Skip to content

Commit 7f5e955

Browse files
committed
fix: Resolve all configuration issues and duplicates
Critical Fixes: - Fix duplicate /api/market-data prefix: Changed market_data_workflow to /api/market-data/workflow - Fix Celery app name: Changed from 'quantum_trading_matrix' to 'octopus_trading_platform' - Fix Celery worker queues: Added all missing queues (ml_training, risk, strategies, analytics, generative, llm) - Fix agents_v2.py prefix: Changed to /api/agents/v2 to avoid conflicts - Standardize queue naming: Use data_processing (underscore) consistently Documentation: - Add API_ROUTES_DOCUMENTATION.md: Comprehensive route documentation - Add CONFIGURATION_ISSUES.md: Detailed issue tracking and fixes - Add MARKET_DATA_WORKFLOW.md: Market data workflow documentation All critical route conflicts and misconfigurations resolved.
1 parent 3528f23 commit 7f5e955

14 files changed

Lines changed: 1775 additions & 78 deletions

API_ROUTES_DOCUMENTATION.md

Lines changed: 178 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,178 @@
1+
# API Routes Documentation
2+
3+
## Overview
4+
5+
This document provides a comprehensive guide to all API routes in the Octopus Trading Platform.
6+
7+
## Route Organization
8+
9+
### Authentication & Authorization
10+
- `/api/auth/*` - Professional Authentication (`professional_auth.py`)
11+
- `/auth/*` - Legacy Authentication (`auth.py`)
12+
13+
### Market Data APIs
14+
15+
#### Professional Market Data
16+
- **Prefix**: `/api/market-data`
17+
- **Router**: `professional_market_data.py`
18+
- **Purpose**: Professional-grade real-time and historical market data
19+
- **Features**: Real-time quotes, historical data, technical indicators
20+
21+
#### Market Data Workflow
22+
- **Prefix**: `/api/market-data/workflow`
23+
- **Router**: `market_data_workflow.py`
24+
- **Purpose**: Workflow management for fetching market data from free APIs
25+
- **Features**: Batch fetching, async tasks, source status, historical data
26+
27+
#### Legacy Market Data (V1)
28+
- **Prefix**: `/api/v1/market-data`
29+
- **Router**: `market_data.py` (from routes)
30+
- **Purpose**: Legacy API for backward compatibility
31+
32+
#### Simple Real Market Data
33+
- **Prefix**: `/api` (specific endpoints)
34+
- **Router**: `simple_real_data.py`
35+
- **Purpose**: Simple, lightweight market data endpoints
36+
37+
### Real-Time Data
38+
- **Prefix**: `/api/v1/realtime`
39+
- **Router**: `realtime.py` (from routes)
40+
- **Purpose**: Real-time data streaming and updates
41+
42+
### Machine Learning
43+
- **Prefix**: `/api/v1/ml`
44+
- **Router**: `ml_models.py` (from routes)
45+
- **Purpose**: ML model management and predictions
46+
47+
### Portfolio Management
48+
- **Prefix**: `/portfolios`
49+
- **Router**: `portfolios.py` (from routes)
50+
- **Purpose**: Portfolio CRUD operations
51+
52+
### Agent Monitoring
53+
- **Prefix**: `/api/agents`
54+
- **Router**: `agents.py`
55+
- **Purpose**: AI agent status, logs, and decisions
56+
57+
- **Prefix**: `/api/agents/v2`
58+
- **Router**: `agents_v2.py`
59+
- **Purpose**: Alternative/backup agent monitoring API
60+
61+
### Wallet & Funding
62+
- **Prefix**: `/api/wallet`
63+
- **Router**: `wallet.py`
64+
- **Purpose**: Multi-currency balances, transactions, bank accounts
65+
66+
### Security & Access Control
67+
- **Prefix**: `/api/security`
68+
- **Router**: `security.py`
69+
- **Purpose**: API keys, sessions, trading permissions
70+
71+
### Market Scenarios
72+
- **Prefix**: `/api/scenarios`
73+
- **Router**: `scenarios.py`
74+
- **Purpose**: Market regime scenario analysis
75+
76+
### Risk Management
77+
- **Prefix**: `/api/risk`
78+
- **Router**: `risk.py`
79+
- **Purpose**: Risk metrics and analysis
80+
81+
### LLM & AI Analytics
82+
- **Prefix**: `/llm`
83+
- **Router**: `llm_simple.py`
84+
- **Purpose**: Language model operations
85+
86+
### Real Data Sources
87+
- **Prefix**: `/api` (specific endpoints)
88+
- **Routers**:
89+
- `macro_data.py` - Macro economic data
90+
- `onchain_data.py` - On-chain crypto data
91+
- `social_data.py` - Social sentiment data
92+
93+
### WebSocket Endpoints
94+
95+
#### Main WebSocket
96+
- **Path**: `/ws`
97+
- **Type**: Direct WebSocket endpoint
98+
- **Purpose**: Real-time market data streaming
99+
- **Implementation**: `main_refactored.py` (direct endpoint)
100+
101+
#### WebSocket API (V1)
102+
- **Prefix**: `/api/v1/websocket`
103+
- **Router**: `websocket.py` (from routes)
104+
- **Purpose**: Legacy WebSocket API
105+
106+
#### WebSocket Real-time
107+
- **Prefix**: `/api/ws`
108+
- **Router**: `websocket_realtime.py`
109+
- **Purpose**: Real-time agent status and wallet transaction updates
110+
111+
### Comprehensive API
112+
- **Prefix**: `/api`
113+
- **Router**: `comprehensive_api.py`
114+
- **Purpose**: Comprehensive trading operations and analytics
115+
116+
## Route Conflicts Resolution
117+
118+
### Market Data Routes
119+
All market data routes are now properly separated:
120+
- `/api/market-data` - Professional API
121+
- `/api/market-data/workflow` - Workflow management
122+
- `/api/v1/market-data` - Legacy V1 API
123+
- `/api/real-market-data` - Simple endpoints
124+
125+
### Agent Routes
126+
- `/api/agents` - Main agent monitoring
127+
- `/api/agents/v2` - Alternative/backup API
128+
129+
### WebSocket Routes
130+
- `/ws` - Main WebSocket (direct)
131+
- `/api/v1/websocket` - Legacy API
132+
- `/api/ws` - Real-time updates
133+
134+
## Best Practices
135+
136+
1. **Use Professional APIs**: Prefer `/api/market-data` over legacy routes
137+
2. **Workflow API**: Use `/api/market-data/workflow` for batch operations
138+
3. **WebSocket**: Use `/ws` for main real-time streaming
139+
4. **Versioning**: V1 routes are for backward compatibility only
140+
141+
## Migration Guide
142+
143+
### From Legacy to Professional APIs
144+
145+
**Old**: `/api/v1/market-data/current/{symbol}`
146+
**New**: `/api/market-data/quote/{symbol}`
147+
148+
**Old**: `/api/v1/market-data/historical/{symbol}`
149+
**New**: `/api/market-data/historical/{symbol}`
150+
151+
### From Simple to Workflow API
152+
153+
**Old**: `/api/real-market-data`
154+
**New**: `/api/market-data/workflow/fetch/{symbol}`
155+
156+
## Authentication
157+
158+
Most endpoints require JWT authentication:
159+
```
160+
Authorization: Bearer <token>
161+
```
162+
163+
Exceptions:
164+
- `/health` - Public health check
165+
- `/docs` - API documentation
166+
- `/` - Root endpoint
167+
168+
## Rate Limiting
169+
170+
All authenticated endpoints have rate limiting:
171+
- Default: 30 requests per minute
172+
- Some endpoints may have custom limits
173+
174+
Check response headers:
175+
- `X-RateLimit-Limit`: Maximum requests
176+
- `X-RateLimit-Remaining`: Remaining requests
177+
- `X-RateLimit-Reset`: Reset time
178+

