Live Streaming / Market Data

Quotes

After setting up the streaming connection, you can now request quotes by sending a message named isins to the subscription channel.

The message is expected to contain a comma-separated list of up to 10 instruments you'd like to receive quotes for.

Let's visualize this using another example in JavaScript:

1const instruments = [
2  'US64110L1061', // Netflix
3  'US88160R1014', // Tesla
4]
5subscriptions.publish('isins', instruments.join(','), (err) => {
6  console.log('publish subscriptions error', err)
7})
8console.log("requested quotes", instruments)

Now you should be receiving quotes on your message channel. The message name will be quotes and the data looks like this:

1{
2  "isin": 'US88160R1014',
3  "mic": 'XMUN',
4  "t": 1655895027465,
5  "a": 6621000,
6  "a_v": 121,
7  "b": 6613000,
8  "b_v": 121
9}

That's the same structure as used in the /quotes/latest endpoint when using the query parameters &decimals=false&epoch=true.

Read more about the different date and price formats we provide ↗

Out-of-Order Message Delivery

When you subscribe to the live quotes, it is possible to receive a quote that is older than the one you received before:

  • {
      "isin": "US88160R1014",
      "mic":  "XMUN",
      "t":    1657807464350,
      "a":    6925000,
      "a_v":  208,
      "b":    6916000,
      "b_v":  208
    }
    
  • {
      "isin": "US88160R1014",
      "mic":  "XMUN",
      "t":    1657807464212,
      "a":    6925000,
      "a_v":  208,
      "b":    6917000,
      "b_v":  208
    }
    

Unfortunately, the lemon.markets platform receives the messages in that order. As we want to provide you with the lowest latency possible, we decided to forward the data as-is. Depending on your use-case, you might want to apply one of the following techniques to clean up the data before use:

  • Trading: In case of potentially triggering trades based on live quotes, we recommend you store the latest quotes you received and compare the timestamp of new messages with the timestamp of the quote stored. Only trigger a trade if and only if the timestamp of the incoming quote is newer than the one you used before.
  • Archiving: If you use the API to create your own historical data store we recommend to use a storage system that can insert new messages into the chronolocially correct position (e.g. a SQL database) or periodically reorder the data.