Revolutionary options trading system combining chess AI with financial markets
Features β’ Quick Start β’ Documentation β’ Examples
ChessTrader is a sophisticated AI-powered options trading system that applies chess engine principles to financial markets. By combining spatial neural networks, regime detection, and reinforcement learning, it provides intelligent strategy recommendations and comprehensive backtesting capabilities.
- Chess-Inspired AI: Leverages spatial pattern recognition from chess engines
- 16 Options Strategies: Complete coverage from conservative to aggressive approaches
- Regime Detection: AI identifies market conditions for optimal strategy selection
- ML-Driven Recommendations: Confidence-scored suggestions with risk assessment
- Professional Backtesting: Monte Carlo simulation with walk-forward optimization
- Production Ready: Both CLI and programmatic API interfaces
- Spatial Neural Networks: Chess-inspired 7x6 board representation for options positions
- Regime Detection: 8-regime market classification with confidence scoring
- Reinforcement Learning: PPO-trained position management with game-theoretic modeling
- Strategy Selection: ML-powered ranking of 16 options strategies
- Neutral: Iron Condor, Iron Butterfly, Short Straddle, Short Strangle
- Directional: Bull/Bear Call/Put Spreads, Covered Call, Protective Put
- Volatility: Long Straddle, Long Strangle, Calendar Spreads, Diagonal Spreads
- Advanced: Collar, Synthetic positions with dynamic risk management
- Event-Driven Engine: Realistic order execution with slippage and commissions
- Walk-Forward Optimization: Out-of-sample validation with ML pipeline integration
- Monte Carlo Simulation: Statistical confidence intervals and risk metrics
- Performance Reporting: Professional tearsheets with HTML/PDF export
- CLI Application: Rich-formatted command-line interface with progress indicators
- Python API: Async-first programmatic access for custom applications
- Configuration: Flexible JSON/environment variable configuration system
# Clone the repository
git clone https://github.com/chesstrader/chesstrader.git
cd chesstrader
# Install dependencies
pip install -r requirements.txt
# Install as editable package (enables 'chesstrader' command)
pip install -e .
# Verify installation
chesstrader --version# Get AI-powered strategy recommendations
chesstrader recommend AAPL
chesstrader recommend SPY --confidence 0.6 --max-results 5 --details
# Run comprehensive backtesting
chesstrader backtest --symbol AAPL
chesstrader backtest --symbol SPY --strategy iron_condor --start-date 2023-01-01 --save-report
# View help for any command
chesstrader --help
chesstrader recommend --help
chesstrader backtest --helpimport asyncio
from src.main import OptionsAI
# Initialize the AI system
ai = OptionsAI()
# Get strategy recommendations
async def get_recommendations():
recommendations = await ai.get_recommendations('AAPL')
for rec in recommendations:
print(f"{rec['strategy']}: {rec['confidence']:.2%} confidence")
# Run backtest
async def run_backtest():
results = await ai.run_backtest({
'symbol': 'SPY',
'start_date': '2023-01-01',
'end_date': '2023-12-31',
'strategy': 'iron_condor'
})
print(f"Sharpe Ratio: {results['sharpe_ratio']:.2f}")
# Execute async functions
asyncio.run(get_recommendations())
asyncio.run(run_backtest())Strategy Recommendations:
π― Strategy Recommendations for AAPL
βββββββββββββββββ³ββββββββββββββ³ββββββββ³βββββββββββββββββ
β Strategy β Confidence β Score β Market Outlook β
β‘βββββββββββββββββββββββββββββββββββββββββββββββββββββββ©
β Iron Condor β 85.0% β 92 β neutral β
β Bull Put β 72.0% β 78 β bullish β
β Calendar β 68.0% β 75 β low_volatility β
βββββββββββββββββ΄ββββββββββββββ΄ββββββββ΄βββββββββββββββββ
Backtesting Results:
π Key Performance Metrics
βββββββββββββββββ³ββββββββββ
β Total Return β 15.2% β
β Sharpe Ratio β 1.23 β
β Max Drawdown β -8.1% β
β Win Rate β 65.0% β
βββββββββββββββββ»ββββββββββ
Overall Performance: β
Good
ChessTrader implements a sophisticated multi-layer architecture:
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
β User Interfaces β
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β β CLI (Typer) β β Python API (Async) ββ
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Core AI Engine β
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β β Strategy β β Position Manager ββ
β β Recommender β β (PPO + RL) ββ
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Neural Architecture β
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β β Spatial Encoder β β Regime Detector ββ
β β (Chess-inspired)β β (8-regime classification)ββ
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Backtesting Engine β
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
β β Event-Driven β β Monte Carlo Simulator ββ
β β Simulation β β + Statistical Analysis ββ
β βββββββββββββββββββ ββββββββββββββββββββββββββββββββ
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ€
β Strategy Framework β
β 16 Options Strategies β
β Iron Condor β’ Straddles β’ Spreads β’ Collars β
βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
- Python: 3.8 or higher
- Dependencies: See
requirements.txtfor complete list - Memory: 4GB+ RAM recommended for neural network operations
- Storage: 1GB+ for caching market data and model weights
torch>=2.0.0 # Neural network framework
scikit-learn>=1.3.0 # Machine learning utilities
pandas>=2.0.0 # Data manipulation
yfinance>=0.2.28 # Market data provider
typer>=0.9.0 # CLI framework
rich>=13.7.0 # Terminal formatting
fastapi>=0.100.0 # Web API framework
pydantic>=2.0.0 # Configuration management
- API Reference - Complete programmatic API documentation
- CLI Guide - Comprehensive command-line interface guide
- Examples - Working code examples and tutorials
# examples/basic_usage.py - Get AI recommendations
from src.main import OptionsAI
import asyncio
async def main():
ai = OptionsAI()
# Get recommendations with custom confidence threshold
ai.update_config(recommendation__confidence_threshold=0.7)
recommendations = await ai.get_recommendations('SPY')
for rec in recommendations:
details = ai.get_strategy_details(rec['strategy'])
print(f"Strategy: {rec['strategy']}")
print(f"Confidence: {rec['confidence']:.2%}")
print(f"Description: {details['description']}")
print("---")
asyncio.run(main())# examples/backtest_example.py - Comprehensive backtesting
from src.main import OptionsAI
import asyncio
async def main():
ai = OptionsAI()
# Configure backtest parameters
config = {
'symbol': 'QQQ',
'start_date': '2022-01-01',
'end_date': '2023-12-31',
'initial_capital': 100000,
'commission': 0.65,
'strategy': 'iron_condor'
}
# Run backtest with progress tracking
results = await ai.run_backtest(config)
# Analyze results
print(f"Total Return: {results['total_return']:.2%}")
print(f"Sharpe Ratio: {results['sharpe_ratio']:.2f}")
print(f"Max Drawdown: {results['max_drawdown']:.2%}")
# Save detailed report
ai.save_config('backtest_config.json')
asyncio.run(main())chesstrader/
βββ src/ # Source code
β βββ main.py # OptionsAI main class
β βββ config.py # Configuration management
β βββ cli/ # Command-line interface
β βββ api/ # Strategy recommendation API
β βββ models/ # Neural network models
β βββ strategies/ # Options strategy implementations
β βββ backtesting/ # Backtesting engine
β βββ features/ # Feature engineering
β βββ data/ # Data providers
βββ tests/ # Test suite
βββ examples/ # Usage examples
βββ docs/ # Documentation
βββ .planning/ # Development planning (GSD workflow)
βββ requirements.txt # Dependencies
# Install development dependencies
pip install -e ".[dev]"
# Run test suite
pytest
# Run with coverage
pytest --cov=src --cov-report=html
# Run specific test files
pytest tests/test_main.py -v
pytest tests/cli/ -v- Fork the repository
- Create a feature branch:
git checkout -b feature/amazing-feature - Make your changes and add tests
- Ensure all tests pass:
pytest - Commit your changes:
git commit -m 'Add amazing feature' - Push to the branch:
git push origin feature/amazing-feature - Submit a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Issues: GitHub Issues
- Documentation: API Reference
- Examples: examples/
- Chess AI research community for spatial pattern recognition techniques
- Options trading community for strategy frameworks and risk management principles
- Open source machine learning ecosystem (PyTorch, scikit-learn, pandas)
Built with β€οΈ for the intersection of artificial intelligence and quantitative finance