lbilli / rib

An R implementation of Interactive Brokers API
GNU General Public License v3.0
34 stars 7 forks source link

Error when fetching contract details #24

Closed enricoschumann closed 6 months ago

enricoschumann commented 6 months ago

With the latest version of rib (a67af061b511596ac98945c58b4ef50a068a510e), when I try to fetch contract details, I get an error. Here is a very stripped-down example to reproduce the error:

library("rib")
port <- 7496
clientId <- 1

wrap <- R6::R6Class("IBWrapCustom",
    class = FALSE,
    cloneable = FALSE,
    lock_class= TRUE,
    inherit = rib::IBWrap,

    public = list(
        error = function(id, errorCode, errorString, advancedOrderRejectJson)
            NULL,
        contractDetails=    function(reqId, contractDetails)
            NULL,
        contractDetailsEnd= function(reqId)
            NULL,
        nextValidId=        function(orderId)
            NULL,
        managedAccounts=    function(accountsList)
            NULL
    )
)

wrap <- wrap$new()
ic <- IBClient$new()

ic$connect(port = port, clientId = clientId)
ic$checkMsg(wrap)

contr <- rib::Contract
contr$secIdType <- "ISIN"
contr$secId <- "CA82509L1076"
contr$exchange <- "NYSE"
contr$secType <- "STK"

ic$reqContractDetails(1, contr)
ic$checkMsg(wrap)
## Error in ev$.validate(arglist, names = names, types = types) : 
##   names(arglist) == names are not all TRUE
## In addition: Warning message:
## In names(arglist) == names :
##   longer object length is not a multiple of shorter object length

ic$disconnect()

With the previous version (748b8f3df3d3a0b5c01a4057ad150a440ee5fa69), I don't get this error. The latest commit added a field lastTradeDate to contract details. Shouldn't that field also be reflected in inst/data-raw/codes_struct.txt?

Thank you.

lbilli commented 6 months ago

Yes, that's sounds about right. Thanks

enricoschumann commented 6 months ago

Impressive ;-) thank you