[R-SIG-Finance] IBrokers, TWS and eWrapper.data.Last.R
Niklas K
nk at fennoturvapalvelut.com
Mon Mar 11 19:02:20 CET 2013
Hi!
I am trying to achieve the same as A. Zege discussed on this list
earlier (link:
http://r.789695.n4.nabble.com/how-to-get-quotes-with-IBrokers-td2329328.html
) which he seemed to accomplish. That is I need to poll a large number
of very thinly traded instruments.
Based on the earlier discussion and the help of Garrett (here:
http://stackoverflow.com/questions/15096987/ibrokers-reqmktdata-how-to-add-timeout-to-the-callback-function
) I created an ewrapper with timeout that returns values even if not all
values have been filled.
The code for it is here:
http://pastebin.com/FYp3dwCX
The problem I have with this callback is that when it has been called
usually 2-3 times execution will stop with the error:
Error in file[[id]] : subscript out of bounds
I am not sure what would cause this kind of error and I havent been able
to sort it out.
I make the call to it for example like this:
opts <- reqContractDetails(tws, twsOption(local="", expiry=expir_date,
right=put_or_call, symbol=stk))
opt_prices <- reqMktData(tws, Contract = opts,
eventWrapper=eWrapper.data.Last(length(opts)),CALLBACK=snapShot)
If anyone has tips or has an wrapper file that would accomplish this I
would be very grateful!
BR,
Niklas
More information about the R-SIG-Finance
mailing list