Inconsistency in Open Interest Data

Hi,

I downloaded the Historical Data for Analysis .

I see that the OI becomes 0 and then again comes back to a Non Negative number. Why does OI become 0 when there are contracts open.

posting Example Data:

2025-05-19T11:52:00+05:30,218.75,218.75,218.75,218.75,200,88600
2025-05-19T11:51:00+05:30,217.4,217.4,217.4,217.4,0,0
2025-05-19T11:50:00+05:30,215.45,217.4,215.45,217.4,600,89200
2025-05-19T11:49:00+05:30,216.0,216.0,215.45,215.45,400,89200
2025-05-19T11:48:00+05:30,215.0,215.0,215.0,215.0,0,0
2025-05-19T11:47:00+05:30,215.0,215.0,215.0,215.0,200,89000
2025-05-19T11:46:00+05:30,227.15,227.15,227.15,227.15,0,0
2025-05-19T11:45:00+05:30,227.15,227.15,227.15,227.15,0,0
2025-05-19T11:44:00+05:30,227.15,227.15,227.15,227.15,0,0
2025-05-19T11:43:00+05:30,227.15,227.15,227.15,227.15,200,89000
2025-05-19T11:42:00+05:30,232.0,232.0,232.0,232.0,200,89400
2025-05-19T11:41:00+05:30,222.0,229.25,222.0,229.25,600,89400
2025-05-19T11:40:00+05:30,213.8,213.8,213.8,213.8,200,89400

Could you please explain how the OI data is catured.

@Babu_Dilip_47574717 Could you please share the instrument_key for which you’re observing zero Open Interest (OI)? Additionally, let us know which API you’re using. It would be helpful if you could provide the complete request details for further analysis.

@Anand_Sajankar I am downloading for stock options . Example posted here is for Angel One 3000 CE for May Expiry. I see the same issue for many stock options where OI becomes 0 and then changes back to >0 number . Looks like OI becomes 0 whenever volume becomes 0 .

i am using Historical Data API V3 to download the data

def downloadHistoricalData(instrument_key,toDate, fromDate):
“”"
Download historical data for the given instrument key.
“”"
# URL encode the instrument key
encoded_instrument_key = quote(instrument_key)
url = f’https://api.upstox.com/v3/historical-candle/{encoded_instrument_key}/minutes/1/{toDate}/{fromDate}/
headers = {
‘Accept’: ‘application/json’
}

response = requests.get(url, headers=headers)

if response.status_code == 200:
    data = response.json()
    # Assuming the candles data is in data['data']['candles']
    candles = data.get('data', {}).get('candles', [])
    if candles:
        df = pd.DataFrame(candles, columns=['time', 'open', 'high', 'low', 'close', 'volume', 'oi'])
        return df
    else:
        print(url)
        return pd.DataFrame(columns=['time', 'open', 'high', 'low', 'close', 'volume', 'oi'])
else:
    raise Exception(f"Error: {response.status_code} - {response.text}")

@Babu_Dilip_47574717 Thank you for bringing this to our attention. We have shared the details with the relevant team and will keep you updated here once we receive any updates from them.