POST Adopt Strategy
- NT8
- Tradovate
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
| Name | Value |
|---|---|
| Content-Type | application/json |
| Authorization | Bearer <token> |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
account | string | Required | Name of the NT8 account that owns the strategy. |
strategyId | string | Required | ID of the running strategy as returned by ListStrategies or ListAllStrategies. |
Code examples
- Python
- JavaScript
- cURL
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}")
const token = 'my-secret-token';
const url = "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/370780512/adopt";
fetch(url, {
method: "POST",
headers: {
"Authorization": `Bearer ${token}`,
"Content-Type": "application/json"
},
body: JSON.stringify({})
})
.then(res => res.json())
.then(data => console.log(data))
.catch(err => console.error(err));
TOKEN="my-secret-token"
curl -X POST "https://dev.crosstrade.io/v1/api/accounts/Sim101/strategies/370780512/adopt" \
-H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{}'
Response
- 200
- 200 - already adopted
- 400 - not found
- 400 - chart-attached
{
"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."
}
{
"success": true,
"already_adopted": true,
"refreshed": true,
"deploymentId": "dep_4f1a8c02d7e3",
"strategyId": "370780512",
"account": "Sim101",
"strategyClass": "SampleMACrossOver",
"instrument": "MES 09-26",
"periodType": "Minute",
"period": 1,
"hostMode": "account",
"parameters": { "Fast": 12, "Slow": 30 },
"detail": "Existing deployment record refreshed from the live instance. DisableStrategy → EnableStrategy round trips 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."
}
{
"success": false,
"error": "strategy_not_found",
"detail": "No live strategy with id '370780512' on account 'Sim101'. Adoption needs a RUNNING strategy to capture its configuration from — a strategy that was already disabled has been removed by NT8 and has nothing left to adopt. Use ListStrategies to discover live ids."
}
{
"success": false,
"error": "not_account_hosted",
"detail": "Strategy id '370780512' is chart-attached. Chart strategies pause and resume in place via DisableStrategy/EnableStrategy and do not need a deployment record; adoption only applies to account-hosted (Control Panel) strategies."
}
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"
}
}
Tradovate
NinjaScript strategies are a NinjaTrader desktop concept, so there is no /v1/api/tv equivalent for adopting a strategy. See the Tradovate API overview for what the Tradovate surface covers.