Pricing Services Price Store Setup 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 pair and pricing source in the PFE's Price Store.

The Price Store setup is a one-time process for each asset/asset pair/source. Once these processes are performed, multiple calls to retrieve latest prices and price histories for asset pairs are possible.

The entire setup process consists of several steps, described below:

1. Create the ‘base’ asset within the PE Price Store

The base asset is the asset to retrieve the latest price for, e.g. BTC for bitcoin.

POST {Apigee domain}/{PFE proxy}/v1/assets
{

  "assetClass": "Crypto",

  "assetName": "Bitcoin",

  "asset": "BTC"

}

Where assetClass and asset would typically be on of:

Crypto - BTC, ETH, XLM, etc

2. Create the ‘priced in’ asset with the PE Price Store

The priced in asset specifies the units that the base asset is express in, e.g. USD for US dollars. 

POST {Apigee domain}/{PFE proxy}/v1/assets
{

"assetClass": "Currency", 

  "assetName": "US Dollar",

  "asset": "USD"

}

Where assetClass and asset would typically be on of:



Currency - 
USD, EUR, GBP, etc

3. Validate the base asset/priced in asset pair

This is to determine which pricing sources can provide it – e.g. find pricing sources for BTC/USD, examples of which might be Gemini or Polygon.

GET {Apigee domain}/{PFE proxy}/v1/listeners/validate/BTC/USD

This validation also returns the available price update mechanisms (e.g. polling) and the price fields available (e.g. ask price, mid price). 

4.  Insert the asset pair into the the PE Price Store

This configures a PE listener function to receive prices from the pricing source (e.g. Gemini) to update the PE price store. This includes specifying the pricing source and the price update mechanism/frequency to capture prices – e.g. polling, every 10 seconds. 

POST {Apigee domain}/{PFE proxy}/v1/listeners/pairs/BTC/ETH
{

  "priceTypeConfigurations": [

    {

      "priceType": "ask",

      "providerConfigurations": [

        {

          "rateProvider": "Gemini",

          "isDefaultProviderForPriceType": true,

          "rateRefreshMethod": "Polling",

          "refreshRateInterval": 10

        }

      ]

    }

  ]

}

Note: Return codes from the API Endpoints listed above can be found in the API Primer.