erdewit / ib_insync

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

Error when performing a Trail Limit order on Windows #88

Closed jecepeda closed 6 years ago

jecepeda commented 6 years ago

Hi,

I was just testing ib_insync on windows and there is an error when when performing a TRAIL LIMIT order on Windows which does not happen on my Linux machine.

This is the order I try to perform:

trail_order = Order()
trail_order.orderType = 'TRAIL LIMIT'
trail_order.totalQuantity = 100
trail_order.action = 'SELL'
trail_order.lmtPriceOffset = 5e-4
trail_order.trailStopPrice = 1.155
trail_order.auxPrice = 5e-3
trail_order.lmtPrice = 1.155 - 5e-4

In principle there is no reason to have an error, but when I execute:

app.placeOrder(contract, trail_order)

And i check the order with whatIfOrder, there is this output:

ERROR:ib_insync.wrapper:Error 321, reqId 56: Error validating request:-'bE' : cause - You must specify one value: limit price or limit price offset value., contract: Contract(secType='CASH', symbol='EUR', exchange='IDEALPRO', currency='USD')

If I remove lmtPrice, the order is submitted but the trail limit is not updated. However, this does not happen on Linux. On Linux the message says: OrderState(status='PreSubmitted', initMargin='1.7976931348623157E308', maintMargin='1.7976931348623157E308', equityWithLoan='1.7976931348623157E308', warningText='Important Note: Your order size is below the EUR 20000 IdealPro minimum.\nYou may cancel and increase the order size if you wish to route to IdealPro\nor select the Transmit button to route as an odd lot order.\nNote that odd lot orders are not guaranteed executions at the IdealPro displayed quotes.') Which I see reasonable.

Have this happened to any of you? I'm willing to help if necessary

The versions used of TWS are:

jecepeda commented 6 years ago

Update: after talking with Interactive Brokers support and trying some things, I've found the following things:

The problem with the second option is that you must deactivate some field inside TWS and it does not work by default

I'm sorry for opening this issue. I hope this is useful to the next person who is faced with this problem. I proceed to close the issue.

Regards