Open interest for multiple Instruments

sriraj1122
Hello,
I would like to retrieve Open interest for multiple instruments in one go. Currently if I have to retrieve Open Interest for 5 instruments.. I am calling historical data api 5 times to retrieve the Open Interest value for each instrument.
Is there a way I can get Open Interest for all the 5 instruments in one go?
Does any one have the code available for the same
  • sriraj1122
    @rakeshr Thank you. Rather than using Webscoket I am using below api because i need to get the OI only for one time.
    "https://api.kite.trade/quote?i=NSE:INFY"
    I have another question. Is there a way I can retrieve data for the Options which are already expired?
  • rakeshr
    Is there a way I can retrieve data for the Options which are already expired?
    No, we store continuous Historical data only for the FUTURES contract, not for OPTIONS.
  • sriraj1122
    @rakeshr I am facing an issue while use api "https://api.kite.trade/quote" for Option / future instruments over the holidays. Although OHLC prices are being retrieve Open Interest is not retrieve in the api.
    Kindly help in this regard.
  • rakeshr
    @sriraj1122
    Can you paste here the complete param you are requesting? Including contract name, etc
  • mlearner
    Does Historical Data API provide historical OI data for active option contracts?

    For ex: for NIFTY2110714000PE at 3:00 pm on a trading day, can I get OI data for say 12:00 pm, 12:30 pm and so on..?

    I think this is a very basic expectation to have from Historical Data API. Should have a support for this.

    I could only see live OI data in market quote API.
  • rakeshr
    Does Historical Data API provide historical OI data for active option contracts?
    Yes, Historical candles do provide OI value along with OHLCV data for the requested candle. You just need to send extra param of oi=1. Go through this documentation.
  • sriraj1122
    @rakeshr I am using python quote function to retrieve the OI. Here is the function I am using
    kite.quote([12762370]).
    This is working fine during the working day and I am able to retrieve OI. But when I execute the same on weekends it is giving full quote but OI is coming as zero.
  • rakeshr
    You are using Quote APIs not Historical data API. Quote APIs only gives current OHLCV and OI values, not historical. So, on non-trading hour's/day's/weekends, you get the previous last trading OHLCV and OI values.
  • sriraj1122
    Yes and I do understand that. That;s exactly my question is. When I am using quote APIs on non-trading days / weekends it is returning Zero OI. Ideally it should provide me with final OI on Friday. Correct? But it is not giving me the same.
  • sriraj1122
    @rakeshr Just for reference, I am using below code.

    from pprint import pprint
    from kiteconnect import KiteConnect

    kite = KiteConnect(api_key="xxxxxxx", access_token="xxxxxxx")
    instruments = ['12762370'] ### ==> this is for NIFTY21JANFUT
    quote = kite.quote(instruments)
    pprint(quote)

    I executed above script on weekend i.e. 1/9/2021
    *********************Here is the output****************
    {'12762370': {'average_price': 0,
    'buy_quantity': 0,
    'depth': {'buy': [{'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0}],
    'sell': [{'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0},
    {'orders': 0, 'price': 0, 'quantity': 0}]},
    'instrument_token': 12762370,
    'last_price': 14374.9,
    'last_quantity': 0,
    'last_trade_time': datetime.datetime(2021, 1, 8, 15, 29, 59),
    'lower_circuit_limit': 12933.85,
    'net_change': 0,
    'ohlc': {'close': 14191.1,
    'high': 14379.3,
    'low': 14249,
    'open': 14281},
    'oi': 0,
    'oi_day_high': 0,
    'oi_day_low': 0,
    'sell_quantity': 0,
    'timestamp': datetime.datetime(2021, 1, 8, 17, 39, 47),
    'upper_circuit_limit': 15808,
    'volume': 0}}
  • sriraj1122
    Please check the code I am using
  • sujith
    @siraj1122,
    This data is fetched from Kite Ticker. It just saves the last tick received from the exchange.
  • sriraj1122
    @sujith But OI for last tick received from exchange shouldn't be Zero...correct ?
  • sujith
    We don't do any processing on Kite Ticker, it just caches whatever exchange sends.
    The correct value will be there on the BHAV copy or day candle data of historical data API.
  • sriraj1122
    Hi, I wanted to fetch past OpenInterest & Volume for a past date and for multiple Instruments at once using Python API.

    How can I get that?
  • sujith
    You will have to use historical data API. However, we don't have a bulk fetch API for historical data. You will have to fetch in the loop and store it at your end.
Sign In or Register to comment.