Showing posts with label backfill stock quotes. Show all posts
Showing posts with label backfill stock quotes. Show all posts

Wednesday, July 11, 2012

Historical Minute-by-Minute Stock Prices in MATLAB

This is an extension of my first post on this blog. My first post went over how to gather the minute to minute stock price data from Google Finance using Mathematica. Using the same general programming structure, I've created a function to do this in MATLAB. 

The IntraDayStockData function can be obtained here. This function takes necessary inputs of a stock symbol and the name of the exchange the stock is traded in. This function also takes optional inputs of quote frequency (in seconds) and number of previous trading days. By default, the optional inputs are set for 1 minute quote intervals and 15 previous trading days. The output of this function are the time, the time in string format, trade volume, highest prices, lowest prices, and closing prices. Here is a quick example for getting the minute by minute quotes of the latest trading day (today) for JP Morgan Chase:

jpm = IntraDayStockData('JPM','NYSE','60','1d'); plot(jpm.date,jpm.close,'b-'); hold on; plot(jpm.date,jpm.high,'r-'); hold on; plot(jpm.date,jpm.low,'g-'); datetick('x',16);

Monday, April 18, 2011

Google Finance Backfill

During a 3am google search, I stumbled upon this page:

http://www.marketcalls.in/database/google-realtime-intraday-backfill-data.html

It seems that google finance keeps a 15 day minute by minute backfill of all stock quotes.  This was a great opportunity to use Mathematica to do some overly-complicated plotting at 3am.

The parameters to get the data is detailed on the site above.  For the minute by minute quote of JP Morgan for the last 15 days, the Market Calls website suggested using the following URL:

http://www.google.com/finance/getprices?q=JPM&x=NYSE&i=60&p=15d&f=d,c,h,l

The first task was to create a way to download the data for any stock of interest, which was easy enough with Mathematica.

Now the second task was a bit more complicated, since the backfill data kept time in a Unix format (counting the seconds since the birth of Unix).  The following snippet of code can convert this Unix time to a more familiar format.

Then all that is left to do, is to extract and format the price data.

Now it is time to plot!


When insomnia hits again, I may try my hand on some econometrics styled analysis with this data.  For those interested in playing with the code, you can download it here