This Python script, elliottwaves.py, is used for Elliott Waves analysis on financial data. Elliott Waves are a method of technical analysis that look for recurrent long-term price patterns related to persistent changes in investor sentiment and psychology.
The main function in this script is ElliottWaveFindPattern(df_source, measure, granularity, dateStart, dateEnd, extremes=True). This function finds and analyzes Elliott Wave patterns in the given data.
df_source: A pandas DataFrame containing the source data.measure: The measure to be used for the analysis.granularity: The granularity of the data.dateStart: The start date for the data subset to consider.dateEnd: The end date for the data subset to consider.extremes: A boolean value indicating whether to consider extreme values or not. Default is True.draw_wave function.ElliottWaveDiscovery function.filterWaveSet function.findBestFitWave function.buildWaveChainSet function.The function prints the initial number of waves, the waves themselves, the selected waves, and the best fit wave. It also draws the waves using the draw_wave function.
This script requires pandas for data manipulation and matplotlib for drawing the waves.
To use this script, import it and call the ElliottWaveFindPattern function with the appropriate parameters. Make sure your data is in the correct format and that you have the necessary dependencies installed.
import pandas as pd
from elliottwaves import ElliottWaveFindPattern
# Load your data into a pandas DataFrame
df = pd.read_csv('your_data.csv')
# Call the function
ElliottWaveFindPattern(df, 'Close', 'D', '2020-01-01', '2020-12-31')
The Elliott Waves analysis script requires the following Python packages:
You can install these packages using pip, which is a package manager for Python. Open your terminal and type the following commands:
```bash pip install pandas pip install matplotlib
To visualize the Elliott Waves analysis results, you can use matplotlib to plot the price data and then overlay the identified wave patterns. Here's a basic example of how you might do this:
```python import matplotlib.pyplot as plt
df is your DataFrame and waves is the result from ElliottWaveFindPatterndf['Close'].plot()
for wave in waves: start, end = wave['start'], wave['end'] plt.plot(df.index[start:end], df['Close'][start:end], label=f'Wave {wave["name"]}')
plt.legend() plt.show()
This code first plots the 'Close' prices from your DataFrame. It then loops over the waves returned by ElliottWaveFindPattern, plotting each wave on the same graph. The start and end points of each wave are used to subset the 'Close' prices for that wave. Each wave is labeled with its name.
Please note that this is a basic example and may need to be adjusted based on the exact structure of your waves data and your specific visualization needs.
$ claude mcp add ElliottWaves \
-- python -m otcore.mcp_server <graph>