Streaming Market Data (Quotes)
We are pleased to announce that US equity options, CME futures and CME futures options market data is available for streaming once again.
  1. Get an Api Quote Token
  2. DXLink Streamer
  3. DXLink Symbology
  4. DXLink Documentation
  5. Candle Events (Historic Data)

The process to subscribe to streaming market events has two parts.

  1. Get an API quote token.
  2. Using the api quote token, clients may fetch market events from DXLink (see DXLink Streamer section below).

Important: Api quote tokens expire after 24 hours

Get an Api Quote Token

The GET /api-quote-tokens endpoint will return an api quote token and its associated urls.

This token is unique to the Customer identified by the session token on the request. It's used to identify the customer to TW's quote provider, DXLink.

Response
GET
/api-quote-tokens
{
    "data": {
        "token": "<redacted>",
        "dxlink-url": "wss://tasty-openapi-ws.dxfeed.com/realtime",
        "level": "api"
    },
    "context": "/api-quote-tokens"
}

Quote streamer tokens are valid for 24 hours.

DXLink Streamer

DXLink data is sent and received via a websocket connection. Use the dxlink-url provided to you in the /api-quote-tokens response to open a websocket.

You then send a SETUP message to initiate a connection to DXLink.

Then you use your token to send an AUTH message.

Once authenticated, you may open a feed channel. These are virtual connections that you may use to subscribe to different data. For example, you may want one channel for equities and another for futures.

All of these steps are very well documented on DXLink's protocol documentation site. That same site also lets you use your api quote token to test out the DxLink protocol.

DXLink provides several different market events, each of which has its own schema. For example, the Quote event provides data like bidPrice and askPrice while the Profile event provides data like high52WeekPrice and description. DXLink requires that you specify which market events you wish to subscribe to when you are adding a symbol subscription.

tastytrade's api quote token grants you access to Profile, Quote, Summary, and Trade market events as well as Greeks for options.

Symbology

To receive live market event data via DXLink, clients must convert symbols into a format that meets DxLink's requirements. For convenience, we provide these symbols via a field called streamer-symbol. You can find it in the http response body when fetching instrument data. For example, for subscribing to market events for a futures contract, you would hit the GET /instruments/futures endpoint:

Response
GET
/instruments/futures
{
    "data": {
        "items": [
            {
                "symbol": "/6AM3",
                "streamer-exchange-code": "XCME",
                "streamer-symbol": "/6AM23:XCME"
            }
        ]
    }
}

An identical field is available for the following instruments endpoints:

  • GET /instruments/cryptocurrencies
  • GET /instruments/equities/:symbol
  • GET /instruments/futures
  • GET /futures-option-chains/:product-code
  • GET /option-chains/:underlying-symbol
Content Not Found

Candle Events (Historic Data)

DxLink allows you to subscribe to different event types. One of these event types is Candle. A candle event represents quote data for a duration of time like 5 minutes, 1 hour, or 1 day. Each event has fields like open, close, high, and low.

When you subscribe to candle events for a specific symbol, you need to provide a period and a type. The type represents the unit of time with which each candle is measured, like minutes or hours. The period is a multiplier for the type, like five minutes or two hours.

You need both period and type to be present in the symbol when subscribing to candle events.

Please refer to DxFeed's guidelines for more information on how to generate a candle symbol correctly.

The final piece you need in order to subscribe to candle events is a fromTime timestamp. This is an integer in Unix epoch time format. For example, the timestamp representing August 8th, 2023 at 10:00am GMT is 1691402400. If today were August 9th, 2023 at 10:00am GMT and you used 1691402400 as the fromTime, you'd receive 24 hours of candle events.

Here are a few examples:

  1. Suppose you wanted AAPL quote data from the past 24 hours and you wanted it grouped into 5-minute intervals. The fromTime would be now - 24 hours in epoch format. The symbol would look like AAPL{=5m} where 5 is the period and m is the type (minutes). Each candle event you receive will represent 5 minutes of data. The open field represents the price of AAPL at the start of the 5-minute candle duration and close represents the price of AAPL at the end of the 5-minute candle duration. high is the highest price that AAPL hit during those 5 minutes, and low is the lowest price that AAPL hit during those 5 minutes.

  2. Suppose you wanted SPY quote data for the past 6 months grouped into 1-hour intervals. The symbol would look like SPY{=1h} and the fromTime would just be now - 6 months in epoch format.

Important We recommend using larger time intervals the further back you go. If you request too many candles you could get blasted with millions of events and bring your client to a crawl. For example, requesting 12 months of data grouped into 1-minute intervals would amount to around half a million events. That is a lot of data to process all at once.

Here is a rough guideline on what type and period to use based on how far back you reach:

Time BackRecommended TypeExampleNotes
1 day1 MinuteAAPL{=1m}Returns around 1440 candle events
1 week5 MinutesAAPL{=5m}Returns around 2016 candle events
1 month30 MinutesAAPL{=30m}Returns around 1440 candle events
3 months1 hourAAPL{=1h}Returns around 2160 candle events
6 months2 hoursAAPL{=2h}Returns around 2160 candle events
1 year+1 dayAAPL{=1d}Returns around 365 candle events

The last candle event you receive is always the "live" candle data. You may receive this event constantly as the quote changes and the candle data is updated for the current period. Specifically, the close value will update as the quote's price changes. For example, say you subscribed to AAPL{=5m} and it is currently 12:51. The "live" candle event should have a timestamp of 12:50. You should constantly receive messages for this event as the quote moves. Once the clock hits 12:55, the 12:50 event will close and the "live" event will be 12:55. This allows you to fetch whatever historica data you want and also be notified of the most recent quote statistics as they change.