Pyth is an innovative market data distribution protocol that aims to decentralize market data distribution and thereby make it accessible to the masses.

Market data is the price and other data that trading venues like stock exchanges publish for financial instruments such as equities, fixed-income products, derivatives, and currencies. It’s how traders and investors know the latest price and can track trends over time. For example, when you open CNBC.com or Robinhood, you will see a price for a stock. That price is derived from market data. If you want to learn more about market, check out this article.

Example of Apples stock price from the Robinhood App

Example of Apples stock price from the Robinhood App

Market data is provided by vendors such as Bloomberg, Refinitiv (formerly Thomson Reuters), MorningStar or published directly by exchanges like Nasdaq and NYSE. There are numerous costs associated with providing and consuming market data access that is typically outside the reach of individual investors…until now!

Market Data for All

Pyth is an innovative solution that aims to bring market data to the masses using blockchain technology. The network does this by incentivizing market participants – in the form of crypto currency – to share price data collected as part of their normal operations. The Pyth network then aggregates this data and makes it available to end users.

When I first heard about Pyth at the FIA Conference, the first thought that crossed my mind was what prevents someone from publishing a bad price so they can skew the market in their favor. Thankfully the Pyth protocol has a series safeguards to prevent market manipulation by bad actors.

Pyth Tokens

Pyth tokens are the financial incentive that is part of the protocol in order to drive behavior that contribute to efficient and fair market data distribution. The stakeholders of the Pyth network will be given Pyth tokens accordingly:

  • Publishers: Publishers are awarded tokens based on the volume of data they share and also on how accurate the prices of the data they share is. Publishers have to stake tokens in order to participate in the network. This stake is reduced if they publish inaccurate information.
  • Consumers: Consumers read price feeds and pay data fees in order to get accurate data. Consumers can submit a claim – entirely on chain – if they believe they received inaccurate market data.
  • Delegators: Delegators stake tokens onto publishers and earn a share of data fees and also lose their stake if the price produced is deemed to be inaccurate during a claims process.

Consuming Pyth Data

Pyth has a number of APIs that you can use to contribute to and consume from the Pyth network.

For the sake of this post, let’s consider the Node API. Here is a snippet of sample code that you can use to subscribe to the Pyth Network:

pythConnection.onPriceChange((product, price) => {
  // sample output:
  // SRM/USD: $8.68725 ±$0.0131
  if (price.price && price.confidence) {
    // tslint:disable-next-line:no-console
    console.log(`${product.symbol}: ${price.price} \xB1${price.confidence}`)
  } else {
    // tslint:disable-next-line:no-console
    console.log(`${product.symbol}: price currently unavailable. status is 
${PriceStatus[price.status]}`)
  }
})

Running this code will very quickly overwhelm your JavaScript console with the following bits of information:

...
Crypto.SLND/USD: 1.9875 ±0.0028
Equity.US.AMC/USD: 19.959999999999997 ±0.18642999999999998
Crypto.FTT/USD: 47.962 ±0.012
Crypto.C98/USD: 1.59415 ±0.00105
Crypto.AVAX/USD: 86.395 ±0.022000000000000002
Crypto.BTC/USD: 43890.793 ±21.202
FX.USD/CNH: 6.380699999999999 ±0.0003
Crypto.UST/USD: 1.00205 ±0.00025100000000000003
...

Now imagine if you were just interested in the price of Bitcoin, or just wanted the price of Bitcoin denominated in your local currency. You’d have to sift through all the data you receive and pull out the information you are interested in. In addition, what if your company had traders sitting in multiple locations? They would also need to use the API to consume the market data and sift through it to find the price they were interested in. This can get prohibitively expensive in terms of both network and infrastructure costs.

Pyth network diagram

The ideal scenario would be that you consume from the Pyth network once and publish it to all interested parties on a demand basis using a highly robust, logical network of event brokers known as an event mesh.

Accessing Real-Time Market Data in the Cloud with SolaceDelve into the business case for cloud-delivered market data; how an event mesh can help deploy that real-time data; and how to start the journey towards making it a reality for your organization.Download PaperSolly logo

The Importance of an Event Mesh

An event mesh is a configurable and dynamic infrastructure layer for distributing events among decoupled applications, cloud services and devices. An event mesh is a network of interconnected event brokers that enables event communications to be governed, flexible, reliable and fast.

Remember that consuming data from the Pyth network in effect costs you, so consuming the Pyth feed for every user can get prohibitively expensive both from an infrastructure perspective and a network perspective. This is where the event mesh would enable you to consume from the Pyth network just once and then publish it in such a way that other users could consume it on demand from locations around the world.

Pyth network and an event mesh diagram

The benefits of doing this are as follows:

  • You only incur the consumption fees from the Pyth network once
  • The event mesh can be deployed globally and thereby route data from the Pyth network globally
  • Users will only see the data they are interested in and not the entire Pyth network feed. This is accomplished via topic routing which takes data and adds a topic address to it. For example, all BTC prices will be on the topic ‘Crypto/BTC/USD’ and whenever anyone is interested in BTC prices, they would simply express a subscription via Crypto/BTC/USD and they will receive it.

Feedhandler Implementation

In the diagram above, you may have noticed a ‘feed handler’ that takes data from the Pyth network and publishes it to a Solace PubSub+ event broker. I’ve created a sample implementation of the feed handler that does exactly that which you can find in this repo.

Conclusion

Pyth is a fascinating initiative that is backed by many key industry players. If successful, it will certainly make market data distribution more accessible to the masses. Its implementation is well suited to work with an event mesh which offers significant advantages such as filtering feeds and global distribution to name a few.

For more about how Solace PubSub+ Platform makes it easy to efficiently route real-time market data between trusted data sources and other front- and back-office systems, visit this page.

If you’re interested in learning about the challenges with cloud-delivered market data and whether cloud native services can meet standard service requirements for market data distribution, I encourage you to read this paper: Accessing Real-Time Market Data in the Cloud with Solace

Thomas Kunnumpurath

Thomas Kunnumpurath is the Vice President of Systems Engineering for Americas at Solace where he leads a field team across the Americas to solution the Solace PubSub+ Platform across a wide variety of industry verticals such as Finance, Retail, IoT and Manufacturing.

Prior to joining Solace, Thomas spent over a decade of his career leading engineering teams responsible for building out large scale globally distributed systems for real time trading systems and credit card systems at various banks.

Thomas enjoys coding, blogging about tech, speaking at conferences and being invited to talk on PodCasts. You can follow him at Twitter with the handle @TKTheTechie, GitHub @TKTheTechie and his blog on TKTheTechie.io