Hi Tradovate Support Team is there any diagram related on how the api/sockets works? I’d like to create a program that gives me latest 100 minute data from NQ and create a simple bracket order in MNQ?
100 minute data(latest 100 quotes 1 minute)
What would be the flow? What are the api paths I need to consider… Thanks
You’ll want to use a Market Data socket to get the chart data. You can read about using WebSockets with the API here.
We currently are having an issue with our
orderStrategy family of endpoints - this is due to a known problem related to what should be visible to public API users (and
orderStrategy belongs to a category that is not publicly visible). This means you can’t start a bracket strategy using the standard
What you can do, however, is use the
/order/placeOCO endpoints. OSO let’s you define your entry, while the
bracket2 fields will allow you to define your TP/SL brackets.
The whole app flow would go something like this:
- acquire an Access Token using your API credentials and the
/auth/accessTokenRequest endpoint documented here.
- create a new WebSocket. Connect on the market data URL -
- use the
WebSocket.send function to send the
md/getChart request to our servers.
- add a listener to your socket using either the
WebSocket.addEventListener function or the
WebSocket.onmessage handle. This function should process the incoming data and decide if the program should buy, sell, wait.
- a condition is met that tells the program that it’s time to act - you have 2 options:
- Send the order via WebSocket protocol
- Send the order via HTTP protocol
Either option is fine, but the protocol varies slightly.
For WebSockets, you’ll connect the socket then use the
WebSocket.send function and endpoints with no leading slash eg.
order/placeOSO. Parameters for WebSockets are separated by
\n (newline) characters.
For HTTPS, you’ll use something like
axios or just basic
fetch to make the request to the full endpoint eg.
https://live.tradovateapi.com/v1/order/placeOSO. The parameters for the HTTPS endpoints are sent either via the query string or the request body, stringified.
Thanks @Alexander this is pure gold !! Is there any implementation using Python?