I have been able to place simple market orders via https://demo.tradovateapi.com/v1/order/placeorder no problem, but when it comes to creating a multibracket strategy, I get {‘errorText’: ‘Invalid or missed parameters’}. I have been following the API documentation, plus other examples throughout this forum, but I am struggling. I am not sure if this is because I am using python, but hopefully someone can spot my error below. In the end I am looking to take profit at 15pts, stop loss at 35, breakeven trigger at 10 pts, then breakeven offset at 3 pts.
Again, I am using python to send a HTTPS post request to https://demo.tradovateapi.com/v1/orderStrategy/startOrderStrategy via the requests library, and I cannot spot where the error would be. Any help would be appreciated:
def placeLongOS(live, token):
header = {
'Authorization': f'Bearer ${token}',
'accept': 'application/json'
}
if live:
url = "https://live.tradovateapi.com/v1/orderStrategy/startOrderStrategy"
else:
url = "https://demo.tradovateapi.com/v1/orderStrategy/startOrderStrategy"
params = {
"entryVersion": {
"orderId": 0,
"orderQty": 1,
"orderType": "Market",
"timeInForce": "Day"
},
"brackets": [{
"qty": 1,
"profitTarget": 5,
"stopLoss": -10,
"trailingStop": "false"
}]
}
order = {"accountId": 0000000,
"symbol":"MNQH3",
"action":"Buy",
"orderStrategyTypeId": 2,
"params": params
}
res = requests.post(url, headers=header, data=order)
if res.status_code != 200:
print("Order Failed")
print(res.status_code)
print(res.reason)
print(res.text)
if res.status_code == 200:
content = res.json()
print(content)
token = getAccessToken(False)[0]
placeLongOS(False, token)