Planning the first trading bot on DOM

Hi @Somtam,

First of all, yes you can receive DOM updates via API using a WebSocket and the md/subscribedom WebSocket operation. There are details for setting up your WebSocket here. You’ll want to connect your WebSocket to the market data URL: 'wss://md.tradovateapi.com/v1/websocket'. There are specific details about retrieving DOM data here. You can request fine grain tick data as well using the md/getchart operation, which is also retrieved through the Market Data WebSocket API.

I’m not sure if you’ll be able to differentiate between the order types however. Our DOM data is structured like this:

{
  "e":"md",
  "d": {
    "doms": [ // "doms" may contain multiple DOM objects
      {
        "contractId":123456, // ID of the DOM contract
        "timestamp":"2017-04-13T11:33:57.488Z",
        "bids": [ // Actual depth of "bids" may vary depending on available data
          {"price":2335.25,"size":33},
          ...
          {"price":2333,"size":758}
        ],
        "offers": [ // Actual depth of "offers" may vary depending on available data
          {"price":2335.5,"size":255},
          ...
          {"price":2337.75,"size":466}
        ]
      }
    ]
  }
}

For Backtesting, that same DOM data can be accessed historically (along with other data like user session data, or chart data) by using a Market Replay socket. The goal of the Market Replay socket is to replay a period of time chosen by the subscriber as if it were happening in real time (or up to 400% of real time). The trick to using the replay socket is to treat it as if it were both a Market Data socket and a real-time user data socket. I wrote a bit about the differences and how you could set up your sockets in this post.

For Execution, I’ve encountered people developing software using the API in a variety of languages, Python and NodeJS are both quite common. We have a pretty detailed JavaScript guide that hits all the major points of the API using browser based JS. You can convert most of that knowledge to the Node platform as well so long as you use the ws NPM package - its the same interface as the browser based WebSockets. There are Python based WebSocket implementations out there as well.