Last active
October 3, 2022 07:57
-
-
Save ganigithub/4b9b87360bc79716c88118661125d7f8 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def instrument_token(data, symbol): | |
""" | |
This function will return the token number of the instrument from data | |
""" | |
return data[data.tradingsymbol == symbol].instrument_token.values[0] | |
def historical_data(symbol, from_date, to_date, interval): | |
""" | |
This function will return historical data of the instrument for specific period of days for specific interval | |
""" | |
df = pd.DataFrame() | |
int_token = instrument_token(nse_data, symbol) #the function we defined above which will return token no. of instrument | |
to_date = pd.Timestamp(to_date) | |
from_date = pd.Timestamp(from_date) | |
while True: | |
if from_date >= (to_date - dt.timedelta(60)): #if from_date is within the 60 days limit | |
df = df.append(pd.DataFrame(kite.historical_data(int_token, from_date, to_date, interval))) | |
break | |
else: #if from_date has more than 60 days limit | |
to_date_new = from_date + dt.timedelta(60) | |
df = df.append(pd.DataFrame(kite.historical_data(int_token, from_date, to_date_new, interval))) | |
#to_date = from_date.date() + dt.timedelta(60) | |
from_date = to_date_new | |
return df |
Hello,
Thanks for observing this mistake...
instrument_token is just a function which returns the instrument token
number of the stock / instrument.
I've updated the gist you can see here...
https://gist.github.com/ganigithub/4b9b87360bc79716c88118661125d7f8
…On Mon, Jul 4, 2022 at 5:22 PM 26dhruv ***@***.***> wrote:
***@***.**** commented on this gist.
------------------------------
what's instrument token in this?
—
Reply to this email directly, view it on GitHub
<https://gist.github.com/4b9b87360bc79716c88118661125d7f8#gistcomment-4220827>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/AUTYQUIYV4FAFPARMIIMQX3VSLGBRANCNFSM52S55TRQ>
.
You are receiving this because you authored the thread.Message ID:
***@***.***>
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
what's instrument token in this?
[SOLVED]