[R-SIG-Finance] intraday historical data

G See gsee000 at gmail.com
Tue Mar 12 15:04:52 CET 2013


This is extremely broad.  You just want intraday data?  Whose day? The
SGX provides free intraday data:
http://www.sgx.com/wps/portal/sgxweb/home/marketinfo/historical_data/derivatives/time_sales

What asset class?  TrueFX provides historical tick data for FX
(http://truefx.com/?page=downloads).  There's a script called
download.TrueFX.R in the inst/parser directory of FinancialInstrument
that will download and parse that data.
(http://r-forge.r-project.org/scm/viewvc.php/pkg/FinancialInstrument/inst/parser/?root=blotter)

Maybe you want stocks?  Did you search the internet?  I found this via
google: http://www.quantshare.com/sa-426-6-ways-to-download-free-intraday-and-tick-data-for-the-us-stock-market

That link gives 6 sources.  One of them is "stooq".  They provide 5
days of 5 minute OHLC data for thousands of stocks around the world.
I once wrote a script to download and parse that data.  I ran it on a
crontab for a couple weeks, then they put up a captcha.  So, I guess
they don't want you downloading the data systematically -- I don't
know, I can't read Polish.  If you're willing to manually download the
data at least once every 5 days, I'd be happy share my code that
parses it.

Also, the methods that page gives for getting historical intraday data
from Google and Yahoo look promising if you're up to parsing it.  I
think I have some scraps of code laying around somewhere where I
started working on that.  Let me know if you'd like me to look.

I use Interactive Brokers for my personal intraday data needs.
They're really hard to beat since they provide a year's worth of data
for stocks, bonds, FX, options, futures, etc. for products all over
the world.

I use (a small adaptation of) twsInstrument:::update.data() to
download minutely OHLC data for BID, ASK, and TRADES, data for over
2000 stocks.  Since you can only make 6 requests every minute, it
takes almost a full day to download 5 days of data.  So, it runs 24
hours a day.  (it's also helpful to get more than one log-in).  There
is a cost for Interactive Brokers.  It's about 10 or 20 bucks a month,
but if you spend that much money on commissions, they waive the fee.
I just get minutely data, because I want a lot of history for a lot of
symbols, but they also provide 1 second frequency historical data if
you are patient.  Here's the reference for how much data you can get
per request (remember: 6 requests a minute)
http://www.interactivebrokers.com/php/apiUsersGuide/apiguide/api/historical_data_limitations.htm

If you're interested in realtime/near-realtime intraday data, you have
a few options.

This will give you a 15 minute delayed quote:
getQuote("SPY", src="yahoo")

These will give you a real-time quote:
library(qmao)

getQuote("SPY", src="google")

getQuote("SPY", src="IB") # if you have an Interactive Brokers account

getQuote("SPY", src="bats")
getQuote("SPY", src="bats", what="bbo")
getQuote("SPY", src="bats", what="ladder")
getQuote("SPY", src="bats", what="depth")
getQuote("SPY", src="bats", what="trades")
# These come with plot methods too
plot(getQuote("SPY", src="bats"))
plot(getQuote("SPY", src="ladder"))
plot(getQuote("SPY", src="depth"))

I created a shiny app using the getQuote.bats stuff.  If you run
qmao::shinyBATS() it will launch this shiny app:
http://glimmer.rstudio.com/gsee/BATS/

You can wrap one of these getQuote calls in a while loop to retrieve a
"stream" of data

dat <- NULL
while(TRUE){
    dat <- rbind(dat, getQuote("SPY", src="yahoo"))
    Sys.sleep(1)
}

(If you like shiny, here's a crude way to plot intraday data as it
comes in -- just replace the rnorm call with a getQuote call:
https://gist.github.com/gsee/4384158)

If you want real-time intraday fx quotes, see the TFX package
(http://rpubs.com/gsee/TFX)

Recently, I've been excited about this new free API (requires a free
account): https://developers.tradeking.com/documentation/r
According to their forums, they're planning on rolling out historical
intraday data soon.  Currently, you can get snapshots, or streaming
data.


twsInstrument and qmao can be obtained via svn checkout from
https://r-forge.r-project.org/R/?group_id=1113

I hope this helps, and I hope that if you write code to parse some
intraday historical data, that you share it with the list.

Best,
Garrett


On Mon, Mar 11, 2013 at 6:15 PM, Bill Blount <bill at easterngrain.com> wrote:
> i just mean intraday historical quotes.  any ideas where?
>
> On Mon, Mar 11, 2013 at 6:36 PM, Michael Weylandt <
> michael.weylandt at gmail.com> wrote:
>
>> What exactly do you mean by end of day intraday?
>>
>> Regardless, I assume the answer is 'yes, many by subscription: some cheap:
>> few free.'
>>
>> MW
>>
>> On Mar 11, 2013, at 22:26, Bill Blount <bill at easterngrain.com> wrote:
>>
>> > is there a source for end of day intraday data (i am assuming that yahoo
>> is
>> > daily only)?
>> >
>> > Thanks.  Bill
>> >
>> >    [[alternative HTML version deleted]]
>> >
>> > _______________________________________________
>> > R-SIG-Finance at r-project.org mailing list
>> > https://stat.ethz.ch/mailman/listinfo/r-sig-finance
>> > -- Subscriber-posting only. If you want to post, subscribe first.
>> > -- Also note that this is not the r-help list where general R questions
>> should go.
>>
>
>         [[alternative HTML version deleted]]
>
> _______________________________________________
> R-SIG-Finance at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-sig-finance
> -- Subscriber-posting only. If you want to post, subscribe first.
> -- Also note that this is not the r-help list where general R questions should go.



More information about the R-SIG-Finance mailing list