A modular Python bot that analyzes multiple US stocks (AAPL, NVDA, MSFT, GOOGL) using technical charting, OpenAI's Vision Language Model (VLM) for chart analysis, and mock fundamental news. The bot generates trading signals, applies risk management, and simulates trade execution.
- Automated Chart Generation: Fetches historical data and generates candlestick charts with technical indicators (Moving Averages, RSI, MACD, Bollinger Bands).
- Vision-Based Chart Analysis: Uses OpenAI's VLM to analyze chart images and extract structured technical insights.
- Mock Fundamental Analysis: Simulates news-based sentiment for each stock.
- Risk Management: Calculates position size, stop loss, and take profit based on account equity and risk parameters.
- Simulated Trade Execution: Logs trade signals and parameters for backtesting or demonstration.
- Extensible & Modular: Easily add new symbols, indicators, or real broker integration.
- Python 3.8+
- The following Python packages (see
requirements.txt):- openai
- pandas
- numpy
- matplotlib
- mplfinance
- requests
- Pillow
- yfinance
Install dependencies with:
pip install -r requirements.txt- Clone the repository and navigate to the project directory.
- Configure API Keys:
- Open
config.pyand add your OpenAI API key toOPENAI_API_KEY. - (Optional) Add your Finnhub API key to
FINNHUB_API_KEYif you plan to extend fundamental analysis.
- Open
- (Optional) Adjust Trading Symbols:
- Edit
TRADING_SYMBOLSinconfig.pyto analyze different stocks.
- Edit
- Review Risk Settings:
- Adjust
RISK_SETTINGSinconfig.pyto match your risk profile.
- Adjust
Run the bot from the command line:
python main.py- The bot will analyze each symbol in
TRADING_SYMBOLS, generate charts, run VLM analysis, apply risk management, and simulate trades. - Logs and results are saved to
trading_bot.logand chart images are saved as PNG files in the project directory.
- API Keys: Set in
config.py(OPENAI_API_KEY,FINNHUB_API_KEY). - Symbols: Edit
TRADING_SYMBOLSinconfig.py. - Risk Management: Adjust
RISK_SETTINGSfor account equity, risk per trade, and reward/risk ratio. - Chart/Indicator Settings: Modify
GENERIC_CHART_SETTINGS,INDICATOR_SETTINGS_DAILY, andINDICATOR_SETTINGS_HOURLYinconfig.py.
main.py— Entry point; runs the analysis cycle for all symbols.orchestrator.py— Central logic for coordinating charting, analysis, and trade simulation.chart_generator.py— Fetches data and generates charts with indicators.vlm_analyzer.py— Sends chart images to OpenAI VLM and parses the response.news_analyzer.py— Mock fundamental news analysis.risk_manager.py— Calculates position size, stop loss, and take profit.trade_executor.py— Simulates trade execution and logs results.config.py— All configuration (API keys, symbols, risk, indicator settings).requirements.txt— Python dependencies.trading_bot.log— Log file with all analysis and trade actions.
- API Keys: The bot will not run VLM analysis without a valid OpenAI API key.
- Fundamental Analysis: Currently uses mock data; extend
news_analyzer.pyfor real news APIs. - Broker Integration: Trade execution is simulated; integrate with a real broker for live trading.
- Extensibility: Add new symbols, indicators, or analysis modules as needed.
For research, educational, and backtesting purposes only. Not financial advice.