feat: implement Latency Control with criticality-based prioritization (Pillar 1) #27
Reference in New Issue
Block a user
Delete Branch "feature/issue-21-latency-control"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Implements Pillar 1: 속도와 시의성의 최적화
Urgency-based response system that reacts faster in critical market situations, with prioritized task execution based on real-time market conditions.
Components
1. CriticalityAssessor (src/core/criticality.py)
Evaluates market conditions to determine response urgency:
Criticality Levels & Timeouts:
Auto-elevation to CRITICAL when:
Key Methods:
Coverage: 100%
2. PriorityTaskQueue (src/core/priority_queue.py)
Thread-safe priority queue with timeout enforcement:
Features:
Key Methods:
Coverage: 96%
3. Integration with main.py
Criticality Assessment (start of trading_cycle):
Latency Monitoring (end of trading_cycle):
Queue Metrics: Periodic reporting of statistics
4. Volatility Hunter Integration
Tests (tests/test_latency_control.py)
30 comprehensive tests covering:
CriticalityAssessor (11 tests):
PriorityTaskQueue (15 tests):
Integration (4 tests):
Coverage: 98% (criticality: 100%, queue: 96%)
All 157 tests passing
Performance Specifications
✅ CRITICAL timeout: <5s
✅ HIGH timeout: <30s
✅ NORMAL timeout: <60s
✅ LOW: no timeout (batch)
✅ Queue is thread-safe
✅ Graceful degradation
✅ P&L threshold: -2.5%
✅ Price change: 5% in 1min
✅ Volume surge: 10x
Integration Points
Uses existing infrastructure:
Usage Example
Related
Closes #21
Part of The 4 Pillars: Pillar 1 (Latency Control)
Depends on: #20 (Volatility Hunter)
Synergy with: #15 (Context Tree), #19 (Evolution)