This project involves analyzing Bitcoin (BTC) price data to identify pivot points and develop a trading strategy based on these pivot points. The analysis is performed using historical BTC price data from Yahoo Finance, processed and visualized using Python libraries such as pandas, numpy, matplotlib, and yfinance.
- Data Acquisition: Fetch historical BTC-USD data from Yahoo Finance.
- Pivot Points Calculation: Identify pivot points based on cumulative returns over specified windows and days.
- Trading Strategy Simulation: Implement a trading strategy that leverages pivot points to make trading decisions, incorporating a stop-loss mechanism.
- Strategy Optimization: Use multiprocessing to optimize the trading strategy by testing various combinations of parameters.
- Visualization: Plot the cumulative returns and strategy performance, highlighting pivot points and trading signals.
- Data Acquisition: The data for BTC-USD is downloaded and processed to calculate returns and cumulative returns.
- Pivot Points Calculation: The function
find_pivs
calculates pivot points based on the maximum cumulative returns over a rolling window. - Trading Strategy: The function
run_strat
simulates a trading strategy based on the identified pivot points and includes a stop-loss mechanism. - Optimization: The function
optimize
is used to find the best parameters (window size, days high, stoploss) for the strategy. - Visualization: Use
plot_pivots
andplot_strat
to visualize the pivot points and the performance of the trading strategy respectively.
Pivot Points.ipynb
: Jupyter notebook containing all the code and documentation for the analysis.
Ensure you have Jupyter installed, or use Google Colab to run the notebook. Open the notebook and execute the cells sequentially to reproduce the analysis.