I am comparing from Kite chart. Look at the volume. What i got is 210260, while it is actually around 32lakhs. Also day low should be 2019.75 as per kite chart, but i got 2020.
You are fetching BSE instrument_token of TCS and comparing it with TCS-NSE chart data. Modify your getInstrumentToken method to return only NSE instrument for requested Symbol. Might add,filter condition of exchange=='NSE' in above method.
def getHistoricalData(symbol, days, interval):
# minute, 3minute, 5minute, 10minute, 15minute, 30minute, 60minute, day
instrumenttoken = getInstrumentToken(symbol)
fromdate = date.today()-timedelta(days=days)
todate = date.today()
historicaldata = kite.historical_data(instrumenttoken, fromdate, todate, interval)
data = pd.DataFrame(historicaldata)
#data.set_index('date', inplace=True)
return data
getHistoricalData('TCS', 20, 'day')
getHistoricalData('TCS', 5, '5minute')
Extracted Mindtree Daily data.
OHLC and volume has discrepancy.
date open high low close volume
0 2020-06-03 00:00:00+05:30 935.0 936.0 904.9 908.5 49240
1 2020-06-04 00:00:00+05:30 928.5 939.75 905.1 934.75 89702
2 2020-06-05 00:00:00+05:30 944.9 945.5 917.0 918.95 45158
3 2020-06-08 00:00:00+05:30 925.9 930.85 909.35 918.4 30312
4 2020-06-09 00:00:00+05:30 920.35 926.1 887.05 897.25 34067
5 2020-06-10 00:00:00+05:30 905.0 916.45 858.4 909.2 89746
6 2020-06-11 00:00:00+05:30 910.0 924.7 896.0 919.15 31837
7 2020-06-12 00:00:00+05:30 891.0 918.0 887.6 913.55 17226
8 2020-06-15 00:00:00+05:30 907.4 930.5 903.05 922.95 29351
9 2020-06-16 00:00:00+05:30 931.0 935.3 908.15 912.2 31687
10 2020-06-17 00:00:00+05:30 930.0 930.0 902.95 906.15 123022
11 2020-06-18 00:00:00+05:30 915.6 918.8 900.3 907.4 19688
12 2020-06-19 00:00:00+05:30 905.0 934.0 898.35 912.75 47499
13 2020-06-22 00:00:00+05:30 915.65 921.7 900.0 909.45 14240
14 2020-06-23 00:00:00+05:30 897.0 938.0 897.0 926.2 54199
Used below code. Previously there was no issue. Data extraction was accurate using this same code snippet.
def getHistoricalData(symbol, days, interval):
# minute, 3minute, 5minute, 10minute, 15minute, 30minute, 60minute, day
instrumenttoken = getInstrumentToken(symbol)
fromdate = date.today()-timedelta(days=days)
todate = date.today()
historicaldata = kite.historical_data(instrumenttoken, fromdate, todate, interval)
data = pd.DataFrame(historicaldata)
return data
getHistoricalData('MINDTREE', 20, 'day')
Modify your
getInstrumentToken
method to return only NSE instrument for requested Symbol. Might add,filter condition ofexchange=='NSE'
in above method.