Skip to content

fix #39 algoParams#40

Open
fmair wants to merge 1 commit into
joshuaulrich:masterfrom
fmair:39_add_algoParams_to_placeOrder
Open

fix #39 algoParams#40
fmair wants to merge 1 commit into
joshuaulrich:masterfrom
fmair:39_add_algoParams_to_placeOrder

Conversation

@fmair

@fmair fmair commented Apr 20, 2023

Copy link
Copy Markdown

By adding algoParams to placeOrder isssue #39 is resolved.

I tested the new function with an order for ES DEC 2023 with the following code and it worked as expected. Note that you'll need a running TWS version and trading access to CME futures:

library(IBrokers)

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

contract <- twsFuture(symbol = "ES",
                       exch = "CME",
                       expiry = "202312",
                       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)

Result in TWS:

image

@junyzhou10

Copy link
Copy Markdown

I also met the same issue when trying to incorporate algoParams. So I am really happy to see this post. But is the code in #40 the same as that in #39? I failed to see how to add algoParams in placeOrder()... Any hint?

@fmair

fmair commented Jul 6, 2023

Copy link
Copy Markdown
Author

You add the algoParams to the order object as above. The placeOrder function needs to be changed, see: https://github.com/joshuaulrich/IBrokers/pull/40/files. It is just one line.

@junyzhou10

Copy link
Copy Markdown

Cool!! Brilliant!! Problem solved!!

@junyzhou10

Copy link
Copy Markdown

I am exploring other IB algoStrategy in R, and got stuck. For example, for VWAP order, I read the IB API document, and trying to implement that in R with this package.

It has the following parameters which I believe should be fill in the algoParams
image

I succeed in code like

algoStrategy = "Vwap",
algoParams = c("1", "maxPctVol", "0.2")

but get no luck when trying to incorporate more parameters, for example,

algoStrategy = "Vwap",
algoParams = c("1", "maxPctVol", "0.2", 
               "2", "startTime", "09:00:00 US/Eastern")

Do you have any suggestion? I guess I might have trouble to understand what the "1" means in algoParams. Thanks!

@junyzhou10

Copy link
Copy Markdown

I got it... Key is to change the number in c("1", "maxPctVol", "0.2"). "1" means one argument specified.

For detailed example, I put it here: https://github.com/junyzhou10/IBrokers/tree/master

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

Successfully merging this pull request may close these issues.

2 participants