Here’s a summary of the steps to run your algorithmic trading application, formatted as a README.md file. This will guide users on setting up the project, preparing data, training models, generating predictions, and backtesting.
This project is an algorithmic trading application that uses machine learning models to predict stock prices and generate trading signals. The application supports data preprocessing, model training, prediction generation, backtesting, and visualization.
- Data Preprocessing
- Model Training (Regression for price prediction and Classification for probability of target price)
- Generating Predictions
- Backtesting Strategy
- Visualizing Performance
- Python 3.7+
- Virtual environment (recommended)
- Required Python packages (listed in
requirements.txt)
- Clone the Repository:
git clone https://gitlab.com/algotradinggroup1/pythonalgorithmictrading.git cd pythonalgorithmictrading 2. Create and Activate a Virtual Environment:
python3 -m venv venv source venv/bin/activate # On Windows, use venv\Scripts\activate
3. Install Dependencies:
pip install -r requirements.txt
Running the Application
- Data Preprocessing
Preprocess raw data and generate normalized features for model training.
python3 scripts/preprocess.py
• Input: data/nq_data.csv
• Output: data/processed_nq_data.csv
- Model Training
Train both regression and classification models on the processed data.
• Regression Model: Predicts closing prices.
• Classification Model: Predicts the probability of reaching the target price.
python3 scripts/regression_training.py python3 scripts/classification_training.py
• Output:
• models/regression_model.pkl
• models/classification_model.pkl
- Generate Predictions
Use the trained models to predict closing prices and probabilities.
python3 scripts/predict.py
• Input: data/processed_nq_data.csv
• Output: data/predicted_results.csv
- Backtest the Strategy
Simulate trading using predictions to evaluate the strategy’s profitability.
python3 scripts/backtest.py
• Input: data/predicted_results.csv
• Output: data/backtest_results.csv
- Visualize Results
Generate visualizations for model predictions and strategy performance.
python3 scripts/visualization.py
• This will display:
• Actual vs Predicted Closing Prices
• Predicted Probability of Reaching Target
• Strategy Cumulative Returns
Configuration
Modify parameters in individual scripts to adjust thresholds, model hyperparameters, and backtesting conditions.
File Structure
• data/: Contains raw and processed data files.
• models/: Stores trained model files.
• scripts/: Python scripts for each step in the workflow.
• preprocess.py: Data preprocessing.
• regression_training.py: Regression model training.
• classification_training.py: Classification model training.
• predict.py: Generate predictions.
• backtest.py: Backtesting strategy.
• visualization.py: Visualize performance.
Additional Notes
• The .gitignore file excludes unnecessary files such as virtual environments, log files, and configuration files.
• Experiment with different thresholds and parameters to improve the model and strategy performance.
License
This project is licensed under the MIT License. See LICENSE for details.
This README.md provides a structured summary of the steps involved in setting up, running, and evaluating the algorithmic trading application. Let me know if you'd like to add more details or have specific instructions included!
e24c9e5 (Visualization changes)