Shared infrastructure for independently deployed NinjaTrader 8 strategies.
The project contains the platform-neutral session/risk policy and the shared NinjaTrader lifecycle adapter. Concrete trading strategies are added separately.
NinjaFrame.Core— .NET Framework 4.8 policy and execution-position ledger library with no NinjaTrader dependency.NinjaFrame.Core.Tests— xUnit tests for session limits, cycle accounting, completion, and faults.NinjaTrader/Strategies/NinjaFrame/NinjaFrameStrategy.cs— shared NinjaTrader lifecycle, gating, accounting, and fault adapter.docs/architecture.md— agreed architecture and deferred scope.docs/ninjatrader-validation.md— generic base compile, provider, and consumer compatibility validation.docs/open-source-release.md— publication and disclosure-audit requirements.docs/publication-audit.md— recorded public-release audit and validation evidence.
- NinjaTrader 8.1.7.2 compatibility.
- .NET Framework 4.8 targeting pack.
- A C# 13-capable .NET SDK/compiler.
From the repository root:
dotnet build NinjaFrame.sln
dotnet test NinjaFrame.sln
The repository is the canonical source. Run:
.\scripts\deploy.ps1The script:
- Builds
NinjaFrame.Core. - When NinjaTrader is closed, copies the core DLL and symbols into
Documents\NinjaTrader 8\bin\Custom. - When NinjaTrader is running, continues only if the deployed core DLL is already identical; this allows NinjaScript-only changes to be deployed without a restart.
- Deploys only
Strategies\NinjaFrame\NinjaFrameStrategy.cs; concrete repositories own separate child directories and are never swept recursively. - Idempotently registers the DLL in NinjaTrader's persisted
Config.xmlreference list and adds the base reference/source entries toNinjaTrader.Custom.csproj. NinjaTrader must be closed when the persisted reference needs to change. - Builds
NinjaTrader.Custom.csprojin Release/x64 mode.
Changes under NinjaTrader/ can therefore be deployed while NinjaTrader is running after the Core reference has been registered. Changes under NinjaFrame.Core/, and the first deployment that registers the Core reference, require NinjaTrader to be closed. Use -NinjaTraderCustomPath to override the default custom directory; automatic in-app reference registration requires a corresponding Config.xml two directories above that custom path.
Concrete strategies are versioned and deployed from independent repositories. Deploy this base first. The public-release audit and validation evidence are recorded in docs/publication-audit.md.
StrategySession.RecordRealizedPnl accepts commission-inclusive realized deltas from partial exits.
StrategySession.RecordCompletedCycle accepts the complete cycle's net result for winner/loser classification plus only the final realized delta that has not already been recorded. Passing previously recorded P&L again would double count session P&L.
A fault is terminal for the current StrategySession. A configured session boundary resets normal completion and statistics but does not clear a fault.
ExecutionPositionLedger reconstructs signed strategy quantity from unique execution IDs and signed fill deltas. NinjaTrader order updates supply stable order metadata, executions supply fill quantity, and provider position callbacks remain advisory.
NinjaFrame source in this repository is licensed under the MIT License. NinjaTrader and third-party dependencies are not included and remain subject to their respective terms.