Skip to main content

POST Adopt Strategy

Adopt a manually-attached strategy NT8

Adopts a NinjaScript strategy that was attached by hand in NT8's Strategies tab (or by any tool other than CrossTrade) into CrossTrade's deployment registry. Adoption captures the running strategy's configuration: class, account, instrument, bars period, and its declared writable inputs, exactly as they are at adopt time.

After adoption the strategy behaves like one started through StartStrategy: DisableStrategy followed by EnableStrategy round trips work (enable recreates the strategy from the adopted record, since NT8 removes account-hosted strategies on disable), and deployment state queries track it. No restart or redeploy of the running strategy is needed, which makes this the migration path for moving an existing manual setup under CrossTrade management incrementally.

Adopt while the strategy is running, before disabling it. A disabled account-hosted strategy has already been removed by NT8 and has nothing left to adopt.

Endpoint

POST /v1/api/accounts/{account}/strategies/{strategyId}/adopt

Headers

NameValue
Content-Typeapplication/json
AuthorizationBearer <token>

Path parameters

NameTypeRequiredDescription
accountstringRequiredName of the NT8 account that owns the strategy.
strategyIdstringRequiredID of the running strategy as returned by ListStrategies or ListAllStrategies.

Code examples

import requests

token = 'my-secret-token'

url = "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/370780512/adopt"
headers = {
"Authorization": f"Bearer {token}",
"Content-Type": "application/json"
}

try:
response = requests.post(url, headers=headers, json={})
print(f"Response Code: {response.status_code}, Response Text: {response.text}")
except Exception as e:
print(f"An error occurred: {e}")

Response

{
"success": true,
"adopted": true,
"deploymentId": "dep_4f1a8c02d7e3",
"strategyId": "370780512",
"account": "Sim101",
"strategyClass": "SampleMACrossOver",
"instrument": "MES 09-26",
"periodType": "Minute",
"period": 1,
"hostMode": "account",
"parameters": { "Fast": 10, "Slow": 25 },
"detail": "Deployment record created from the live instance. DisableStrategy → EnableStrategy round trips now work for this strategy (enable recreates it from this record), and GetDeployedStrategyState tracks it. Inputs were captured as of now; re-adopt after changing them in NT8's UI."
}

Platform nuances

Available in CrossTrade Add-On v1.13.8+.

Adoption is idempotent: adopting an id that is already tracked (whether it was started through CrossTrade or adopted earlier) never creates a duplicate record. If the strategy is still running, the existing record is refreshed from the live instance and the response carries already_adopted: true with refreshed: true; if it is no longer running, the stored snapshot is kept and refreshed is false.

Inputs are captured as a snapshot. If you change the strategy's parameters in NT8's UI while it is still running, adopt it again to refresh the record. Once the strategy has been disabled there is no live instance left to capture from, so whatever the record holds is what enable recreates.

Chart-attached strategies are rejected with not_account_hosted: they pause and resume in place, so they never need a deployment record.

WebSocket API

This request can also be made over the WebSocket API. The account and strategyId path parameters are passed inside args.

{
"action": "rpc",
"id": "my-request-id",
"api": "AdoptStrategy",
"args": {
"account": "Sim101",
"strategyId": "370780512"
}
}