ADTA leverages CrewAI and OpenAI's LLM Model for market analysis, signal generation, and risk management—operating strictly during US market hours.
Warning
Disclaimer: ADTA provides simulated trading signals for educational purposes only. Real-time trading behaviour may differ. Not intended for actual investment decisions. Consult a qualified financial advisor.
- Real-time market data collection and validation (WIP; might evolve in the future)
- Technical analysis using RSI, MACD, and Bollinger Bands®
- Risk management and portfolio protection
- Data processing with Polars DataFrames
- Market schedule awareness (9:30 AM - 4:00 PM ET, weekdays only)
- Multi-agent system using CrewAI framework
- Python 3.8+
- OpenAI API key
- Required Python packages:
- crewai
- langchain-openai
- polars
- pandas
- numpy
- tqdm
- icecream
- python-dotenv
- pydantic
- requests
- Clone the repository:
git clone [email protected]:0xnu/day_trading_agents.git
cd day_trading_agents
- Install dependencies:
## Prerequisites
python3 -m venv .venv
source .venv/bin/activate
uv pip install -r requirements.txt
python3 -m pip install --upgrade pip
## When you finish
deactivate
- Set up environment variables:
cp .env.example .env
# Edit .env file with your OpenAI and Alpha Vantage API keys
day_trading_agents/
├── scripts/
│ ├── day_trading_agents.py
│ ├── day_trading_agents_advanced.py
│ └── market_news_agent_terminal.py
├── trading_data/
│ ├── signals/
│ │ ├── csv/ # Polars DataFrame storage
│ │ └── json/ # JSON signal storage
│ └── results/ # Trading session results
├── requirements.txt
└── .env
Enable debug tracking:
# In scripts/day_trading_agents.py
DEBUG = True # Enables icecream logging
Debug features include:
- Configuration validation
- Agent initialisation tracking
- Signal processing progress
- File storage operations
- Exception details
Disable and bypass market hours:
# In scripts/day_trading_agents_advanced.py
enforce_market_hours=False
Run the trading system:
python3 -m scripts.day_trading_agents ## Simple
python3 -m scripts.day_trading_agents_advanced ## Advanced
python3 -m scripts.market_news_agent_terminal ## Market News Terminal
The system will:
- Verify market hours (US Eastern Time)
- Process each stock with progress tracking
- Generate and store trading signals
- Track all operations with debug logging when enabled
Collects and validates real-time market data using GPT-4 Turbo, ensuring data quality and completeness.
Analyses market data using technical indicators (RSI, MACD, Bollinger Bands®) to generate trading signals with confidence scores.
Evaluates trading signals, manages risk parameters, and provides portfolio protection strategies.
Config
: System configuration and parametersStockInfo
: Basic stock informationMarketData
: Market data validation modelTechnicalSignal
: Technical analysis signals with confidence scores
Handles real-time market data collection and validation using Alpha Vantage API. The agent:
- Retrieves current and historical price data with rate limiting (5 calls/minute)
- Implements caching to minimise API calls (60-second expiry)
- Validates data quality and completeness
- Processes batch requests for multiple stock symbols
- Stores data in both CSV and JSON formats for analysis
Performs technical analysis using multiple indicators:
-
RSI (Relative Strength Index)
- Calculates momentum with 14-period default
- Generates buy signals below 30
- Generates sell signals above 70
-
MACD (Moving Average Convergence Divergence)
- Uses 12/26/9 standard periods
- Identifies trend reversals and momentum
- Generates signals based on line crossovers
-
Bollinger Bands®
- Implements 20-period moving average with 2 standard deviations
- Generates buy signals at lower band crosses
- Generates sell signals at upper band crosses
Evaluates trading signals and manages portfolio risk:
- Analyses confidence scores for each technical signal
- Monitors signal metadata and technical indicators
- Provides risk assessments based on market conditions
- Generates trade recommendations with risk parameters
- Stores assessment results for future analysis
- API keys for OpenAI and Alpha Vantage (SecretStr for security)
- Model selection and parameters (temperature, max tokens)
- File paths for data and signal storage
- Market hours enforcement flags
- Stock symbol list with descriptions
- Debugging and logging settings
- Trading symbol
- Company name
- Market sector
- Market capitalisation
- Average trading volume
- Trading symbol
- Timestamp with timezone awareness
- OHLC (Open, High, Low, Close) prices
- Trading volume
- Data validation status
- Trading symbol and timestamp
- Indicator type (RSI, MACD, Bollinger Bands®)
- Signal value and direction (Buy, Sell, Hold)
- Confidence score (0-1 range)
- Technical metadata dictionary containing:
- RSI values
- MACD line and signal line
- Bollinger Band values (upper, middle, lower)
- Additional indicator-specific data
- Structured storage in CSV and JSON formats
- Timestamp-based file organisation
- Historical signal retrieval
- Data persistence and backup
- Signal aggregation and filtering
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the BSD 3-Clause License.
@misc{afoadta2024,
author = {Oketunji, A.F.},
title = {Automated Day Trading Agents (ADTA)},
year = 2024,
version = {2.0.1},
publisher = {Zenodo},
doi = {10.5281/zenodo.14536356},
url = {https://doi.org/10.5281/zenodo.14536356}
}
(c) 2024 Finbarrs Oketunji. All Rights Reserved.