This repository contains the code and documentation for a stock prediction and trading strategy project. The project aims to predict stock prices using an ARIMA model and implement a trading strategy based on the model's predictions.
- Clone the repository:
git clone https://github.com/your-username/stock-prediction-trading.git
- Install the required dependencies:
pip install -r requirements.txt
- Open the Jupyter Notebook file Stock_Prediction_Trading.ipynb in a Jupyter environment.
- Run the cells to execute the code and generate predictions.
- Explore the simulation results and visualize trading performance.
- Jupyter Notebook containing the code for stock prediction and trading simulation.
- Requirements file
- Python
- Jupyter Notebook
- pandas
- yfinance
- matplotlib
- seaborn
- statsmodels
- tqdm
pip install -r requirements.txt
The historical stock price data for Microsoft (MSFT) is downloaded using the yfinance library.
- Data Collection:
- Historical stock price data for MSFT is downloaded using the yfinance library.
- Data Preprocessing:
- Data is cleaned and explored to handle null values.
- Stationarity Check:
- The Augmented Dickey-Fuller and KPSS tests are performed to check stationarity.
- Differencing is applied to make the data stationary.
- ARIMA Modeling:
- A suitable ARIMA model is chosen based on ACF and PACF plots.
- The model is trained on the differenced data.
- Trading Strategy Simulation:
- A simulation is run using the ARIMA model to make buy/sell decisions based on specified thresholds.
- Simulation results, including returns, are recorded.
- Threshold = 0:
- Initial Amount: $100
- Positive Return: 0.38%
- Total Return Amount: $100.38
- Threshold = 0.001:
- Initial Amount: $100
- Positive Return: 3.4%
- Total Return Amount: $103.4
- Threshold = 0.005:
- Initial Amount: $100
- Positive Return: 7.45%
- Total Return Amount: $107.45
- If you'd like to contribute to this project, please follow these steps:
- Fork the repository.
- Create a new branch for your feature:
git checkout -b feature-name
- Commit your changes:
git commit -m 'Add new feature'
- Push to the branch:
git push origin feature-name
- Submit a pull request.