That's the full example, if you were willing to try! You can just have your boilerplate code and enter the order exactly as given above but replace the orderId with 80085 (or some other unused order id).
I tried your idea about setting other fields. I am nearly 100% sure this is a floating point issue on TWS side like you suggested, nothing else really makes sense except... why does it work properly with the paper trading account?
It worked for me.
Can you set order.transmit = False and check in TWS if anything looks off? Can it then be submitted through TWS?
Another thing to try would be to create the order in TWS, and then retrieve it with the API and compare all the fields.
nextOrderId += 1
contract = Contract()
contract.symbol="USD"
contract.secType="CASH"
contract.currency="CAD"
contract.exchange="IDEALPRO"
order = Order()
order.orderId=nextOrderId
order.account="****"
order.action="SELL"
order.orderType="LMT"
order.totalQuantity=50000
order.lmtPrice=1.41675
order.transmit = False
# OK FINE
conn.placeOrder(contract,order)
# WTF
import time
time.sleep(0.25)
# WTF
order.transmit = True
conn.placeOrder(contract,order)
So it works as an API order through your paper trading account? Or just manual entry on your paper trading account?
Well...
In the land of retards, joe blow is king.
The above fixes the problem in production and on the live account.
Why?
Fuck if I know.
Maybe look at the API logs for today and see if you can figure out a reason for it not working originally. You might have to turn on an option for the logs to be generated:
https://interactivebrokers.github.io/tws-api/support.html
Maybe it was the order id you were using?
I'm glad all of my suggestions turned out to be stupid, just like I thought they would be.
Brilliant idea.
I tried this and there was no difference...
Except I accidentally submitted the same order again and guess what...
It worked.
Here is the full test case that now works for me:
Code:nextOrderId += 1 contract = Contract() contract.symbol="USD" contract.secType="CASH" contract.currency="CAD" contract.exchange="IDEALPRO" order = Order() order.orderId=nextOrderId order.account="****" order.action="SELL" order.orderType="LMT" order.totalQuantity=50000 order.lmtPrice=1.41675 order.transmit = False # OK FINE conn.placeOrder(contract,order) # WTF import time time.sleep(0.25) # WTF order.transmit = True conn.placeOrder(contract,order)
WOW.
That's bizarre, but glad you've got a workaround. FWIW, the line below is the API log entry for my order that worked directly. The only difference from yours is that bolded 'O' before the string of zeros and ones.
11:29:37:034 <- 3-10-0-USD-CASH--0.0---IDEALPRO--CAD-----SELL-50000-LMT-1.41675-----O-0--1-0-0-0-0-0-0-0--0--------0---1-0---0---1-1--0------0-----0-----------0---0-0---0--0-0-0-0--1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-1.7976931348623157e+308-0----1.7976931348623157e+308-----0-0-0--