Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

placeOrder does not include/transmit algoParams #39

Open
fmair opened this issue Apr 20, 2023 · 0 comments
Open

placeOrder does not include/transmit algoParams #39

fmair opened this issue Apr 20, 2023 · 0 comments

Comments

@fmair
Copy link

fmair commented Apr 20, 2023

Description

In IBrokers 0.10-2 the function IBrokers::placeOrder creates an order with algoStrategy that is written to the connection, but algoParams is not, while it is an argument to twsOrder. Therefore, orders that were created including algoParams tend to be rejected by TWS.

In plain terms: We can tell TWS to create a market order with "algoStrategy" == "Adaptive", but not with an adaptivePriority, e.g. "Urgent".

Expected behavior

The function should include algoParams such that algo orders can be created using IBrokers

Minimal, reproducible example

library(IBrokers) # v 0.10-2

tws <- twsConnect(port = 7496, verbose = TRUE)

contract <- twsFuture(symbol = "ES",
                       exch = "CME",
                       expiry = "202306",
                       currency = "USD")

order <- IBrokers::twsOrder(action = "BUY",
                            totalQuantity = 1,
                            orderType = "MKT",
                            tif = "DAY",
                            transmit = FALSE,
                            algoStrategy = "Adaptive",
                            algoParams = c("1", "adaptivePriority", "Patient")

placeOrder(twsconn = tws,
           Contract = contract,
           Order = order)

Suggested fix

Include Order$algoParams, in line 65 in the placeOrder function. It works on my local version. I'll try to come up with a merge request.

Session Info

R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 19044)

Matrix products: default

locale:
[1] LC_COLLATE=English_United States.utf8  LC_CTYPE=English_United States.utf8    LC_MONETARY=English_United States.utf8 LC_NUMERIC=C                          
[5] LC_TIME=English_United States.utf8    

attached base packages:
[1] stats     graphics  grDevices utils     datasets  methods   base     

other attached packages:
[1] twsInstrument_1.4-10      FinancialInstrument_1.3.1 quantmod_0.4.20           TTR_0.24.3                IBrokers_0.10-2           xts_0.13.0               
[7] zoo_1.8-11               

loaded via a namespace (and not attached):
[1] compiler_4.2.1  tools_4.2.1     rstudioapi_0.14 curl_4.3.2      grid_4.2.1      lattice_0.20-45
fmair pushed a commit to fmair/IBrokers that referenced this issue Apr 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant