Hi,
Is it possible to send the attached order using API?
Appreciate if you could provide the sample code for the order. Thank you!
Hi,
Is it possible to send the attached order using API?
Appreciate if you could provide the sample code for the order. Thank you!
@Alexander I wonder if you might be able to help with this. Appreciate it. Thank you!
Hi @fin1,
Check out this section of the documentation.
You can add as many brackets objects as you like, so for each of your targets you’d have a separate object. If you want them to be SL or TP only, include only one of the stopLoss
or profitTarget
fields instead of both.
Hope that helps!
Hi @Alexander ,
Thanks for the response. To follow up, I’m getting 404/undocumented response on the call to startorderstrategy API call, with the below endpoint and request payload.
Could you please help? I was able to recreate this from your API portal site as well (Tradovate API)
Endpoint:
https://demo.tradovateapi.com/v1/orderStrategy/startorderstrategy
Headers:
Authorization: Bearer ***
Content-Type: application/json
{
“accountId”: ,
“accountSpec”: "",
“symbol”: “MESZ1”,
“orderStrategyTypeId”: 1,
“action”: “Buy”,
“params”: “{ “entryVersion”: { “orderQty”: 3, “orderType”: “Stop”, “stopPrice”: 4533.00, }, “brackets”: [{ “qty”: 1, “profitTarget”: 1, “stopLoss”: 0.25 }, { “qty”: 3, “stopLoss”: 0.75 } ]}”,
“uuid”: “82dee86c-353a-11ec-8d3d-0242ac130003”,
“customTag50”: “strat01”
}
Response received: 404 (undocumented)
Appreciate your help and guidance with this. Thank you!
Hi @fin1,
Currently, there is only one valid value for orderStrategyTypeId
, and that value is 2
. Try changing that parameter first and see if that fixes it.
Hi @Alexander ,
I tried it. It shows return code 404, and there’s no description or error message returned by the API. Is there a way check logs ? Thanks!
I see you have accountSpec and accountId blank, is that because you’re omitting the values or are you sending empty strings?
@Alexander We send them. Omitted them here for obvious reasons.
@Alexander Appreciate any insights into how we could resolve this. Thanks as always!
I always use a websocket to complete this request. I can confirm this endpoint works just fine when using a websocket, and there are other great benefits to using a websocket as well (real time user data updates for one thing). Try this using a websocket and I believe you will have success.
Look at the new API FAQ repo’s user sync sample, it has working code you can use to hook up a websocket fast and send your own messages. The project is setup for a browser, so if you’re using just Node you’ll need to add the ws
package - same interface as the browser WebSocket class, just for Node.
Note: there is now a start-an-order-strategy section.