Just when I thought I had bracket orders working through the API this popped up this morning. Below is a sample order I’m sending through but I keep getting an error on the STOP bracket. The trade submits but the STOP order is rejected with a message of ‘Invalid price’
{
“accountSpec”: “XXX”,
“accountId”: XXX,
“action”: “Buy”,
“symbol”: “MESM5”,
“orderQty”: 1,
“orderType”: “Limit”,
“timeInForce”: “GTC”,
“price”: 6097.75,
“bracket1”: {
“action”: “Sell”,
“orderType”: “Limit”,
“price”: 6112.75
},
“bracket2”: {
“action”: “Sell”,
“orderType”: “Stop”,
“stopPrice”: 6087.75
},
“isAutomated”: true
}
This seemed to work fine last week so I’m not sure if something has changed.
invalid price usually occurs when the current price is below the stop price(in case of a sell stop)
I ran into something similar but by now I’d think you’d have it solved. Mine had to do with the script calling the ATM strategy where the box trades were too close due to the market swiftness and called it invalid and left just the single short to be open for SEVEN hours…lol. So, what I did was adjust the ATM closing strategy to first place them wide, then move them in as the market moves but wait there’s more, because the NT8 would report no trade active due to the error, it would just continue as if there was nothing wrong so I built in a timer feature for both longs and shorts. I think I landed on 800 seconds for longs and 180 seconds for shorts which flattened all trades after an initial trade was made. Hope that helps. NT should fix the status of an ATM trade when something goes wrong with it so the script can pick up on it.