Hello,
I’m new to this.
Can any one help to write python code Nifty, Bank Nifty spot in real time?
dhan.intraday_minute_data(security_id=idx_secid,
exchange_segment=‘IDX_I’,
instrument_type=‘INDEX’)
where Dhan instance is created using your client ID and token
dhan = dhanhq(“DHAN_CLIENTID”, “DHAN_API”) and ;
idx_secid can be either of these : {‘13’: ‘NIFTY’, ‘25’: ‘BANKNIFTY’, ‘27’: ‘FINNIFTY’, ‘442’: ‘MIDCPNIFTY’, ‘51’ : 'SENSEX}
and once you have converted the json to a Dataframe you can extract the last close price by df[‘close’].iloc[-1]
Hello @shekhar.biswas @gestural
Welcome to Dhan Community!
Would recommend you to try out this youtube playlist on DhanHQ APIs with Python from scratch: Beginners Guide : Algorithmic Trading.
@gestural Thank you for posting this code snippet.
Thanks. I will try and revert for any help.