tools: add DASH-001 TOOL-001 TOOL-002 TOOL-003 and RUNNER-001 utilities
This commit is contained in:
114
tools/preflight/README.md
Normal file
114
tools/preflight/README.md
Normal file
@@ -0,0 +1,114 @@
|
||||
# preflight
|
||||
|
||||
`preflight.ps1` is a standalone PowerShell script for morning go/no-go checks before enabling the strategy. It does not import or reference any NinjaTrader assembly.
|
||||
|
||||
PowerShell was chosen because this tool is an operator-side environment check: process count, file writability, deployed-source hash verification, and disk-space checks are all native PowerShell tasks and do not need any .NET solution changes.
|
||||
|
||||
## What It Checks
|
||||
|
||||
The script prints `PASS` or `FAIL` for:
|
||||
|
||||
1. Exactly one `NinjaTrader` process running
|
||||
2. Log directory writable and no current-day `session_YYYYMMDD_*.log` already present
|
||||
3. Most recent `settings_Simple_ORB_NT8_*.txt` export has:
|
||||
- `TestMode=False`
|
||||
- `EnableKillSwitch=True`
|
||||
- `EnableVerboseLogging=True`
|
||||
- `EnableFileLogging=True`
|
||||
- `MinTradeGrade=5`
|
||||
- `MaxDailyTrades=1`
|
||||
4. Most recent settings export `Account` and `Instrument` match the expected arguments
|
||||
5. Deployed `NT8StrategyBase.cs` hash matches the repo copy
|
||||
6. Free disk space in the log directory drive is greater than `1 GB`
|
||||
|
||||
Every failure prints a specific remedy. The script exits `0` only when every check passes. Any failure returns exit code `1`.
|
||||
|
||||
## Usage
|
||||
|
||||
Run with the expected account and instrument:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
|
||||
-ExpectAccount "SimSimple ORB" `
|
||||
-ExpectInstrument "NQ SEP26"
|
||||
```
|
||||
|
||||
Override the log directory if needed:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
|
||||
-ExpectAccount "SimSimple ORB" `
|
||||
-ExpectInstrument "NQ SEP26" `
|
||||
-LogDirectory "C:\Users\billy\Documents\NinjaTrader 8\log\nt8-sdk"
|
||||
```
|
||||
|
||||
Override the repo/deployed file paths for validation or alternate installs:
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
|
||||
-ExpectAccount "SimSimple ORB" `
|
||||
-ExpectInstrument "NQ SEP26" `
|
||||
-RepoStrategyBasePath "C:\dev\nt8-sdk\src\NT8.Adapters\Strategies\NT8StrategyBase.cs" `
|
||||
-DeployedStrategyBasePath "C:\Users\billy\Documents\NinjaTrader 8\bin\Custom\Strategies\NT8StrategyBase.cs"
|
||||
```
|
||||
|
||||
## Defaults
|
||||
|
||||
- `LogDirectory`: `%USERPROFILE%\Documents\NinjaTrader 8\log\nt8-sdk`
|
||||
- `RepoStrategyBasePath`: `src\NT8.Adapters\Strategies\NT8StrategyBase.cs` relative to the repo root
|
||||
- `DeployedStrategyBasePath`: `%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom\Strategies\NT8StrategyBase.cs`
|
||||
|
||||
## Notes
|
||||
|
||||
- The script is read-only except for a temporary write/delete probe file in the log directory used to verify writability.
|
||||
- The settings check uses the most recently modified `settings_Simple_ORB_NT8_*.txt` file in the log directory.
|
||||
- The hash check compares SHA-256 of the repo and deployed `NT8StrategyBase.cs` files.
|
||||
|
||||
## Gate 3 Freeze Mode
|
||||
|
||||
Freeze mode captures Gate Run #3 provenance under `docs/gate-runs/gate3/freeze_YYYYMMDD_HHMMSS` and writes `docs/gate-runs/gate3/baseline.json` plus `DEC-GATE3-CONFIG.md` when all freeze gates pass.
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
|
||||
-ExpectAccount "SimSimple ORB" `
|
||||
-ExpectInstrument "NQ SEP26" `
|
||||
--freeze
|
||||
```
|
||||
|
||||
PowerShell also accepts `-Freeze`.
|
||||
|
||||
Freeze captures:
|
||||
|
||||
- current settings export
|
||||
- `ConfigHash` and `CodeVersion`
|
||||
- git commit SHA
|
||||
- `git status --porcelain`, which must be clean
|
||||
- full test suite result from `dotnet test NT8-SDK.sln --configuration Release --verbosity minimal`
|
||||
- SHA-256 hash of every deployed `.cs` file in the NT8 `Strategies` folder
|
||||
- `tools/configdiff` report for the preceding 3 settings exports
|
||||
|
||||
If the worktree is dirty, freeze exits non-zero and writes a failed capture folder with `git-status-porcelain.txt` and `FREEZE_FAILED.txt`. It does not create or replace `baseline.json`.
|
||||
|
||||
## Gate 3 Verify Mode
|
||||
|
||||
Verify mode repeats the capture and compares significant fields against `docs/gate-runs/gate3/baseline.json`. It exits non-zero on any difference.
|
||||
|
||||
```powershell
|
||||
powershell -ExecutionPolicy Bypass -File .\tools\preflight\preflight.ps1 `
|
||||
-ExpectAccount "SimSimple ORB" `
|
||||
-ExpectInstrument "NQ SEP26" `
|
||||
--verify
|
||||
```
|
||||
|
||||
PowerShell also accepts `-Verify`.
|
||||
|
||||
Verify compares:
|
||||
|
||||
- settings values
|
||||
- `ConfigHash`
|
||||
- `CodeVersion`
|
||||
- git SHA
|
||||
- clean git status
|
||||
- full-suite pass/fail status
|
||||
- configdiff pass/fail status
|
||||
- deployed strategy source hashes
|
||||
Reference in New Issue
Block a user