4ABMVB
January 20, 2025, 5:42am
1
OHLC data is coming as 0 … but getting this data for Crude … please check.
interval=‘1d’
api_version = ‘2.0’
api_instance.get_market_quote_ohlc(‘NSE_COM|126099’, interval, api_version)
{‘data’: {‘NSE_COM:NATURALGAS25JANFUT’: {‘instrument_token’: ‘NSE_COM|126099’,
‘last_price’: 0.0,
‘ohlc’: {‘close’: 0.0,
‘high’: 0.0,
‘low’: 0.0,
‘open’: 0.0}}},
‘status’: ‘success’}
Ketan
January 20, 2025, 7:27am
2
Hi @4ABMVB ,
The instrument you provided is not currently being traded, which is why the OHLC values are showing as 0.
You can verify this using our historical API. Below is the curl request:
curl --location 'https://api.upstox.com/v2/historical-candle/NSE_COM|126099/day/2025-01-25/2024-01-13' \
--header 'Accept: application/json'
In the response, you’ll notice that the volume for each day is zero (the sixth element of each candle represents the volume).
For more details, you can refer to our documentation:
https://upstox.com/developer/api-documentation/get-historical-candle-data
Thank you!
4ABMVB
January 20, 2025, 12:37pm
3
Hi Ketan,
Thank you for your reply.
Can you help me with the instrument code to fetch naturalgas data ? i am not talking about mini here?
Ketan
January 22, 2025, 5:09am
4
@4ABMVB
You can refer to this python snippet which gives a list of natural gas instruments.
import requests
import gzip
import json
def load_instruments():
instrument_file_link = "https://assets.upstox.com/market-quote/instruments/exchange/complete.json.gz"
# Download the file
response = requests.get(instrument_file_link)
response.raise_for_status() # Ensure we notice bad responses
# Decompress the file
compressed_content = response.content
decompressed_content = gzip.decompress(compressed_content)
# Parse the JSON content
instruments = json.loads(decompressed_content)
natural_gas_instruments = []
for instrument in instruments:
if instrument["segment"] == "NSE_COM" and instrument["name"] == "NATURALGAS":
natural_gas_instruments.append(instrument["instrument_key"])
print(natural_gas_instruments)
return natural_gas_instruments
Once you have a list of instruments, simply pass it to the market data feeder WebSocket to start receiving the feed.
For examples on how to send instrument keys to the streamer function, please refer to the documentation at: GitHub - upstox/upstox-python: Official Python SDK for accessing Upstox API .
4ABMVB
January 22, 2025, 6:51am
5
Hi Ketan,
I picked instrument key from this same file. NSE_COM|126099… please let me know if i am doing anything wrong … I am looking for NaturalGas (not mini). thank you.
Regards,
Bhavin
Ketan
January 22, 2025, 1:31pm
6
4ABMVB:
NSE_COM|126099
You have selected the correct instrument key, but the issue is that NSE_COM:NATURALGAS25JANFUT
is not being traded. However, the same token is actively traded on the MCX exchange as MCX_FO:NATURALGAS25JANFUT
. Please check the instrument MCX_FO|437800
for reference.
Thank you.