CONFIGURATION_ISSUES.md

Lines changed: 138 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,138 @@
1+
# Configuration Issues & Fixes
2+
3+
## 🔴 Critical Issues Found
4+
5+
### 1. **DUPLICATE API PREFIX: `/api/market-data`**
6+
7+
**Problem:**
8+
- `professional_market_data.py` has prefix: `/api/market-data`
9+
- `market_data_workflow.py` has prefix: `/api/market-data`
10+
- Both are registered in `main_refactored.py`, causing route conflicts!
11+
12+
**Location:**
13+
- `Modules/src/api/endpoints/professional_market_data.py:20`
14+
- `Modules/src/api/endpoints/market_data_workflow.py:27`
15+
- `Modules/src/main_refactored.py:135, 159`
16+
17+
**Fix:**
18+
Change one of the prefixes. Recommended:
19+
- Keep `professional_market_data.py` as `/api/market-data`
20+
- Change `market_data_workflow.py` to `/api/market-data/workflow`
21+
22+
### 2. **DUPLICATE AGENTS ROUTER**
23+
24+
**Problem:**
25+
- `agents.py` has prefix: `/api/agents`
26+
- `agents_v2.py` has prefix: `/api/agents` (duplicate!)
27+
- Only `agents.py` is registered, but `agents_v2.py` exists with same prefix
28+
29+
**Location:**
30+
- `Modules/src/api/endpoints/agents.py:35`
31+
- `Modules/src/api/endpoints/agents_v2.py:23`
32+
33+
**Fix:**
34+
- Remove or rename `agents_v2.py` if not needed
35+
- Or change prefix to `/api/agents/v2` if it's a versioned API
36+
37+
### 3. **Celery Worker Missing Queues**
38+
39+
**Problem:**
40+
Worker command only listens to: `default,data-processing,prediction,backtesting,portfolio`
41+
42+
But `task_routes` defines additional queues:
43+
- `ml_training`
44+
- `risk`
45+
- `strategies`
46+
- `analytics`
47+
- `generative`
48+
- `llm`
49+
50+
**Location:**
51+
- `Modules/docker-compose-core.yml:111`
52+
- `Modules/src/core/celery_app.py:49-60`
53+
54+
**Fix:**
55+
Update celery-worker command to include all queues:
56+
```yaml
57+
command: celery -A src.core.celery_app worker -l info -Q default,data-processing,market_data,ml_training,prediction,backtesting,portfolio,risk,strategies,analytics,generative,llm
58+
```
59+
60+
### 4. **Celery App Name Mismatch**
61+
62+
**Problem:**
63+
- Celery app name: `"quantum_trading_matrix"`
64+
- Platform name: `"Octopus Trading Platform"`
65+
66+
**Location:**
67+
- `Modules/src/core/celery_app.py:13`
68+
69+
**Fix:**
70+
Change to: `"octopus_trading_platform"` for consistency
71+
72+
### 5. **Multiple Market Data Routers**
73+
74+
**Problem:**
75+
Multiple market data routers with overlapping functionality:
76+
1. `market_data.router` (from routes) - prefix `/api/v1/market-data`
77+
2. `market_router` (professional_market_data) - prefix `/api/market-data`
78+
3. `market_data_workflow_router` - prefix `/api/market-data` (CONFLICTS!)
79+
4. `simple_data_router` - prefix `/api`
80+
81+
**Location:**
82+
- `Modules/src/main_refactored.py:136, 135, 159, 144`
83+
84+
**Fix:**
85+
Consolidate or clearly separate:
86+
- `/api/v1/market-data` - Legacy/v1 API
87+
- `/api/market-data` - Professional API
88+
- `/api/market-data/workflow` - Workflow API (rename)
89+
- `/api/real-market-data` - Simple real data (rename)
90+
91+
## ⚠️ Medium Priority Issues
92+
93+
### 6. **WebSocket Endpoints**
94+
95+
**Problem:**
96+
Multiple WebSocket implementations:
97+
- `websocket.router` - prefix `/api/v1/websocket`
98+
- `ws_realtime_router` - prefix `/api/ws`
99+
- Direct endpoint `/ws`
100+
101+
**Location:**
102+
- `Modules/src/main_refactored.py:139, 156, 162`
103+
104+
**Fix:**
105+
Consolidate or document which to use:
106+
- `/ws` - Main WebSocket endpoint
107+
- `/api/v1/websocket` - Legacy API
108+
- `/api/ws` - Real-time updates
109+
110+
### 7. **Missing Queue in Task Routes**
111+
112+
**Problem:**
113+
`market_data.*` tasks route to `data_processing` queue, but worker command uses `data-processing` (with hyphen)
114+
115+
**Location:**
116+
- `Modules/src/core/celery_app.py:51`
117+
- `Modules/docker-compose-core.yml:111`
118+
119+
**Fix:**
120+
Ensure consistency: Use `data_processing` (underscore) everywhere
121+
122+
## 📝 Recommended Fixes
123+
124+
### Priority 1 (Critical - Route Conflicts)
125+
1. Fix duplicate `/api/market-data` prefix
126+
2. Remove or rename `agents_v2.py`
127+
3. Update Celery worker queues
128+
129+
### Priority 2 (Consistency)
130+
4. Rename Celery app to match platform
131+
5. Consolidate market data routers
132+
6. Document WebSocket endpoints
133+
134+
### Priority 3 (Cleanup)
135+
7. Remove unused routers if any
136+
8. Standardize naming conventions
137+
9. Add route documentation
138+

0 commit comments

Comments
 (0)