Skip to navigation

Start Order Strategy

View as Markdown

Start a multi-bracket trading strategy.

This endpoint is used with a WebSocket. You can create any number of brackets and add them to brackets field on the params object as a JSON string.

const URL = 'wss://demo.tradovateapi.com/v1/websocket'
const params = {
entryVersion: {
orderQty: 1,
orderType: "Market"
},
brackets: [{
qty: 1,
profitTarget: -30,
stopLoss: 15,
trailingStop: false
}]
}
const body = {
accountId: myAcctId,
accountSpec: name,
symbol: 'MESM1',
action: 'Sell',
orderStrategyTypeId: 2, //2 is 'multibracket', we currently only offer this strategy but more may exist in the future.
params: JSON.stringify(params)
}
const mySocket = new WebSocket(URL)
//authorize socket using your access token
mySocket.onopen = function() {
mySocket.send(`authorize\n0\n\n${accessToken}`)
}
mySocket.send(`orderstrategy/startorderstrategy\n4\n\n${JSON.stringify(body)}`)

For more details about working with advanced order types, see placeOrder, placeOCO, and placeOSO.

Authentication

AuthorizationBearer

Bearer authentication of the form Bearer <token>, where token is your auth token.

Request

This endpoint expects an object.
symbolstringRequired<=64 characters
orderStrategyTypeIdlongRequired
actionenumRequired
Buy, Sell
Allowed values:
accountIdlongOptional
accountSpecstringOptional<=64 characters
paramsstringOptional<=8192 characters
uuidstringOptional<=64 characters
customTag50stringOptional<=64 characters

Operator ID for the order. Send it only if NinjaTrader configured an allow-list of operator IDs for your user. In that case it’s required on every order and must exactly match one approved value. If no allow-list is configured, omit it: a supplied value is denied. Organizations using passthrough also omit it, and NinjaTrader fills it in. Up to 64 characters. See Operator ID (customTag50) and Passthrough.

isAutomatedbooleanOptional

Response

OrderStrategyStatusResponse
errorTextstringOptional<=8192 characters

Non-empty if the request failed

failureReasonenumOptional
AccountClosed, AdvancedTrailingStopUnsupported, AnotherCommandPending, BackMonthProhibited, ExecutionProviderNotConfigured, ExecutionProviderUnavailable, HomeStateRestricted, InvalidContract, InvalidPrice, KeyInformationDocumentRequired, LiquidationOnly, LiquidationOnlyBeforeExpiration, MaxOrderQtyIsNotSpecified, MaxOrderQtyLimitReached, MaxPosLimitMisconfigured, MaxPosLimitReached, MaxTotalPosLimitReached, MinTradeDurationNotElapsed, MultipleAccountPlanRequired, NoQuote, NotEnoughLiquidity, OtherExecutionRelated, ParentRejected, RiskCheckTimeout, SSFNFAComplianceRequired, SSFNFAComplianceRequiredJointOnly, SSFRiskDisclosureAcknowledgmentRequired, SessionClosed, Success, TooLate, TradingLocked, TrailingStopNonOrderQtyModify, Unauthorized, UnknownReason, Unsupported
orderStrategyobjectOptional