# NT8 SDK Installation Instructions

## Overview

This guide documents manual and scripted deployment of the NT8 SDK into NinjaTrader 8.

## Prerequisites

1. Windows machine with NinjaTrader 8 installed.
2. NinjaTrader 8 has been launched at least one time so the Custom folder exists.
3. .NET SDK available for building release binaries.
4. Repository checked out locally.

## Expected Paths

- Project root: `c:\dev\nt8-sdk`
- Deployment script: `c:\dev\nt8-sdk\deployment\deploy-to-nt8.bat`
- NinjaTrader custom folder: `%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom`

## Build Release Artifacts

Run this from repository root:

```bat
cd c:\dev\nt8-sdk && dotnet build NT8-SDK.sln --configuration Release
```

Expected outputs:

- `src\NT8.Core\bin\Release\net48\NT8.Core.dll`
- `src\NT8.Adapters\bin\Release\net48\NT8.Adapters.dll`

## Deploy Using Script (Recommended)

Run:

```bat
cd c:\dev\nt8-sdk\deployment && deploy-to-nt8.bat
```

What the script does:

1. Validates NinjaTrader custom folder exists.
2. Validates release binaries exist.
3. Creates backup folder under `deployment\backups\<timestamp>`.
4. Backs up existing deployed SDK files.
5. Copies DLLs into NinjaTrader Custom folder.
6. Copies wrapper strategy source files into `Custom\Strategies`.
7. Verifies expected deployed files exist after copy.
8. Writes `manifest.txt` into the backup folder with source/destination details.

## Verify Deployment in NinjaTrader 8

1. Open NinjaTrader 8.
2. Open NinjaScript Editor.
3. Press `F5` to compile.
4. Confirm no compile errors.
5. Open Strategies window and verify wrappers are listed:
   - `BaseNT8StrategyWrapper`
   - `SimpleORBNT8Wrapper`

## Rollback Procedure

If deployment must be reverted:

1. Locate the latest backup in `deployment\backups`.
2. Review `manifest.txt` in that backup folder to confirm file set and paths.
2. Copy files back into:
    - `%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom`
    - `%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom\Strategies`
3. Recompile in NinjaTrader (`F5`).

## Troubleshooting

### "NinjaTrader Custom folder not found"

- Launch NinjaTrader once.
- Confirm `%USERPROFILE%\Documents\NinjaTrader 8\bin\Custom` exists.

### "Core DLL not found" or "Adapters DLL not found"

- Re-run release build:

```bat
cd c:\dev\nt8-sdk && dotnet build NT8-SDK.sln --configuration Release
```

### NinjaScript compile errors after deploy

- Confirm target framework remains .NET Framework 4.8.
- Confirm C# 5.0-compatible syntax in wrappers.
- Restore from backup and redeploy after fixes.

## Operational Notes

- Deploy only when NinjaTrader strategy execution is stopped.
- Keep timestamped backups for audit and rollback.
- Keep `manifest.txt` with each backup for deployment traceability.
- Re-run deployment after every release build update.
