An automated options trading system with Interactive Brokers integration, built with FastAPI backend and React/TypeScript frontend.
This project implements an automated trading bot for options strategies, providing real-time market data analysis, strategy execution, and portfolio management through Interactive Brokers API.
- Automated Trading: Execute complex options strategies automatically
- Real-time Market Data: Live market data streaming and analysis
- Strategy Management: Multiple pre-configured trading strategies
- Risk Management: Built-in risk controls and position monitoring
- Portfolio Tracking: Real-time P&L and position tracking
- Web Interface: Modern React-based dashboard for monitoring and control
- Paper Trading: Test strategies with simulated trading environment
- FastAPI: High-performance Python web framework
- ib_insync: Interactive Brokers API integration
- PostgreSQL: Database for historical data and configuration
- Redis: Caching and real-time data management
- Celery: Distributed task queue for background processing
- React: Modern UI framework
- TypeScript: Type-safe JavaScript
- Material-UI: Component library for consistent design
- Chart.js: Data visualization
- WebSocket: Real-time data updates
- Python 3.9+
- Node.js 16+
- Interactive Brokers account with API access enabled
- TWS (Trader Workstation) or IB Gateway installed
git clone https://github.com/Milofax/options-strategy-bot-trader.git
cd options-strategy-bot-tradercd backend
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
pip install -r requirements.txtcd frontend
npm installCreate .env files in both backend and frontend directories:
backend/.env
DATABASE_URL=postgresql://user:password@localhost/options_bot
REDIS_URL=redis://localhost:6379
IB_HOST=127.0.0.1
IB_PORT=7497 # Paper trading port (7496 for live)
IB_CLIENT_ID=1
SECRET_KEY=your-secret-keyfrontend/.env
REACT_APP_API_URL=http://localhost:8000
REACT_APP_WS_URL=ws://localhost:8000/wsEnsure IB Gateway or TWS is running and API connections are enabled.
cd backend
python scripts/init_db.pycd backend
uvicorn main:app --reload --port 8000cd frontend
npm startOpen your browser and navigate to http://localhost:3000
The bot supports various options strategies including:
- Covered Calls
- Cash-Secured Puts
- Iron Condors
- Credit Spreads
- Straddles/Strangles
- Custom strategies via configuration
Trading strategies and risk parameters can be configured in backend/config/strategies.yaml:
strategies:
- name: "Iron Condor SPY"
symbol: "SPY"
type: "iron_condor"
parameters:
dte_min: 30
dte_max: 45
delta_short: 0.20
delta_long: 0.10
max_loss: 500
profit_target: 0.50- Position size limits
- Maximum daily loss limits
- Strategy-specific risk parameters
- Automatic stop-loss orders
- Real-time margin monitoring
- Paper trading mode for testing
For detailed documentation, see the /docs directory:
cd backend
pytest tests/cd frontend
npm testContributions are welcome! Please feel free to submit a Pull Request.
- Fork the repository
- Create your feature branch (
git checkout -b feature/AmazingFeature) - Commit your changes (
git commit -m 'Add some AmazingFeature') - Push to the branch (
git push origin feature/AmazingFeature) - Open a Pull Request
IMPORTANT: This software is for educational purposes only. Trading options involves substantial risk of loss and is not suitable for all investors. Past performance is not indicative of future results. Always do your own research and consider consulting with a financial advisor before making investment decisions.
The developers of this software are not responsible for any financial losses incurred through the use of this bot. Use at your own risk.
This project is licensed under the MIT License - see the LICENSE file for details.
- Interactive Brokers for their comprehensive API
- The ib_insync community for excellent Python integration
- All contributors and testers
For questions or support, please open an issue on GitHub.
Note: This bot requires an active Interactive Brokers account with API access permissions. Ensure you understand the risks involved in automated trading before using this system with real money.