Closed simonskok closed 4 years ago
Thanks for the interest in the package. I'm no expert in these types of orders, however I'd first distinguish between fields that are used to set plain TRAIL orders, which in the TWS Order ticket window appear under "Order Description", e.g.:
orderType
auxPrice
trailingPercent
trailStopPrice
...
and those used to set Adjust TRAIL orders, which in the TWS Order ticket window appear under the "Adjust Stop / Trailing Stop" section, e.g.:
adjustedOrderType
triggerPrice
adjustedStopPrice
adjustedStopLimitPrice
adjustedTrailingAmount
adjustableTrailingUnit
...
I haven't tried it, but in your case you might need to set also order.adjustedOrderType <- "TRAIL"
or similar, before the other adjusted*
fields become active.
In situations like this, what I find useful is to create first the desired order directly in TWS and then from a connected R client issue:
ic$reqAllOpenOrders()
and see which fields have been affected.
Thanks for your feedback. For some reason it is more stable to add adjustedOrderType parameter even if the order type stays the same. With regards to the adjustableTrailingUnit problem calling ic$reqAllOpenOrders()
resolved the issue as the official TWS API contains an error... adjustableTrailingUnit is 100 for percentage changes and not 1 as stated in the official docs.
Hi, thank you for writing this great package! Its the only one on Github written in R that truly provides a comprehensive connection to the IB TWS. While looking at some of the more complicated orders, I came across the following two problems. The goal is to attach a Trailing Stop Loss order and change the trailing percent parameter when a certain threshold is breached.
However, in the example below, the Trigger Price and the corresponding trailing percent is not recognised, i.e. the order is send to IB TWS, but the trigger price column is empty.
Any clues on what could cause this behaviour? The second problem is that in another example the trigger price is recognised, but it only accepts adjustableTrailingUnit = 0, which corresponds to trailing amount in nominal change, not in percentage points (adjustableTrailingUnit = 1). Contrary to the code above, this parameter always fails, i.e. attached orders with adjustableTrailingUnit = 1 are always dark in IB TWS (it displays "ticks" in the Adj_Trailing_Amount column). Going through your source sode it is not obvious why Order$adjustableTrailingUnit <- 0 is accepted whereas Order$adjustableTrailingUnit <- 1 is not. It is a small technical difficulty and the only one I haven't been able to solve by myself in an otherwise fantastic package so it would be really great if you could provide some thoughts or fixes.