[R-SIG-Finance] ibrokers
Stephen Choularton
stephen at organicfoodmarkets.com.au
Wed Dec 1 09:28:56 CET 2010
Hi Jeff
Thanks, they all seem to work now although reqRealTimeBars and
reqMktDepth only work while the market is trading, which i suppose is
correct anyway.
I'm mainly looking at spreads and I wrote this charting function that
seems to work very well:
chartIB <- function(sym1, sym2) {
one <- reqHistoricalData(tws, twsEquity(sym1, exch='ASX',
currency="AUD"),duration = "6 M")
two <- reqHistoricalData(tws, twsEquity(sym2, exch='ASX',
currency="AUD"),duration = "6 M")
chartSeries(one - two, type='line',name=c(' ', sym1, ' - ',
sym2),theme=chartTheme('white'),TA=NULL)
addBBands(n = 20, sd = 2, maType = "SMA", draw = 'bands', on = -1)
}
library(IBrokers)
library('quantmod')
tws <- twsConnect()
tws
chartIB('CBA','NAB')
dev.new()
chartIB('CBA','WBC')
I'm using the bollinger function to draw 2 standard deviations which are
my boundaries and if the spread is outside them I open short or long and
hold until I get back to the mean. I test for co-integration first but
I haven't done any work on time to revert to mean or indeed on if 2
standard deviations is the optimum boundary..
I wouldn't mind doing the same sort of thing with reqRealTime Bars, but
I'm still having a lot of trouble using the callbacks in IBrokers. Did
I read you are going to run some sort of courses? is there a more
fulsome tutorial (with lots of code examples ;-)
I've read your paper Real Time Market Data and Trade Execution but the
example 2.5 is missing. I'd love to see it.
Stephen Choularton Ph.D., FIoD
More information about the R-SIG-Finance
mailing list