An AI-powered trading analysis system that combines technical analysis with LLM-based decision making. The system analyzes market conditions, technical indicators, and uses GPT-4 to generate trading decisions.
TradingAI helps traders by:
- Analyzing market conditions using EMA-based scoring
- Identifying stocks in Stage 2 uptrend
- Providing AI-powered trading decisions with entry/exit points
- Automating data collection and analysis
- Historical data fetching from Zerodha
- Daily EOD data updates
- Data validation and cleaning
- Efficient PostgreSQL storage
- Moving Averages (SMA, EMA)
- MACD Indicator
- Bollinger Bands
- Volume Analysis
- Market Breadth
- Market Condition Assessment (6-point scoring)
- Pattern Recognition
- Trading Signal Generation
- Risk Assessment
- Stop Loss Calculation
- RESTful API endpoints
- Real-time analysis
- Historical data access
- Batch operations
- Clone the repository:
git clone https://github.com/mitesh-sharma/tradingai.git cd tradingai
-
Create and activate virtual environment: python -m venv venv source venv/bin/activate
-
Install dependencies: pip install -e ".[dev]"
-
Set up environment variables: cp .env.example .env
Edit .env with your credentials
- Set up database: createdb tradingai
Required environment variables in .env:
Database
POSTGRES_SERVER=localhost
POSTGRES_USER=postgres
POSTGRES_PASSWORD=your_password
POSTGRES_DB=tradingai
API Security
API_KEY=your_api_key
Zerodha
ZERODHA_API_KEY=your_zerodha_api_key
ZERODHA_API_SECRET=your_zerodha_secret
ZERODHA_USER_ID=your_zerodha_user_id
OpenAI
OPENAI_API_KEY=your_openai_key
LLM_MODEL_NAME=gpt-4
-
Start the server: uvicorn src.tradingai.main:app --reload
-
Fetch historical data: curl -X POST http://localhost:8000/api/v1/stock/stocks/historical
-H "Content-Type: application/json"
-H "X-API-Key: your-secret-key"
-d '{ "symbols": ["ZOTA"], "from_date": "2023-02-22", "to_date": "2024-02-22" }' -
Get analysis with LLM decision: curl http://localhost:8000/api/v1/stock/analyze/ZOTA/with-decision
-H "X-API-Key: your-secret-key"
POST /api/v1/stock/stocks/historical: Fetch historical dataGET /api/v1/stock/analyze/{symbol}: Get technical analysisGET /api/v1/stock/analyze/{symbol}/with-decision: Get analysis with LLM trading decisionGET /api/v1/stock/symbols: List all available symbolsPOST /api/v1/stock/daily-update: Trigger daily data update
- Uses 6-point EMA scoring system
- Analyzes market breadth
- Provides market context and direction
- 30-week SMA trend analysis
- MACD confirmation
- Bollinger Band correction opportunities
- Volume trend analysis
- Uses GPT-4 for decision making
- Structured prompts for consistent analysis
- Includes market context in decisions
- Provides detailed reasoning
- Fork the repository
- Create your 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
Mitesh Sharma
- GitHub: @mitesh-sharma
-
Zerodha for their trading API
-
OpenAI for GPT-4 API
-
FastAPI for the web framework
-
SQLAlchemy for database ORM
This project was developed with the assistance of AI language models (Claude and GPT-4) to demonstrate the potential of AI-powered development while maintaining high code quality and security standards.