简体   繁体   中英

How to handle errors from reqMktData calls

Are there any examples on the net how to process errors when downloading data from Interactive Brokers using the IBrokers package ? I've had a look at the package details and eWrapper and twsCALLBACK seem to handle this but I can't get them to work. For example the code below produces an error and R hangs, the error msg isn't processed. Thanks for any suggestions.

contract <-  twsContract(0,
                           symbol="SPI",
                           sectype="XXX",    #bad sectype
                           exch="SNFE",
                           primary="",
                           expiry= "20181220",
                           strike="",
                           currency="AUD",
                           right="",
                           local="",
                           multiplier = "25",
                           combo_legs_desc = "",
                           comboleg = "",
                           include_expired = "",
                           secIdType = "",
                           secId = "")

tws <- twsConnect()
data <- reqMktData(tws,contract,snapshot = TRUE)

You should append a "Disconnect" command to you code. Otherwise your program try to build to connections on the same port, that's not possible and it will not terminate.

I don't know the IBroker package very well, please check the command for disconnecting and append it to your code. Refresh your command line and rerun your code.

In addition, connect to IB Gateway instead of TWS by using that port number (check API settings of your IB Gateway application). In the settings choose a detailed Log. Run your code again (after changing port number) and send your log file. Then I will try to help more. It's hard to help without any error message.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM