pocketful logo light
pocketful logo light

Detailed Marketdata

Detailed MarketData offers real-time access to comprehensive and detailed information about financial instruments. It provides users with a continuous stream of up-to-date data, including market depth, bid-ask spreads, trading volumes, and price movements. This function is invaluable for traders and investors seeking in-depth insights into market dynamics, enabling them to make informed decisions based on the most current and detailed market data available.

To get the detailed marketdata, the first step is to subscribe the instrument for which we need the data.

Below is the list of exchange codes which will be required while subscribing to a particular instrument.

exchange_code = {
    "NSE" : 1,
    "NFO" : 2,
    "CDS" : 3,
    "MCX" : 4,
    "BSE" : 6,
    "BFO" : 7
}

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': 'code', 'instrumentToken': 'token'}
response = pocket_ws.subscribe_detailed_marketdata(marketdata_payload)

To subscribe multiple instrument.

multiple_marketdata_payload = [{'exchangeCode': 'code', 'instrumentToken': 'token'},{'exchangeCode': 'code', 'instrumentToken': 'token'}.....]
response = pocket_ws.subscribe_multiple_detailed_marketdata(marketdata_payload)

Example

marketdata_payload= {'exchangeCode': 1, 'instrumentToken': 1333}
response = pocket_ws.subscribe_detailed_marketdata(marketdata_payload)

Read Marketdata

detailed_market_data = pocket_ws.read_detailed_marketdata()
print(detailed_market_data)
detailed_market_data = pocket_ws.read_multiple_detailed_marketdata()
print(detailed_market_data)

Detailed Marketdata Response

{
  "mode": 1,
  "exchange_code": 1,
  "instrument_token": 1333,
  "last_traded_price": 144895,
  "last_traded_time": 1710489044,
  "last_traded_quantity": 1,
  "trade_volume": 8014246,
  "best_bid_price": 144890,
  "best_bid_quantity": 25,
  "best_ask_price": 144895,
  "best_ask_quantity": 628,
  "total_buy_quantity": 624983,
  "total_sell_quantity": 899665,
  "average_trade_price": 145018,
  "exchange_timestamp": 1710489044,
  "open_price": 145000,
  "high_price": 145930,
  "low_price": 144415,
  "close_price": 145545,
  "yearly_high_price": 175750,
  "yearly_low_price": 136355,
  "lowDPR": 130990,
  "highDPR": 160095,
  "currentOpenInterest": 0,
  "initialOpenInterest": 0
}

Response Parameter

Field NameDescription
modeMode indicator for the instrument.
exchange_codeExchange code for the instrument.
instrument_tokenToken identifying the instrument.
last_traded_priceLast traded price of the instrument.
last_traded_timeTime of the last trade for the instrument.
last_traded_quantityQuantity traded in the last transaction.
trade_volumeTotal volume traded for the instrument.
best_bid_priceBest bid price in the market.
best_bid_quantityQuantity available at the best bid price.
best_ask_priceBest ask price in the market.
best_ask_quantityQuantity available at the best ask price.
total_buy_quantityTotal quantity of buy orders.
total_sell_quantityTotal quantity of sell orders.
average_trade_priceAverage traded price over a period.
exchange_timestampTimestamp of the data from the exchange.
open_priceOpening price of the instrument for the session.
high_priceHighest price of the instrument for the session.
low_priceLowest price of the instrument for the session.
close_priceClosing price of the instrument for the session.
yearly_high_priceHighest price of the instrument in the year.
yearly_low_priceLowest price of the instrument in the year.
lowDPRLow circuit price range for the instrument.
highDPRHigh circuit price range for the instrument.
currentOpenInterestCurrent open interest in the instrument.
initialOpenInterestInitial open interest in the instrument.

Unsubscribe the instrument to stop receiving the data.

response = pocket_ws.unsubscribe_detailed_marketdata(marketdata_payload)
response = pocket_ws.unsubscribe_multiple_detailed_marketdata(marketdata_payload)