[R-SIG-Finance] IBrokers
R P Herrold
herrold at owlriver.com
Mon Dec 1 22:35:39 CET 2008
On Mon, 1 Dec 2008, Arno gaboury wrote:
> My only problem is to be able to download historical data
> (250 days) with a customized closing time (e.g. 5:00 PM
> GMT), not the regular closing price given by exchanges.
> Untill now, after weeks & weeks of browsing the web, I
> couldn't find any suitable solution. I thought IBrokers
> package could be one.
Jeffrey A. Ryan (author of IBrokers) did not supply a worked
example, and I think I have properly stated it later in this
email.
Ad hoc history retrieval intervals are very doable with IB's
history farms (I do not comment yet on the R connection tool
plugin) -- 1700 GMT is either 1200 or 1300 US Eastern time
[varies on 'daylight savings time' offset], and so one would
pull a query on that time mark
A sample script to do such retrievals was published some
months ago at:
http://www.trading-shim.org/pipermail/ts-general/2008-March/000168.html
Obviously one would alter the query time parameter to just:
"12:00:00" or "13:00:00"
in the 'time' array; and update 'syms' to taste; the Ruby
script handles 'walking' through successive array element
conbinations
In like package, the IBrokers package has
reqHistoricalData
and I would expect such a parallel solution to look like:
(taken from the documentation at:
http://cran.r-project.org/web/packages/IBrokers/IBrokers.pdf)
tws <- twsConnect()
contract <- twsContract("AAPL","STK","SMART","ISLAND",
"","0.0","USD","","","",NULL,NULL,"0")
reqHistoricalData(tws,
contract,
'20081201 12:00:00',
barSize = "1 min",
duration = "1 M",
useRTH = "1",
whatToShow = "TRADES",
time.format = "1",
verbose = TRUE,
tickerId = "1",
eventHistoricalData,
file)
# endDateTime argument must be of the form ’CCYYMMDD HH:MM:SS TZ’.
and we would simply step through successive "CCYYMMDD" days
for the data; IB does not keep the finest granularity history
data around for a full year, but one minute data is usually
available.
-- Russ herrold
More information about the R-SIG-Finance
mailing list