Open-source AI-powered trading system using options premium selling and Thompson Sampling strategy selection. Built with Python and Alpaca API.
Current Status: Day 50/90 R&D Phase | $99,450 equity | 50% win rate
Most trading bots fail because they:
- Chase complex strategies that don't work
- Ignore risk management
- Don't learn from mistakes
This system is different:
- Radically simplified - Deleted 90% of bloat, kept what works
- Thompson Sampling - Mathematically optimal strategy selection (~80 lines)
- SQLite trade memory - Query past trades before new ones (~150 lines)
- Daily verification - Honest reporting of actual results
| Metric | Value | Status |
|---|---|---|
| Equity | $99,449.77 | Paper |
| P/L | -$550.23 | -0.55% |
| Win Rate | 50% | Target: 55%+ |
| Backtest Pass | 0/13 | Needs work |
Honest Assessment: System is break-even after 50 days. Options strategy shows promise but execution needs improvement.
Strategy: Sell 15-20 delta puts, 30-45 DTE
Target: 2% monthly premium (24% annual)
Stocks: SPY, QQQ, AMD, NVDA
Risk: Willing to own shares if assigned
- Time decay (theta) works in your favor every day
- High probability - 80%+ of options expire worthless
- Defined risk - You know max loss upfront
- Works in sideways markets - Don't need stocks to go up
git clone https://github.com/IgorGanapolsky/trading.git
cd trading
python3 -m venv venv
source venv/bin/activate
pip install -r requirements.txtcp .env.example .env
# Edit .env with your Alpaca API keys# Paper trading
python3 scripts/autonomous_trader.py
# Check positions
python3 scripts/check_positions.py
# Daily verification
python3 scripts/daily_verification.py┌─────────────────────────────────────────────────────────────┐
│ Trading Pipeline │
├─────────────────────────────────────────────────────────────┤
│ 1. Thompson Sampler - Select best strategy │
│ 2. Trade Memory - Query similar past trades │
│ 3. Risk Manager - Position sizing, stops │
│ 4. Options Strategy - Cash-secured puts │
│ 5. Daily Verification - Honest reporting │
└─────────────────────────────────────────────────────────────┘
│
▼
┌───────────────────────────┐
│ Alpaca API (Execution) │
└───────────────────────────┘
| Component | Purpose | Location |
|---|---|---|
| Orchestrator | Main trading logic | src/orchestrator/main.py |
| Thompson Sampler | Strategy selection | src/learning/thompson_sampler.py |
| Trade Memory | SQLite journal | src/learning/trade_memory.py |
| Risk Manager | Position sizing | src/risk/ |
| Daily Verification | Honest reporting | scripts/daily_verification.py |
- Beta distribution for each strategy
- Sample to select best strategy
- Update based on win/loss outcomes
- Proven optimal for <100 decisions
- SQLite database of past trades
- Query BEFORE each new trade
- Pattern recognition: "This setup has 30% win rate - AVOID"
- Simple but effective
This is NOT financial advice. Paper trade first!
| Safeguard | Description |
|---|---|
| Position Limits | Max 5% per position |
| Daily Loss Limit | 2% max daily loss |
| Circuit Breakers | Auto-halt on 3 consecutive losses |
| Paper Mode | 90-day validation before live |
- R&D Phase - Current 90-day plan
- Verification Protocols - Safety mechanisms
- Profit Optimization - Strategy details
- Environment Variables - Configuration
- Troubleshooting - Common issues
# Run tests
pytest tests/ -v
# Type checking
mypy src/ --ignore-missing-imports
# Lint
ruff check src/This software is for educational purposes only.
- Trading involves significant risk of loss
- Past performance does not guarantee future results
- Always paper trade before using real money
- This is NOT financial advice
Built with Python, Alpaca, and radical simplicity
Maintained by Igor Ganapolsky