erdewit / ib_insync

Python sync/async framework for Interactive Brokers API
BSD 2-Clause "Simplified" License
2.85k stars 772 forks source link

Ib_insync - Trail Limit Order #662

Closed ingelrii closed 11 months ago

ingelrii commented 12 months ago

Hello, I've been searching in the library and the posts if it is possible to submit a trail limit order in ib_insync, but I don't find anything. Can someone help me and tell me if there is any way to do it. Thank you very much,

mattsta commented 11 months ago

The basic order types are defined in the IBKR docs here: https://interactivebrokers.github.io/tws-api/basic_orders.html

It works as the docs say for a trailing stop limit:

order = Order()
order.action = action
order.orderType = "TRAIL LIMIT"
order.totalQuantity = quantity
order.trailStopPrice = trailStopPrice
order.lmtPriceOffset = lmtPriceOffset
order.auxPrice = trailingAmount

Then you submit the order the normal way by combining your qualified contract with your order definition.

ingelrii commented 11 months ago

Very helpful. Thank you very much @mattsta!!