188 lines
5.0 KiB
Markdown
188 lines
5.0 KiB
Markdown
# NT8 SDK Repository
|
|
|
|
## Project Status: ✅ Phase 0 Complete - Ready for Phase 1
|
|
|
|
This repository contains a sophisticated institutional trading SDK designed for NinjaTrader 8 integration. The SDK implements a risk-first architecture with advanced position sizing and deterministic behavior.
|
|
|
|
## 🚨 Important: .NET Framework 4.8 Compatibility
|
|
|
|
This project targets **NinjaTrader 8** and MUST maintain compatibility with:
|
|
- **.NET Framework 4.8** (NOT .NET Core/.NET 5+)
|
|
- **C# 5.0 language features only**
|
|
- **Traditional class syntax** (NO modern C# features)
|
|
|
|
## Quick Start
|
|
|
|
### Prerequisites
|
|
- .NET Framework 4.8
|
|
- Visual Studio 2019/2022 or VSCode
|
|
- NinjaTrader 8 (for integration)
|
|
|
|
### Build Verification
|
|
```bash
|
|
# Clone and verify build
|
|
git clone <repository-url>
|
|
cd nt8-sdk
|
|
.\verify-build.bat
|
|
```
|
|
|
|
Should output: `✅ All checks passed!`
|
|
|
|
## Architecture Overview
|
|
|
|
### Core Components
|
|
- **Risk Management**: Tier 1 controls (daily loss limits, per-trade limits, position limits)
|
|
- **Position Sizing**: Fixed contracts and fixed dollar risk methods
|
|
- **Strategy Framework**: Thin plugin architecture for trading strategies
|
|
- **Logging System**: Structured logging compatible with .NET Framework 4.8
|
|
|
|
### Design Principles
|
|
1. **Risk-First**: All trades pass through risk validation before execution
|
|
2. **Deterministic**: Identical inputs produce identical outputs
|
|
3. **Modular**: Strategies are plugins, SDK handles infrastructure
|
|
4. **Observable**: Comprehensive logging with correlation IDs
|
|
|
|
## Project Structure
|
|
|
|
```
|
|
nt8-sdk/
|
|
├── src/
|
|
│ ├── NT8.Core/ # Core trading framework
|
|
│ ├── NT8.Adapters/ # NinjaTrader 8 integration (Phase 1)
|
|
│ ├── NT8.Strategies/ # Example strategies (Phase 1)
|
|
│ └── NT8.Contracts/ # Data contracts (Phase 1)
|
|
├── tests/
|
|
│ ├── NT8.Core.Tests/ # Unit tests
|
|
│ ├── NT8.Integration.Tests/
|
|
│ └── NT8.Performance.Tests/
|
|
└── docs/ # Documentation
|
|
```
|
|
|
|
## Development Guidelines
|
|
|
|
### For AI Agents
|
|
**MUST READ** before making any changes:
|
|
- [`AI_DEVELOPMENT_GUIDELINES.md`](AI_DEVELOPMENT_GUIDELINES.md) - Compatibility requirements
|
|
- [`CODE_STYLE_GUIDE.md`](CODE_STYLE_GUIDE.md) - Required code patterns
|
|
- [`CODE_REVIEW_CHECKLIST.md`](CODE_REVIEW_CHECKLIST.md) - Pre-commit verification
|
|
|
|
### For Human Developers
|
|
1. Review the guidelines above
|
|
2. Run `.\verify-build.bat` before committing
|
|
3. Follow existing code patterns in the repository
|
|
4. Maintain .NET Framework 4.8 compatibility
|
|
|
|
## Phase Status
|
|
|
|
### ✅ Phase 0 (Complete)
|
|
- Repository structure and build system
|
|
- Core interfaces and models
|
|
- Basic risk management (Tier 1)
|
|
- Basic position sizing
|
|
- Test framework setup
|
|
|
|
### 🔄 Phase 1 (In Progress)
|
|
- NinjaTrader 8 integration adapters
|
|
- Market data provider implementation
|
|
- Order management system
|
|
- Enhanced risk controls (Tier 2)
|
|
|
|
### 📋 Future Phases
|
|
- Advanced risk controls (Phases 2-3)
|
|
- Confluence scoring system (Phase 4)
|
|
- Analytics and optimization (Phase 5)
|
|
- Production hardening (Phase 6)
|
|
|
|
## Key Features
|
|
|
|
### Risk Management
|
|
```csharp
|
|
// All trades go through risk validation
|
|
var riskDecision = riskManager.ValidateOrder(intent, context, config);
|
|
if (!riskDecision.Allow)
|
|
{
|
|
// Trade rejected - log reason and stop
|
|
return;
|
|
}
|
|
```
|
|
|
|
### Position Sizing
|
|
```csharp
|
|
// Intelligent position sizing with risk controls
|
|
var sizingResult = positionSizer.CalculateSize(intent, context, config);
|
|
var contracts = sizingResult.Contracts; // Final contract count
|
|
```
|
|
|
|
### Strategy Framework
|
|
```csharp
|
|
// Strategies are thin plugins - SDK handles everything else
|
|
public class MyStrategy : IStrategy
|
|
{
|
|
public StrategyIntent OnBar(BarData bar, StrategyContext context)
|
|
{
|
|
// Strategy logic here - return trading intent
|
|
return new StrategyIntent(/* parameters */);
|
|
}
|
|
}
|
|
```
|
|
|
|
## Testing
|
|
|
|
### Run All Tests
|
|
```bash
|
|
dotnet test --configuration Release
|
|
```
|
|
|
|
### Test Coverage
|
|
- Core components: >90% coverage
|
|
- Risk scenarios: Comprehensive test suite
|
|
- Integration tests: End-to-end validation
|
|
|
|
## Building
|
|
|
|
### Development Build
|
|
```bash
|
|
dotnet build --configuration Debug
|
|
```
|
|
|
|
### Release Build
|
|
```bash
|
|
dotnet build --configuration Release
|
|
```
|
|
|
|
### Full Verification
|
|
```bash
|
|
.\verify-build.bat
|
|
```
|
|
|
|
## Contributing
|
|
|
|
### Code Changes
|
|
1. Read development guidelines (see links above)
|
|
2. Follow existing patterns
|
|
3. Add unit tests
|
|
4. Run verification script
|
|
5. Submit for review
|
|
|
|
### Architecture Changes
|
|
All architecture changes must:
|
|
- Maintain risk-first design
|
|
- Preserve deterministic behavior
|
|
- Support NinjaTrader 8 compatibility
|
|
- Include comprehensive tests
|
|
|
|
## License
|
|
|
|
[Specify your license here]
|
|
|
|
## Support
|
|
|
|
For technical issues:
|
|
1. Check build verification: `.\verify-build.bat`
|
|
2. Review development guidelines
|
|
3. Examine existing code patterns
|
|
4. Create issue with full error details
|
|
|
|
---
|
|
|
|
**Remember**: This SDK prioritizes institutional-grade risk management and NinjaTrader 8 compatibility above all else. All development must maintain these core principles. |