Basics of Statistics - I
How to work with indicators
Basics of Statistics - II
Entropy Basics
Entropy Core Strategies
Entropy Advanced Strategies
Backtest Entropy Alpha Strategy with Futures Data Part I
Backtest Entropy Alpha Strategy with Futures Data Part II
Backtest Entropy Alpha Strategy with Equities Data
Entropy FAQs
Entropy Trading Examples
Entropy Sessions

Getting Historical Data of Reliance​ In Pandas Using Python and Zerodha API

Now, coming back to our old discussion of getting the historical data. So lets backtest from the start of 1/1/2019 to today. Although Kite gives data from far behind, Let’s just hold onto last few years to get faster results. You may chose older dates as you may please.
				
					import datetime
starting_date=datetime.datetime(2019, 1, 1)
ending_date=datetime.datetime.today()
				
			

The starting_date and ending_date variables are now initiated with two datetime datatypes. 

Now, lets fetch the data –

				
					zap=kite.historical_data(token,starting_date,ending_date,"day")
zap= pd.DataFrame(zap)
print(zap.head(10))
				
			

It will output –

The initial display exhibits the first 10 rows, utilizing the ‘head’ function to offer a more concise data view of the Pandas Dataframe. It effectively presents OHLC data and volume for each day.

				
					date	open	high	low	close	volume
0	2019-01-01 00:00:00+05:30	1072.60	1074.55	1058.15	1068.55	4674622
1	2019-01-02 00:00:00+05:30	1062.35	1074.25	1049.45	1054.60	7495772
2	2019-01-03 00:00:00+05:30	1055.65	1062.45	1039.05	1041.60	7812061
3	2019-01-04 00:00:00+05:30	1046.05	1052.75	1030.50	1047.25	8880761
4	2019-01-07 00:00:00+05:30	1055.20	1066.10	1049.45	1053.05	5784262
5	2019-01-08 00:00:00+05:30	1053.35	1058.00	1044.70	1052.95	5901336
6	2019-01-09 00:00:00+05:30	1059.95	1064.70	1047.30	1058.75	6049942
7	2019-01-10 00:00:00+05:30	1055.90	1059.00	1051.40	1055.65	4280616
8	2019-01-11 00:00:00+05:30	1055.75	1061.65	1037.65	1046.65	6781266
9	2019-01-14 00:00:00+05:30	1043.75	1049.00	1035.55	1045.45	4313661
				
			
Post a comment

Leave a Comment

Your email address will not be published. Required fields are marked *

×Close