Pricing Services Price Discovery Tutorial

Pricing Services is supported by the Price Feed Engine (PFE) platform, which provides price data from multiple sources to applications in a normalized format.  

Pricing data from external pricing sources, such as an exchange, can be retrieved in near real-time or as snapshots with different intervals, such as hourly, daily. 

The PFE maintains its own internal time-series database known as the Price Store. Before discovering prices for an asset pair, or retrieving a price history, it is first necessary to set up the assets, asset pairs and pricing source in the PFE's Price Store. This is a one-time process and is explained in the Pricing Services Price Store Setup Tutorial.

Once this Price Store setup has been accomplished, it is then possible to make use of price discovery API Endpoints, including:

- Discovering the latest price for an asset pair

- Retrieving the price history of an asset pair.

1. Discover Latest Price - for an asset pair - the API Endpoint is:

POST {Apigee Domain}/{PFE Proxy}/v1/price-store/get-latest-price/{baseAsset}/{pricedInAsset}

Where:

{baseAsset} is the asset to retrieve the latest price for, e.g. BTC for bitcoin.

{pricedInAsset} specifies the units that the base asset is express in, e.g. USD for US dollars

For example, if {baseAsset} is BTC for bitcoin, and {pricedInAsset} is USD for US dollars, the  API Endpoint would be:

POST {Apigee Domain}/{PFE Proxy}/v1/price-store/get-latest-price/BTC/USD

This API Endpoint would then return price data with the following fields and format:

[

  {

    "priceType": "Bid",

    "provider": "Polygon",

    "price": 13.12,

    "effectiveFrom": "2022-06-23T11:26:00.000Z"

  },

  {

    "priceType": "Ask",

    "provider": "Polygon",

    "price": 13.42,

    "effectiveFrom": "2022-06-23T11:26:00.000Z"

  }

]

2. Retrive Price History for an Asset Pair - the API Endpoint is:

POST {Apigee Domain}/{PFE Proxy}/v1/price-store/get-price-history/{baseAsset}/{pricedInAsset}

This API Endpoint would then return price data with the following fields and format:

[

    {

      "provider": "Polygon",

      "priceType": "Bid",

      "prices": [

        {

          "price": 13.12,

          "effectiveFrom": "2022-06-21T11:26:00.000Z",

        },

        {

          "price": 13.14,

          "effectiveFrom": "2022-06-22T11:26:00.000Z",

        },

        {

          "price": 13.17,

          "effectiveFrom": "2022-06-23T11:26:00.000Z",

        }

      ]

    },

    {

      "provider": "Polygon",

      "priceType": "Ask",

      "prices": [

        {

          "price": 13.42,

          "effectiveFrom": "2022-06-21T11:26:00.000Z",

        },

        {

          "price": 13.54,

          "effectiveFrom": "2022-06-22T11:26:00.000Z",

        },

        {

          "price": 13.67,

          "effectiveFrom": "2022-06-23T11:26:00.000Z",

        }

      ]

    }

  ]