Files
nt8-sdk/docs/architecture/phase1_sprint_plan.md
mo 9a28a49292
Some checks failed
Build and Test / build (push) Has been cancelled
Pre-cleanup baseline snapshot
2026-04-05 16:50:18 -04:00

352 lines
13 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# NT8-SDK — Sprint Board
**Last Updated:** 2026-03-27 | **Active Sprint:** Sprint 2
---
## Sprint 2 — SIM Validation (ACTIVE)
**Goal:** Strategy runs unattended 2+ weeks in SIM with correct dual-leg execution.
**Gate:** Zero unhandled exceptions, both scaler and runner filling (Qty=2 in log), daily loss limit never accidentally triggered.
| # | Task | Status | Notes |
|---|---|---|---|
| S2-01 | Restore `EntriesPerDirection=2` | ✅ Done | Deployed 2026-03-27 |
| S2-02 | `MaxOpenPositions=2` in SimpleORBNT8 | ✅ Done | Deployed 2026-03-27 |
| S2-03 | `_realtimeBarSeen` replay guard | ✅ Done | Blocks live replay burst, allows backtest |
| S2-04 | `State.Historical` guard in ProcessStrategyIntent | ✅ Done | Restores backtest execution |
| S2-05 | Validate runner leg — Qty=2 in session log | ⬜ Pending | Run backtest after S2-01 |
| S2-06 | Risk parameter consistency validation | ⬜ Pending | Assert RiskPerTrade ≤ MaxTradeRisk |
| S2-07 | SIM unattended run 2+ weeks | ▶ In progress | Started 2026-03-27 |
| S2-08 | Walk-forward backtest split | ⬜ Pending | MarSep 2025 train / OctMar 2026 test |
| S2-09 | BX68915-15 prop firm re-enable | 🔴 Blocked | Gate: S2-05 + S2-07 pass |
---
## Sprint 3 — Production Hardening
**Goal:** 30-day SIM run clean. CI and alerts live.
| # | Task | Status | Notes |
|---|---|---|---|
| S3-01 | Gitea CI — build + test on push | ⬜ Pending | `.gitea/workflows/build.yml` |
| S3-02 | n8n webhook — fills + risk events | ⬜ Pending | HTTP POST from NT8StrategyBase |
| S3-03 | Fix `GetRiskStatus()` hardcoded limit | ⬜ Pending | Read from registered strategy config |
| S3-04 | `orbRangeTicks` wiring in DailyBarContext | ⬜ Pending | Low priority |
| S3-05 | Short-side regime filter | ⬜ Pending | 20-day MA or VIX-based gate |
| S3-06 | Tick replay validation | ⬜ Pending | 30-day window |
| S3-07 | VWAPMeanReversion strategy skeleton | ⬜ Pending | New IStrategy implementation |
---
## Sprint 4 — Live Capital
**Gate:** 30-day SIM pass rate > 70%, PF > 2.0, max drawdown < $500
| # | Task | Status |
|---|---|---|
| S4-01 | Go live 1 NQ contract | ⬜ Pending gate |
| S4-02 | OvernightGapContinuation strategy | ⬜ Pending |
| S4-03 | OvernightGapReversion strategy | ⬜ Pending |
| S4-04 | Ops runbook and emergency procedures | ⬜ Pending |
| S4-05 | Connection loss recovery testing | ⬜ Pending |
| S4-06 | CME holiday filter | ⬜ Pending |
---
## Sprint 5 — ML Inference
**Prerequisite:** 60 days of live trading data.
| # | Task |
|---|---|
| S5-01 | FastAPI /predict endpoint on Ollama workstation |
| S5-02 | HTTP client in SimpleORBStrategy |
| S5-03 | MLSignalFactorCalculator as IFactorCalculator |
| S5-04 | Feature engineering from live trade history |
| S5-05 | A/B test: with vs without ML factor |
---
## Completed (Historical)
| Task | Sprint | Completed |
|---|---|---|
| Execute trades in NT8 SIM (execution bridge wired) | Sprint 1 | 2026-03-27 |
| Historical replay burst fix | Sprint 1 | 2026-03-27 |
| NR7 warm-up guard | Phase 4 | 2026-02 |
| 10-factor confluence scoring engine | Phase 4 | 2026-02 |
| PortfolioRiskManager singleton | Phase 4 | 2026-02 |
| Analytics layer (240+ tests) | Phase 5 | 2026-02-16 |
| Breakeven + runner trail logic | Sprint 1 | 2026-03 |
| Connection loss detection | Sprint 1 | 2026-03 |
| File logging + settings export | Sprint 1 | 2026-03 |
---
## Backtest Results History
| Date | Period | Trades | Win% | PF | Net | Config |
|---|---|---|---|---|---|---|
| 2026-03-27 | JanMar 2026 | 20 | 75% | 7.00 | $1,200 | trail=20, grade=B ✅ Use this |
| 2026-03-27 | JanMar 2026 | 40 | 75% | 3.69 | $1,075 | trail=12, grade=B |
| 2026-03-27 | Mar 2025Mar 2026 | 148 | 51% | 3.15 | $71,303 | 9 cts experimental |
**Note:** The 148-trade run used `RiskPerTrade=$500` producing 9 contracts AND had `EntriesPerDirection=1` blocking the runner. Not a production reference. Re-run required post Sprint 2.
---
# ARCHIVED BELOW — Phase 1 Sprint Plan (2025-09-15, superseded)
## Overview (ARCHIVED)
This document originally outlined Phase 1 sprint planning from September 2025.
## Sprint Goals
1. Implement Order Management System (OMS) with smart order routing
2. Develop NinjaTrader 8 adapter for integration
3. Enhance risk controls with Tier 2 functionality
4. Implement market data handling and validation
5. Optimize performance and add advanced position sizing algorithms
## Sprint Timeline
- **Duration**: 3 weeks
- **Start Date**: 2025-09-15
- **End Date**: 2025-10-06
- **Review Date**: 2025-10-07
## Team Composition
- 1 Architect
- 2 Senior Developers
- 1 QA Engineer
- 1 DevOps Engineer
## Sprint Backlog
### Epic 1: Order Management System (OMS)
**Objective**: Implement a comprehensive OMS with smart order routing and execution algorithms.
#### User Stories:
1. **As a developer, I want to create an OMS interface that supports multiple order types**
- Priority: High
- Story Points: 5
- Tasks:
- Define IOrderManager interface
- Implement OrderManager class with basic functionality
- Add support for Market, Limit, StopMarket, and StopLimit orders
- Implement order validation logic
2. **As a trader, I want the OMS to support smart order routing**
- Priority: High
- Story Points: 8
- Tasks:
- Implement routing logic based on liquidity and cost
- Add support for multiple execution venues
- Create routing configuration system
- Add routing performance metrics
3. **As a developer, I want to implement execution algorithms**
- Priority: Medium
- Story Points: 8
- Tasks:
- Implement TWAP (Time Weighted Average Price) algorithm
- Implement VWAP (Volume Weighted Average Price) algorithm
- Implement Iceberg order algorithm
- Add algorithm configuration and parameterization
4. **As a risk manager, I want the OMS to enforce order limits and controls**
- Priority: High
- Story Points: 5
- Tasks:
- Integrate with existing risk management system
- Add order rate limiting
- Implement order value limits
- Add circuit breaker functionality
### Epic 2: NinjaTrader 8 Adapter
**Objective**: Develop a robust adapter for integrating with NinjaTrader 8 platform.
#### User Stories:
1. **As a developer, I want to create an adapter interface for NT8 integration**
- Priority: High
- Story Points: 5
- Tasks:
- Define INT8Adapter interface
- Implement NT8Adapter class with basic connectivity
- Add connection state management
- Implement error handling and recovery
2. **As a trader, I want to receive real-time market data from NT8**
- Priority: High
- Story Points: 8
- Tasks:
- Implement market data subscription mechanism
- Add support for different bar types and intervals
- Implement data quality checks and validation
- Add buffering and throttling for high-frequency data
3. **As a trader, I want to execute orders through NT8**
- Priority: High
- Story Points: 8
- Tasks:
- Implement order submission to NT8
- Add order status tracking and updates
- Implement order cancellation and modification
- Add execution reporting and fill handling
4. **As a developer, I want to handle NT8-specific data formats and conventions**
- Priority: Medium
- Story Points: 5
- Tasks:
- Implement data type conversions
- Add support for NT8 instrument definitions
- Handle NT8 session and trading hours
- Implement NT8-specific error codes and handling
### Epic 3: Enhanced Risk Controls (Tier 2)
**Objective**: Extend the risk management system with advanced Tier 2 controls.
#### User Stories:
1. **As a risk manager, I want to implement portfolio-level risk controls**
- Priority: High
- Story Points: 8
- Tasks:
- Add cross-symbol correlation analysis
- Implement portfolio VaR (Value at Risk) calculations
- Add concentration limits by sector/asset class
- Implement portfolio-level stop-losses
2. **As a risk manager, I want advanced position tracking and management**
- Priority: High
- Story Points: 5
- Tasks:
- Enhance position tracking with Greeks and risk metrics
- Add position reconciliation mechanisms
- Implement position flattening algorithms
- Add position reporting and visualization
3. **As a compliance officer, I want transaction cost analysis**
- Priority: Medium
- Story Points: 5
- Tasks:
- Implement slippage tracking and analysis
- Add commission and fee tracking
- Create transaction cost reporting
- Add cost vs. benefit analysis tools
4. **As a risk manager, I want scenario analysis and stress testing**
- Priority: Medium
- Story Points: 8
- Tasks:
- Implement historical scenario analysis
- Add Monte Carlo simulation capabilities
- Create stress testing framework
- Add scenario result visualization
### Epic 4: Market Data Handling
**Objective**: Implement comprehensive market data handling and validation.
#### User Stories:
1. **As a developer, I want to create a market data provider interface**
- Priority: High
- Story Points: 5
- Tasks:
- Define IMarketDataProvider interface
- Implement MarketDataProvider base class
- Add support for multiple data sources
- Implement data source failover mechanisms
2. **As a trader, I want to validate market data quality**
- Priority: High
- Story Points: 8
- Tasks:
- Implement data quality checks (gaps, spikes, etc.)
- Add data freshness monitoring
- Create data validation rules engine
- Add alerts for data quality issues
3. **As a developer, I want to implement historical data handling**
- Priority: Medium
- Story Points: 5
- Tasks:
- Add support for historical data retrieval
- Implement data storage and caching
- Add data compression and archiving
- Create historical data analysis tools
4. **As a trader, I want real-time market data analytics**
- Priority: Medium
- Story Points: 8
- Tasks:
- Implement real-time volatility calculations
- Add volume and liquidity analytics
- Create market regime detection
- Add real-time data visualization
### Epic 5: Performance Optimization
**Objective**: Optimize system performance and add advanced algorithms.
#### User Stories:
1. **As a developer, I want to optimize core system performance**
- Priority: High
- Story Points: 8
- Tasks:
- Profile and optimize critical code paths
- Implement object pooling for frequently used objects
- Add caching mechanisms for expensive calculations
- Optimize memory usage and garbage collection
2. **As a developer, I want to implement advanced position sizing algorithms**
- Priority: Medium
- Story Points: 8
- Tasks:
- Implement Optimal f algorithm
- Add Kelly criterion sizing
- Create volatility-adjusted sizing methods
- Add machine learning-based sizing approaches
3. **As a system administrator, I want comprehensive monitoring and logging**
- Priority: High
- Story Points: 5
- Tasks:
- Implement performance counters and metrics
- Add distributed tracing support
- Enhance logging with structured data
- Create monitoring dashboard
4. **As a developer, I want to implement parallel processing where appropriate**
- Priority: Medium
- Story Points: 5
- Tasks:
- Identify opportunities for parallelization
- Implement thread-safe data structures
- Add async/await patterns where beneficial
- Optimize resource utilization
## Success Criteria
1. OMS implemented with smart order routing and execution algorithms
2. NT8 adapter successfully integrated and tested
3. Tier 2 risk controls operational with portfolio-level management
4. Market data handling robust with quality validation
5. System performance optimized with measurable improvements
6. All new functionality covered by automated tests (>90% coverage)
7. Documentation updated for all new components
## Risks and Mitigations
1. **Risk**: Complexity of NT8 integration
- **Mitigation**: Start with basic connectivity and incrementally add features
2. **Risk**: Performance bottlenecks in OMS
- **Mitigation**: Continuous profiling and optimization throughout development
3. **Risk**: Data quality issues affecting risk calculations
- **Mitigation**: Implement comprehensive data validation and quality monitoring
## Dependencies
1. Completion of Phase 0 (already completed)
2. Access to NT8 development environment
3. Market data feeds for testing
4. Risk management team for validation of new controls
## Definition of Done
- Code implemented and reviewed
- Unit tests written and passing (>90% coverage)
- Integration tests completed
- Documentation updated
- Performance benchmarks met
- Security review completed
- Deployment package created