A comprehensive machine learning system for generating trading signals (Buy/Sell/Hold) for forex and cryptocurrency instruments using the OANDA API. This project provides a complete pipeline from data collection to production deployment with automated model retraining and promotion.
Table of Contents
Overview
This system implements an end-to-end machine learning workflow for forex/crypto trading signal generation:
Data Collection: Fetches historical candle data from OANDA API
If custom processing, always use pd.to_datetime(..., utc=True)
Best Practices
Model Validation: - Always review latest_metrics.json before promoting - Use promote_if_better.py with conservative thresholds - Monitor retrain_log.csv for performance drift
Data Quality: - Fetch fresh data regularly (daily/weekly retraining) - Validate candle data for gaps or anomalies - Handle market closures and holiday gaps appropriately
Service Management: - Use PowerShell scripts for consistent service lifecycle - Monitor service health (add health check endpoint) - Set up logging with log rotation - Consider containerization (Docker) for deployment
Risk Management: - Always use stop-loss orders - Don't blindly follow signals (use as input to decision process) - Backtest on historical data before live trading - Start with paper trading/practice account
Monitoring: - Log all predictions with timestamps - Track signal distribution (Buy/Sell/Hold ratios) - Monitor model confidence scores - Set up alerts for service downtime
Version Control: - Git ignore *.pkl, *.csv, oanda_credentials.json - Track pipeline scripts and configuration - Tag model versions with Git tags
Testing: - Test with --no-train flag to validate data pipeline - Use small --count values during development - Validate predictions on known historical events
Experimentation: - Keep timestamped model files for A/B testing - Document parameter changes in retrain_log.csv - Use Jupyter notebooks for feature analysis
Code Quality: - Add type hints for better IDE support - Write unit tests for feature calculations - Document custom modifications in comments
Additional Resources
Contributing & Version Control
Setting Up Git
This project uses Git for version control. To clone and work with this repository:
*.pkl - Model files (too large, regenerate locally)
*.csv - Data files (regenerate using pipeline)
venv/ - Virtual environment
*.pid - Process ID files
Safe to commit:
All Python scripts
requirements.txt
oanda_credentials.json.example (template only)
PowerShell scripts
Documentation
Fork the repository
Create a feature branch (git checkout -b feature/amazing-feature)
Commit your changes (git commit -m 'Add amazing feature')
Push to the branch (git push origin feature/amazing-feature)
Open a Pull Request
This project is provided as-is for educational and research purposes. Use at your own risk. Trading involves substantial risk of loss and is not suitable for every investor.
IMPORTANT: This software is for educational purposes only. It is not financial advice. Trading forex and cryptocurrencies carries significant risk. Past performance does not guarantee future results. Always do your own research and consult with a licensed financial advisor before making trading decisions.
Project Status: Active Development Last Updated: October 2025 Python Version: 3.8+ Platform: Cross-platform (Windows PowerShell scripts for service management)