From c45c4a2b3b7dbeb907e19f3860f42c52d5985475 Mon Sep 17 00:00:00 2001 From: lbilli Date: Thu, 21 Jul 2022 14:20:53 -0400 Subject: [PATCH] Drop support for API < v165 --- DESCRIPTION | 2 +- R/Decoder.R | 57 +++++++++++++++------------------------------------ R/IBClient.R | 14 ++++--------- R/constants.R | 10 +-------- README.md | 2 +- 5 files changed, 24 insertions(+), 61 deletions(-) diff --git a/DESCRIPTION b/DESCRIPTION index 161aafe..fa02e45 100644 --- a/DESCRIPTION +++ b/DESCRIPTION @@ -1,6 +1,6 @@ Package: rib Title: An R implementation of Interactive Brokers API -Version: 0.15.1 +Version: 0.16.0 Authors@R: person("Luca", "Billi", email = "noreply.section+dev@gmail.com", role = c("aut", "cre")) Description: A native R implementation of Interactive Brokers API. It establishes a TCP connection to a server and handles diff --git a/R/Decoder.R b/R/Decoder.R index 69ecd8c..d5f30b0 100644 --- a/R/Decoder.R +++ b/R/Decoder.R @@ -21,10 +21,9 @@ Decoder <- R6::R6Class("Decoder", # The first field is the message ID msgId <- imsg$pop() - # The second field is unused version, for msgId < 75 and != 3, 5, 11, 17, 21 + # The second field is unused version, for msgId < 75 and != 3, 5, 10, 11, 17, 18, 21 imsgId <- Validator$i(msgId) - if(imsgId < 75L && ! imsgId %in% c(3L, 5L, 10L, 11L, 17L, 18L, 21L) || - imsgId %in% c(10L, 18L) && private$serverVersion < MIN_SERVER_VER_SIZE_RULES) + if(imsgId < 75L && ! imsgId %in% c(3L, 5L, 10L, 11L, 17L, 18L, 21L)) imsg$pop() # Convert ID -> Name @@ -373,16 +372,10 @@ Decoder <- R6::R6Class("Decoder", "dontUseAutoPriceForHedge", "isOmsContainer", "discretionaryUpToLimitPrice", - "usePriceMgmtAlgo")] <- imsg$pop(5L) - - if(private$serverVersion >= MIN_SERVER_VER_DURATION) - order$duration <- imsg$pop() - - if(private$serverVersion >= MIN_SERVER_VER_POST_TO_ATS) - order$postToAts <- imsg$pop() - - if(private$serverVersion >= MIN_SERVER_VER_AUTO_CANCEL_PARENT) - order$autoCancelParent <- imsg$pop() + "usePriceMgmtAlgo", + "duration", + "postToAts", + "autoCancelParent")] <- imsg$pop(8L) if(private$serverVersion >= MIN_SERVER_VER_PEGBEST_PEGMID_OFFSETS) order[c("minTradeQty", @@ -446,10 +439,6 @@ Decoder <- R6::R6Class("Decoder", cd$contract$tradingClass <- imsg$pop() cd$contract$conId <- imsg$pop() cd$minTick <- imsg$pop() - - if(private$serverVersion < MIN_SERVER_VER_SIZE_RULES) - imsg$pop() # deprecated mdSizeMultiplier - cd$contract$multiplier <- imsg$pop() cd[4L:8L] <- imsg$pop(5L) cd$contract$primaryExchange <- imsg$pop() @@ -465,16 +454,10 @@ Decoder <- R6::R6Class("Decoder", "underSecType", "marketRuleIds", "realExpirationDate", - "stockType")] <- imsg$pop(6L) - - if(private$serverVersion >= MIN_SERVER_VER_FRACTIONAL_SIZE_SUPPORT && - private$serverVersion < MIN_SERVER_VER_SIZE_RULES) - imsg$pop() # deprecated sizeMinTick - - if(private$serverVersion >= MIN_SERVER_VER_SIZE_RULES) - cd[c("minSize", - "sizeIncrement", - "suggestedSizeIncrement")] <- imsg$pop(3L) + "stockType", + "minSize", + "sizeIncrement", + "suggestedSizeIncrement")] <- imsg$pop(9L) private$validate("contractDetails", reqId=reqId, contractDetails=cd) }, @@ -507,12 +490,8 @@ Decoder <- R6::R6Class("Decoder", cd$contract[c("tradingClass", "conId")] <- imsg$pop(2L) - cd$minTick <- imsg$pop() - - if(private$serverVersion < MIN_SERVER_VER_SIZE_RULES) - imsg$pop() # deprecated mdSizeMultiplier - - cd[c("orderTypes", + cd[c("minTick", + "orderTypes", "validExchanges", "nextOptionDate", "nextOptionType", @@ -520,7 +499,7 @@ Decoder <- R6::R6Class("Decoder", "notes", "longName", "evRule", - "evMultiplier")] <- imsg$pop(9L) + "evMultiplier")] <- imsg$pop(10L) n <- Validator$i(imsg$pop()) @@ -528,12 +507,10 @@ Decoder <- R6::R6Class("Decoder", cd$secIdList <- fold_tagvalue(imsg$pop(2L * n)) cd[c("aggGroup", - "marketRuleIds")] <- imsg$pop(2L) - - if(private$serverVersion >= MIN_SERVER_VER_SIZE_RULES) - cd[c("minSize", - "sizeIncrement", - "suggestedSizeIncrement")] <- imsg$pop(3L) + "marketRuleIds", + "minSize", + "sizeIncrement", + "suggestedSizeIncrement")] <- imsg$pop(5L) private$validate("bondContractDetails", reqId=reqId, contractDetails=cd) }, diff --git a/R/IBClient.R b/R/IBClient.R index d4061f4..c9a3fb2 100644 --- a/R/IBClient.R +++ b/R/IBClient.R @@ -430,16 +430,10 @@ IBClient <- R6::R6Class("IBClient", "dontUseAutoPriceForHedge", "isOmsContainer", "discretionaryUpToLimitPrice", - "usePriceMgmtAlgo")]) - - if(self$serVersion >= MIN_SERVER_VER_DURATION) - payload <- c(payload, order$duration) - - if(self$serVersion >= MIN_SERVER_VER_POST_TO_ATS) - payload <- c(payload, order$postToAts) - - if(self$serVersion >= MIN_SERVER_VER_AUTO_CANCEL_PARENT) - payload <- c(payload, order$autoCancelParent) + "usePriceMgmtAlgo", + "duration", + "postToAts", + "autoCancelParent")]) if(self$serVersion >= MIN_SERVER_VER_ADVANCED_ORDER_REJECT) payload <- c(payload, order$advancedErrorOverride) diff --git a/R/constants.R b/R/constants.R index f9300c6..cf48872 100644 --- a/R/constants.R +++ b/R/constants.R @@ -7,14 +7,6 @@ HEADER_LEN <- 4L MAX_MSG_LEN <- 0xFFFFFFL # 16Mb - 1b # Server Versions -MIN_SERVER_VER_DURATION <- 158L -MIN_SERVER_VER_MARKET_DATA_IN_SHARES <- 159L -MIN_SERVER_VER_POST_TO_ATS <- 160L -MIN_SERVER_VER_WSHE_CALENDAR <- 161L -MIN_SERVER_VER_AUTO_CANCEL_PARENT <- 162L -MIN_SERVER_VER_FRACTIONAL_SIZE_SUPPORT <- 163L -MIN_SERVER_VER_SIZE_RULES <- 164L -MIN_SERVER_VER_HISTORICAL_SCHEDULE <- 165L MIN_SERVER_VER_ADVANCED_ORDER_REJECT <- 166L MIN_SERVER_VER_USER_INFO <- 167L MIN_SERVER_VER_CRYPTO_AGGREGATED_TRADES <- 168L @@ -25,5 +17,5 @@ MIN_SERVER_VER_IPO_PRICES <- 172L MIN_SERVER_VER_WSH_EVENT_DATA_FILTERS_DATE <- 173L -MIN_CLIENT_VER <- 157L +MIN_CLIENT_VER <- 165L MAX_CLIENT_VER <- MIN_SERVER_VER_WSH_EVENT_DATA_FILTERS_DATE diff --git a/README.md b/README.md index 946ca67..9d0eae2 100644 --- a/README.md +++ b/README.md @@ -8,7 +8,7 @@ implements [Interactive Brokers](https://www.interactivebrokers.com/) API to communicate with their TWS or IBGateway. It aims to be feature complete, however it does not support legacy versions. -Currently, only API versions `v157+` are supported. +Currently, only API versions `v165+` are supported. The package design mirrors the official C++/Java [IB API](https://interactivebrokers.github.io/tws-api/),