pocketful logo light
pocketful logo light

Compact Marketdata

Compact MarketData typically refers to a condensed or summarized version of market data for financial instruments. It provides essential information such as the current price, bid-ask spread, trading volume, and possibly a few other key metrics. This condensed format is often used in situations where real-time updates are needed, but only a limited set of essential data points are required, such as in mobile trading apps or quick market overviews.

To get the compact marketdata, the first step is to subscribe the instrument for which the data is required.

Subscribe instruments to get market data

You can subscribe or unsubscribe single or multiple instruments to get market data.

To subscribe only one instrument.

marketdata_payload= {'exchangeCode': 1, 'instrumentToken': 'token'}
response = pocket_ws.subscribe_compact_marketdata(marketdata_payload)

To subscribe multiple instrument.

multiple_marketdata_payload = {}
response = pocket_ws.subscribe_multiple_compact_marketdata(marketdata_payload)

Example

marketdata_payload= {'exchangeCode': 2, 'instrumentToken': '41990'}
response = pocket_ws.subscribe_compact_marketdata(marketdata_payload)

Read Marketdata

compact_market_data = pocket_ws.read_compact_marketdata()
print(compact_market_data)
compact_market_data = pocket_ws.read_multiple_compact_marketdata()
print(compact_market_data)

compact Marketdata Response

{
  "mode": 2,
  "exchange_code": 1,
  "instrument_token": 1333,
  "last_traded_price": 145065,
  "change": 4294966816,
  "last_traded_time": 1710491906,
  "lowDPR": 130990,
  "highDPR": 160095,
  "currentOpenInterest": 0,
  "initialOpenInterest": 0,
  "bidPrice": 145060,
  "askPrice": 145070
}

Response Parameter

Field NameDescription
modeMode of operation
exchange_codeCode representing the exchange
instrument_tokenUnique token representing the financial instrument
last_traded_pricePrice at which the last trade occurred
changeChange in price since the last trade
last_traded_timeTimestamp of the last trade
lowDPRDaily low price range
highDPRDaily high price range
currentOpenInterestCurrent open interest
initialOpenInterestInitial open interest
bidPriceBid price in the current order book
askPriceAsk price in the current order book

Unsubscribe the instrument to stop receiving the data.

response = pocket_ws.unsubscribe_compact_marketdata(marketdata_payload)
response = pocket_ws.unsubscribe_multiple_compact_marketdata(marketdata_payload)