Downloading 2 min, 5 min Nifty or stock data for free

Monday, September 27, 2010

The national stock exchange opens at 9:00 AM and closes at 3:30 PM (IST) on any trading day. This converts to total of 390 minutes of trading period. Most of our trading strategy is generally based on EOD data for long term trading but for short term and intraday trading we need the the historical data in different time interval such as 2 min, 5 min, 10 min,15 min,30 min data to back test our trading strategy.

so, how can we get free data of all these interval (2,  5,  10,  15,  30, or any custom interval)?
These data are really costly if we buy it from any data vendor. since tick-by-tick data size is very big and difficult to maintain even vendors like Quote center take a 5 sec snapshot of the data for their distribution and that too is available for 2-3 month. only program trading needs that kind of data access. For other strategies intervals mentioned above are sufficient.Below I am going to show you how to get 2 min data for any stock or index for last 30 days from google finance.

http://www.google.com/finance/getprices?q=SUZLON&x=NSE&i=120&p=2d&f=d,c,o,h,l

Utilizing the getprices function we can fetch the data from google finance according to our need.
All the parameters used in the link are quite obvious.you can read my earlier post to know it in detail.

Here, I will focus on how to get 2 min and 5 min data  for last 1 day , 2 days , 30 day.
-------------------------------------------------------------------------------
Getting 2 min data for today (or last trading day)

1. put q= your STOCK SYMBOL (in google finance)in CAPITAL LETTER
       i=120  : for  2 min dat , 300 for 5 min data
       p=1     : or 2 or put 1000 or any big number >100 to get all the data   
                   available (max 30 days data can be obtained using this)

so we have a total 330/2 =195 data for 2 min interval. On entering the above parameters in the link you will get around 195-205 data. At closing some extra data points are taken. how does the out put look like ?

EXCHANGE%3DNSE
MARKET_OPEN_MINUTE=540
MARKET_CLOSE_MINUTE=930
INTERVAL=120
COLUMNS=DATE,CLOSE,HIGH,LOW,OPEN
DATA=
TIMEZONE_OFFSET=330

a1285299120,53.85,54.2,53.6,53.8
1,53.75,53.9,53.7,53.85
2,53.7,53.8,53.65,53.75
3,54,54.1,53.75,53.75
4,54.15,54.2,54,54
5,54.25,54.35,54.1,54.1
6,54.15,54.25,54.1,54.25
7,54.1,54.2,54.05,54.2
8,54.1,54.2,54.05,54.05
...
...
...

195,54.2,54.2,54.2,54.2
199,54.35,54.35,54.35,54.35
205,54.35,54.35,54.35,54.35
206,54.35,54.35,54.35,54.35
207,54.35,54.35,54.35,54.35
208,54.35,54.35,54.35,54.35
209,54.35,54.35,54.35,54.35

first column is showing the column No and others are respective data.
a1285299120   is a time stamp.
this file can easily be copied and saved in a spread sheet and can be converted to csv file.
-------------------------------------------------------------------------

1 comments:

David August 18, 2012 at 1:24 PM  

Great post , some additional info I found out on the first column data. It is the running number in units of the specify interval from the initial timestamp. For example below is the apple 5 minutes data and you can see a jump from 78 to 288. 288 is the second day data and it is from (24*60)/5
73,636.13,636.4,635.87,636.37
74,636.37,636.48,636.052,636.1001
75,636.08,636.44,635.85,636.34
76,636.04,636.28,635.85,636.03
77,636.04,636.09,635.701,636.04
78,636.34,636.36,636.1,636.16
288,639.68,640.01,639.36,640
289,641.3,641.82,638.83,639.245

Post a Comment

Back to TOP