"You must enter a valid price" - API vs TWS

Discussion in 'Interactive Brokers' started by nooby_mcnoob, May 7, 2020.

  1. elt894

    elt894

    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.
     
    #11     May 7, 2020
  2. sprstpd

    sprstpd

    So it works as an API order through your paper trading account? Or just manual entry on your paper trading account?
     
    #12     May 7, 2020
  3. sprstpd

    sprstpd

    Another stupid idea: do you have permission to trade currencies in your live account?
     
    #13     May 7, 2020
  4. 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.
     
    #14     May 7, 2020
  5. Yes, it works as an API order through the paper account.
     
    #15     May 7, 2020
  6. 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.
     
    #16     May 7, 2020
  7. sprstpd

    sprstpd

    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.
     
    #17     May 7, 2020
  8. Your suggestions were super helpful! Solving a problem is less about finding the solution and more about brainstorming possible solutions. So your ideas were helpful.
     
    #18     May 7, 2020
  9. elt894

    elt894

    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--
     
    #19     May 7, 2020
  10. Oh interesting. I will look into that and see what that represents. Thanks!
     
    #20     May 7, 2020