Closed hemangjoshi37a closed 2 years ago
Not sure about the documentation but I think below code might help you.
...
...
import pandas as pd
from datetime import datetime as dt
from datetime import timedelta as td
...
...
...
# do all kite object creation steps
sbin_token = kite.ltp("NSE:SBIN")['NSE:SBIN']['instrument_token']
df = pd.DataFrame(kite.historical_data(
sbin_token, dt.today() - td(days=7), dt.today(), '15minute'))
print(df)
nf_token = kite.ltp("NSE:NIFTY 50")['NSE:NIFTY 50']['instrument_token']
df = pd.DataFrame(kite.historical_data(
nf_token, dt.today() - td(days=7), dt.today(), '15minute'))
print(df)
bnf_token = kite.ltp("NSE:NIFTY BANK")['NSE:NIFTY BANK']['instrument_token']
df = pd.DataFrame(kite.historical_data(
bnf_token, dt.today() - td(days=7), dt.today(), '15minute'))
print(df)
The response structure section of all APIs explains the fields.
Not sure about the documentation but I think below code might help you.
... ... import pandas as pd from datetime import datetime as dt from datetime import timedelta as td ... ... ... # do all kite object creation steps sbin_token = kite.ltp("NSE:SBIN")['NSE:SBIN']['instrument_token'] df = pd.DataFrame(kite.historical_data( sbin_token, dt.today() - td(days=7), dt.today(), '15minute')) print(df) nf_token = kite.ltp("NSE:NIFTY 50")['NSE:NIFTY 50']['instrument_token'] df = pd.DataFrame(kite.historical_data( nf_token, dt.today() - td(days=7), dt.today(), '15minute')) print(df) bnf_token = kite.ltp("NSE:NIFTY BANK")['NSE:NIFTY BANK']['instrument_token'] df = pd.DataFrame(kite.historical_data( bnf_token, dt.today() - td(days=7), dt.today(), '15minute')) print(df)
Thanks. Your solution works. https://hjlabs.in
Dear sir,
There is absolute no documentation on how to read indices like NIFTY from historical_data() function or by any other way.
Please help me. Thank you in advance sir.