125 lines
4.1 KiB
Markdown
125 lines
4.1 KiB
Markdown
# NT8 Institutional SDK Implementation Approach
|
|
|
|
## Component Breakdown
|
|
|
|
### 1. Strategy Framework
|
|
Located in `src/NT8.Core/Common/Interfaces/` and `src/NT8.Core/Common/Models/`:
|
|
|
|
- **IStrategy.cs** - Core strategy interface for trading algorithms
|
|
- **StrategyMetadata.cs** - Strategy metadata and configuration models
|
|
- **StrategyIntent.cs** - Strategy trading intent models and enums
|
|
- **StrategyContext.cs** - Strategy context information models
|
|
- **MarketData.cs** - Market data models and provider interface
|
|
|
|
### 2. Risk Management
|
|
Located in `src/NT8.Core/Risk/`:
|
|
|
|
- **IRiskManager.cs** - Risk management interface with validation methods
|
|
- **BasicRiskManager.cs** - Implementation with Tier 1 risk controls
|
|
|
|
Key features:
|
|
- Daily loss cap enforcement
|
|
- Per-trade risk limiting
|
|
- Position count limiting
|
|
- Emergency flatten functionality
|
|
- Thread-safe implementation with locks
|
|
- Risk level escalation (Low/Medium/High/Critical)
|
|
|
|
### 3. Position Sizing
|
|
Located in `src/NT8.Core/Sizing/`:
|
|
|
|
- **IPositionSizer.cs** - Position sizing interface
|
|
- **BasicPositionSizer.cs** - Implementation with fixed contracts and fixed dollar risk methods
|
|
|
|
Key features:
|
|
- Fixed contracts sizing method
|
|
- Fixed dollar risk sizing method
|
|
- Contract clamping (min/max limits)
|
|
- Multi-symbol support with accurate tick values
|
|
- Conservative rounding (floor) for contract quantities
|
|
|
|
## Development Workflow
|
|
|
|
### 1. Task Management
|
|
Following Archon workflow principles:
|
|
1. Check Current Task → Review task details and requirements
|
|
2. Research for Task → Search relevant documentation and examples
|
|
3. Implement the Task → Write code based on research
|
|
4. Update Task Status → Move task from "todo" → "doing" → "review"
|
|
5. Get Next Task → Check for next priority task
|
|
6. Repeat Cycle
|
|
|
|
### 2. Code Quality Standards
|
|
- All code follows .NET 6.0 standards
|
|
- Comprehensive unit testing with >90% coverage
|
|
- Proper error handling and logging
|
|
- Thread-safe implementations where required
|
|
- Deterministic behavior for reliable testing
|
|
|
|
### 3. Testing Strategy
|
|
Located in `tests/NT8.Core.Tests/`:
|
|
|
|
#### Risk Management Tests
|
|
- **BasicRiskManagerTests.cs** - Unit tests for all risk management functionality
|
|
- **RiskScenarioTests.cs** - Real-world scenario testing
|
|
|
|
#### Position Sizing Tests
|
|
- **BasicPositionSizerTests.cs** - Unit tests for position sizing functionality
|
|
|
|
Key test coverage:
|
|
- >90% code coverage for all components
|
|
- Edge case testing
|
|
- Multi-symbol validation
|
|
- Thread safety verification
|
|
- Risk escalation scenarios
|
|
- Configuration validation
|
|
|
|
## Risk Management Approach
|
|
|
|
### Tier 1 Controls (Implemented)
|
|
1. **Daily Loss Cap** - Trading automatically halts when daily losses exceed configured limit
|
|
2. **Per-Trade Risk Limit** - Individual trades are rejected if they exceed maximum risk
|
|
3. **Position Count Limiting** - Maximum number of concurrent positions enforced
|
|
4. **Emergency Flatten** - Immediate halt and flatten capability for crisis situations
|
|
|
|
### Risk Level Escalation
|
|
- **Low** - Normal trading conditions
|
|
- **Medium** - Elevated caution warranted
|
|
- **High** - Limited trading allowed
|
|
- **Critical** - Trading halted
|
|
|
|
## Position Sizing Methods
|
|
|
|
### Fixed Contracts
|
|
- Simple approach where a fixed number of contracts are traded
|
|
- Configurable with min/max clamping
|
|
- Suitable for consistent position sizing
|
|
|
|
### Fixed Dollar Risk
|
|
- Calculates contract count based on target dollar risk per trade
|
|
- Uses symbol-specific tick values for accurate calculations
|
|
- Conservative rounding (floor) to ensure risk limits are not exceeded
|
|
- Configurable with min/max clamping
|
|
|
|
## Next Steps (Phase 1)
|
|
|
|
### 1. Order Management System
|
|
- Implement OMS with smart order routing
|
|
- Add execution algorithm support
|
|
- Create order book analysis capabilities
|
|
|
|
### 2. NinjaTrader 8 Adapter
|
|
- Develop NT8 integration layer
|
|
- Implement market data handling
|
|
- Create order execution bridge
|
|
|
|
### 3. Enhanced Risk Controls
|
|
- Implement Tier 2 risk controls
|
|
- Add advanced correlation analysis
|
|
- Develop portfolio-level risk management
|
|
|
|
### 4. Advanced Position Sizing
|
|
- Implement Optimal f algorithm
|
|
- Add Kelly criterion sizing
|
|
- Create volatility-adjusted methods
|