joshuaulrich / IBrokers

R API to Interactive Brokers Trader Workstation
65 stars 54 forks source link

Issue running reqContractDetails #38

Open rjvelasquezm opened 1 year ago

rjvelasquezm commented 1 year ago

Description

In the new version of IBrokers I can't seem to get reqContractDetails to work with futures.

Minimal, reproducible example

If I run the following code


contract_raw = IBrokers::twsFuture(symbol ='',exch = '',expiry = '',local = 'MESH3')
tws = twsConnect()
contract_details = reqContractDetails(conn = tws,Contract = contract_raw)

I get an error that says:

Error in if (curMsg != .twsIncomingMSG$CONTRACT_DATA) { : 
  argument is of length zero
In addition: Warning message:
In writeBin(as.character(request), con) : problem writing to connection

but running the exact same code with IBrokers version 0.9-12 works without issues.

diegoperoni commented 1 year ago

take a look to issue #43

diegoperoni commented 1 year ago

I fixed a lot of problems just adding this lines of code to processMsg to fix empty content returned by TWS caused by socket delay:

processMsg = function(curMsg, con, eWrapper, timestamp, file, twsconn, ...) {

if (is.null(curMsg) || length(curMsg)==0) { return(NULL) }

default normal code following....