Hi Imran,
I want to build trading symbol from the strike price obtained from options data. Do we have any function for this? This way i can pass the trading symbol to the get_long_term_historical_data function.
Hi Imran,
I want to build trading symbol from the strike price obtained from options data. Do we have any function for this? This way i can pass the trading symbol to the get_long_term_historical_data function.
hi @vedvishwa
Since in option chain we get the strike only, we need to construct trading_symbol manually.
Where getting underlying, strike, and right as easy tasks.
expiry we can give manually
underlying = 'NIFTY'
expiry = '12 MAY' # expiry we can give manually
strike = "24300" # this we get from option chain
right = "CALL"
trading_symbol = f"{underlying} {expiry} {strike} {right}"
now we have got our trading_symbol, we can pass this to get_long_term_historical_data
@vedvishwa
Also there is a second method to get %ltp change
we can call quote data.. it contains, ltp and previous close values.. and then calculate pct change
see solution
symbol_name = 'NIFTY 12 MAY 24400 CALL'
quote_data = tsl.get_quote_data(names=[symbol_name])[symbol_name]
previous_close = quote_data['ohlc']['close']
ltp = quote_data['last_price']
ltp_pct_change = ((ltp-previous_close)/previous_close)*100
and the same info matched with dhan charts as well
Is this error due to missing/incorrect parameters for the function call, or is it due to non-availability of the service during weekends ?
Dear forum moderators,
Now this error from the channel is also frustrating…
How can we explain our issues with just one screenshot? And btw, who is a new user after posting 25 messages?
HI @vedvishwa
There may be 3 probable causes
pip install Dhan-Tradehull
Do delete the dependencies folder. This will also remove instruments file inside of it.. which may be cause the issue for “unable to find the correct expiry for nifty” .
and then use a new token for login. this will create fresh dependencies folder, and thus fresh instrument file
Check if the Dhan api data subscription is active
Also I tried to run same on my end, api seems to be working fine
adding @Dhan for same
Hello Imran…
I have…
But still the data is not coming…
Hi @vedvishwa
there is a bit change in code for exchange , where exchange=“INDEX”
I have added working code below
atm, option_chain = tsl.get_option_chain(Underlying="NIFTY", exchange="INDEX", expiry=0, num_strikes=10)