Purpose:
This document serves as the single source of truth for the roocode agent. Every time a task is requested, the agent will read this file to understand the project context, including all modules, business logic, domain details, and architectural decisions.
- Project Name: AlphaPulse
- Description:
A sophisticated algorithmic trading system that combines reinforcement learning, technical analysis, and risk management to execute automated trading strategies across multiple asset classes. - Objectives:
- Develop a robust trading system using state-of-the-art machine learning techniques
- Implement comprehensive risk management and portfolio optimization
- Provide real-time market analysis and trade execution capabilities
- Support both paper trading and live trading environments
- Target Audience:
- Quantitative traders and researchers
- Financial institutions
- Individual algorithmic traders
-
Domain Description:
The system operates in the financial markets domain, focusing on algorithmic trading using machine learning. It incorporates technical analysis, market data processing, and automated decision-making. -
Business Objectives & Value:
- Automate trading decisions using AI/ML techniques
- Minimize human emotion in trading decisions
- Optimize portfolio performance through systematic strategies
- Reduce operational risks through automated processes
-
Key Business Rules:
- Rule 1: Risk Management - Strict position sizing and stop-loss implementation
- Rule 2: Data Integrity - Real-time market data validation and cleaning
- Rule 3: Trade Execution - Systematic entry and exit based on ML model predictions
-
System Architecture:
The system follows a modular architecture with clear separation of concerns:AlphaPulse ├── Data Pipeline (Market Data Processing) ├── Feature Engineering ├── ML Models (RL/Supervised) ├── Risk Management ├── Portfolio Management └── Trade Execution
-
Technology Stack:
- Core: Python 3.12+
- ML Framework: PyTorch, Stable-Baselines3
- Data Processing: Pandas, NumPy
- Technical Analysis: TA-Lib
- API Integration: REST/WebSocket clients
- Database: SQL/NoSQL for data persistence
- Description: Handles market data acquisition and preprocessing
- Responsibilities:
- Real-time data fetching
- Historical data management
- Data cleaning and validation
- Key Business Logic:
- Data normalization and feature calculation
- Market data caching and storage
- Dependencies:
- Exchange APIs
- Data providers
- Storage systems
- Description: Implements trading algorithms and models
- Responsibilities:
- Model training and evaluation
- Trading signal generation
- Performance monitoring
- Key Business Logic:
- RL-based trading strategy
- Technical indicator processing
- Market state representation
- Dependencies:
- Data Pipeline
- Feature Engineering
- Risk Management
- Description: Handles risk assessment and position sizing
- Responsibilities:
- Position size calculation
- Stop-loss management
- Portfolio risk monitoring
- Key Business Logic:
- Risk-adjusted position sizing
- Dynamic stop-loss calculation
- Portfolio exposure limits
- Dependencies:
- Portfolio Management
- Trade Execution
- Description: Manages order execution and tracking
- Responsibilities:
- Order placement and management
- Position tracking
- Trade logging
- Key Business Logic:
- Smart order routing
- Trade execution optimization
- Position reconciliation
- Dependencies:
- Exchange APIs
- Risk Management
- Portfolio Management
-
Core Business Processes:
- Market Data Processing
- Real-time data ingestion
- Feature calculation
- State representation
- Trading Decision Making
- Model inference
- Risk assessment
- Order generation
- Trade Execution
- Order placement
- Position management
- Performance tracking
- Market Data Processing
-
Validation & Invariants:
- Market data must be clean and normalized
- Risk limits must be enforced at all times
- Portfolio constraints must be maintained
- Trade execution must be atomic
- Entity Descriptions:
MarketData: - timestamp: DateTime - prices: DataFrame - volumes: DataFrame Position: - asset_id: str - quantity: Decimal - entry_price: Decimal - entry_time: int - exit_price: Optional[Decimal] - exit_time: Optional[int] - pnl: Optional[Decimal] PortfolioData: - timestamp: DateTime - positions: List[Position] - equity: Decimal - exposure: Decimal
-
Internal APIs:
- Data Pipeline Interface
- Model Interface
- Trade Execution Interface
- Risk Management Interface
-
External Services:
- Exchange APIs: For market data and trading
- Data Providers: For additional market data
- Storage Services: For data persistence
-
Performance:
- Sub-second latency for trading decisions
- Real-time data processing capability
- Efficient model inference
-
Scalability & Reliability:
- Horizontal scaling for data processing
- Fault tolerance in trade execution
- Automated recovery mechanisms
-
Security:
- Secure API key management
- Encrypted communications
- Access control and authentication
-
Maintainability:
- Comprehensive logging
- Performance monitoring
- Error tracking and reporting
Version | Date | Author | Changes |
---|---|---|---|
1.0 | 2025-02-14 | Roo | Initial specification |
-
Glossary:
- RL: Reinforcement Learning
- OHLCV: Open, High, Low, Close, Volume
- PnL: Profit and Loss
- Technical Indicators: Mathematical calculations based on price and volume data
-
References:
Note: Update this document as the project evolves to ensure that the roocode agent always has the most up-to-date context.