An intelligent trading system that combines technical analysis, machine learning, and risk management to identify and execute trading opportunities in the stock market.
AI Trading Assistant is a sophisticated trading platform that utilizes artificial intelligence to analyze market data, identify potential trading setups, and manage positions with strict risk management rules. The system is designed to operate in paper trading mode or live trading through either Alpaca or Robinhood integration.
- Real-time market data analysis
- AI-powered trading setup detection
- Automated position management
- Comprehensive risk management
- Performance tracking and analysis
- Pre-market and post-market analysis
- Paper trading support
- Multi-broker support (Alpaca and Robinhood)
- Python 3.9 or higher
- pip package manager
- Git
- pandas
- numpy
- yfinance
- ollama
- colorama
- tabulate
- pytz
- cryptography
- alpaca-py
- Clone the repository:
git clone https://github.com/yourusername/ai-trading-assistant.git
cd ai-trading-assistant
- Create and activate a virtual environment:
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
- Install required packages:
pip install -r requirements.txt
python main.py
The system can be configured through several JSON files:
config.json
: Main system configurationmarket_calendar.json
: Market hours and holidaysalpaca_config.json
: Alpaca API credentials (if using Alpaca)robinhood_config.json
: Robinhood credentials (if using Robinhood)
-
Paper Trading Mode
- Default mode for testing strategies
- No real money involved
- Full functionality for analysis and tracking
-
Live Trading Mode - Alpaca
- Real money trading through Alpaca
- Requires API key and secret
- Supports both paper and live Alpaca accounts
- Enhanced risk management controls
-
Live Trading Mode - Robinhood - Not fully vetted
- Real money trading through Robinhood
- Requires API credentials
- Enhanced risk management controls
- Create an account at https://alpaca.markets/
- Obtain API credentials from your dashboard
- Configure using one of these methods:
- Environment variables:
export ALPACA_API_KEY_ID='your_key' export ALPACA_API_SECRET_KEY='your_secret'
- Interactive setup through the application
- Manual configuration in alpaca_config.json
- Environment variables:
- Configure through interactive setup when running the application
- Requires 2FA verification if enabled
- All activities are logged in
logs/trading_system.log
- Debug information in
logs/trading_system_debug.log
- Performance metrics stored in
logs/performance/
-
Market Monitor
- Tracks market hours and conditions
- Manages trading sessions
-
Stock Scanner
- Identifies potential trading candidates
- Filters based on volume and price criteria
-
Stock Analyzer
- Performs technical analysis
- Calculates key indicators
-
Trading Analyst
- AI-powered setup detection
- Position analysis and management
-
Broker Manager
- Manages broker connections (Alpaca/Robinhood)
- Executes trading decisions
- Manages stop losses and exits
-
Performance Tracker
- Records all trading activity
- Generates performance metrics
[Rest of README remains unchanged with Contributing, Commercial Use, Disclaimer, etc. sections]