Not getting %LTP change for nse options from dhan api. While this is available to view on the app or desktop.
How can I fetch this info or calculate it locally using the available data?
Not getting %LTP change for nse options from dhan api. While this is available to view on the app or desktop.
How can I fetch this info or calculate it locally using the available data?
@vedvishwa Try this. Google Search
Hi @vedvishwa ,
Refer the below code-
ltp_data = tsl.get_ltp_data(['NIFTY'])
ltp = ltp['NIFTY']
ltp_change_percent = ((ltp - previous_close) / previous_close) * 100
I’m stuck here…can anyone help?
@vedvishwa Try official python package. Example code here. Python SDK docs here. API docs here.
Hi @vedvishwa ,
Previous close can be fetched as below -
data = tsl.get_historical_data(tradingsymbol = 'NIFTY',exchange = 'INDEX' ,timeframe="1")
previous_close = data['close'].iloc[-1]
data = tsl.get_historical_data(tradingsymbol = ‘NIFTY’,exchange = ‘INDEX’ ,timeframe=“1”)
previous_close = data[‘close’].iloc[-1]
Can this code be modified to fetch options data for previous day’s values for a specific strike price using daily timeframe? Can you suggest the modifications required.
…….
Meanwhile, I am trying fetch the same using get_expired_option_data method. However, the data it returned seems to be inaccurate..because, if you see the screenshot, I have passed only one strike price (22500) but the method returned values for multiple strike prices. I don’t know why? Can you check my syntax and suggest corrections in my code.
I’m stuck here…can somebody please help on the above
Hi @vedvishwa ,
Currently, only rolling historical options data is available, and there is no function in Dhan to fetch data for a specific strike price.
Refer this video -
Hi,
I want to get previous day’s closing price for a specific strike…How can I do it using get_historical_data or get_expired_option_data method?
@vedvishwa DM me on the link mentioned in my profile.
Can someone help with my query pls…
Hi @vedvishwa ,
To fetch the previous day’s closing price for a specific strike , you can use get_historical_data method .
Thank you Imran.
Can I get a sample usage for this method in action?
Hi @vedvishwa ,
Refer this sample code -
data = tsl.get_historical_data(tradingsymbol='NIFTY', exchange='INDEX', timeframe="DAY")
Arguments:
Hello,
Can you please elaborate over this function with an example to help using the ‘get_historical_data’ function to fetch options data for a particular strike on any past dates of the current weekly expiry.
I also need this data over 2 hourly and 4 hourly timeframes.
On the sidelines, Is it true that the function ‘get_expired_option_data’ can help in fetching data for completely expired contract and, the function ‘get_historical_data’ can help in fetching instrument’s historical data falling within the current expiry?