- Added DataConnector base class with OHLCV, InstrumentInfo, Interval - Implemented MoomooClient with rate limiting, circuit breaker, caching - Mock mode generates realistic data for development - Real-time WebSocket subscription support (mock) - Added examples/demo_moomoo.py showcasing functionality - Updated requirements.txt with requests, websocket-client, redis, python-dotenv - Updated README.md with Data Layer documentation - Added .env.example for configuration
80 lines
2.2 KiB
Markdown
80 lines
2.2 KiB
Markdown
# Quantitative Trading Platform
|
|
|
|
A quantitative trading platform with modular architecture for data acquisition, strategy execution, risk management, and UI/UX.
|
|
|
|
## Architecture
|
|
|
|
See `component_diagram.md` and `architecture_diagram.txt` in the parent directory (`/home/thanthos/clawd/`) for detailed system design.
|
|
|
|
## UI/UX Module
|
|
|
|
### Dashboard
|
|
Simple dashboard displaying key trading metrics:
|
|
- PnL (Profit and Loss)
|
|
- Drawdown
|
|
- Win Rate
|
|
|
|
## Data Layer Module
|
|
|
|
### Moomoo API Connector
|
|
A robust Python client for moomoo API with comprehensive error handling, rate limiting, and data normalization.
|
|
|
|
**Features:**
|
|
- Historical OHLCV data retrieval
|
|
- Real-time WebSocket subscription (mock)
|
|
- Instrument metadata
|
|
- Rate limiting (token bucket algorithm)
|
|
- Circuit breaker pattern for fault tolerance
|
|
- Caching with TTL
|
|
- Mock mode for development
|
|
|
|
**Usage:**
|
|
```python
|
|
from data.connectors import create_moomoo_client, Interval
|
|
from datetime import datetime, timedelta
|
|
|
|
client = create_moomoo_client(mock_mode=True)
|
|
data = client.get_ohlcv(
|
|
symbol="AAPL",
|
|
interval=Interval.DAY_1,
|
|
start_date=datetime.now() - timedelta(days=30),
|
|
end_date=datetime.now()
|
|
)
|
|
```
|
|
|
|
See `examples/demo_moomoo.py` for complete demonstration.
|
|
|
|
## Development
|
|
|
|
### Prerequisites
|
|
- Python 3.8+
|
|
- Node.js (for frontend, optional)
|
|
- Docker (optional)
|
|
- Redis (optional, for caching)
|
|
|
|
### Setup
|
|
1. Clone the repository
|
|
2. Install dependencies: `pip install -r requirements.txt`
|
|
3. Run the dashboard: `python app.py`
|
|
4. Test data connector: `python examples/demo_moomoo.py`
|
|
|
|
### Data Layer Development
|
|
The data connector uses a modular design with base classes for easy extension:
|
|
- `DataConnector` abstract base class
|
|
- `MoomooClient` implementation with mock mode
|
|
- Rate limiting and circuit breaker patterns
|
|
- Caching support (in-memory or Redis)
|
|
|
|
To extend with real API credentials:
|
|
1. Set environment variables: `MOOMOO_API_KEY`, `MOOMOO_SESSION_TOKEN`
|
|
2. Set `mock_mode=False` when creating client
|
|
3. Implement actual API calls in `_make_request()` method
|
|
|
|
### UI/UX Development
|
|
The dashboard is built with Flask (backend) and Bootstrap/Chart.js (frontend).
|
|
- Backend: `app.py` provides REST API endpoints
|
|
- Frontend: `templates/dashboard.html` with interactive charts
|
|
|
|
## License
|
|
|
|
Proprietary |