API orders getting cancelled

Discussion in 'Interactive Brokers' started by nijshar28, Jun 3, 2020.

  1. Hi everyone. I just noticed that some of my MOC orders (placed via API in paper trading mode) did not execute and got canceled. I dug through the logs and found messages of the following form for these orders:

    [{'time': '2020-06-02T15:16:01.733084+00:00',
    'status': 'PendingSubmit',
    'message': ''},
    {'time': '2020-06-02T15:16:04.024916+00:00',
    'status': 'PreSubmitted',
    'message': ''},
    {'time': '2020-06-02T19:31:22.503361+00:00',
    'status': 'PendingCancel',
    'message': ''},
    {'time': '2020-06-02T19:31:22.562397+00:00',
    'status': 'Cancelled',
    'message': ''}]

    In contrast, this is a typical log for an order that got filled.

    [{'time': '2020-06-02T15:15:22.300838+00:00',
    'status': 'PendingSubmit',
    'message': ''},
    {'time': '2020-06-02T15:16:03.851715+00:00',
    'status': 'PreSubmitted',
    'message': ''},
    {'time': '2020-06-02T19:59:30.099333+00:00',
    'status': 'Submitted',
    'message': ''},
    {'time': '2020-06-02T19:59:30.146553+00:00',
    'status': 'Submitted',
    'message': 'Fill 132.0@15.39'},
    {'time': '2020-06-02T19:59:30.146553+00:00',
    'status': 'Filled',
    'message': ''}]

    I could not find any other info. Has anyone encountered this and knows what could be happening? I am kind of pushing it on my maintenance margin. However, I would expect there to be a warning somewhere in the logs about the margin being exceeded, and I can't seem to find any. Any thoughts? Thanks!
     
  2. d08

    d08

    Last I remember auction orders are rejected for paper trading account as they cannot be simulated. You should have an errorhandler in place to check why it was rejected (error code + msg).
     
    SPYAlgoTrader and nijshar28 like this.
  3. Open TWS and see whether you can find that order which got cancelled. Sometimes you can get additional information within TWS when hovering your mouse over it.
     
    nijshar28 likes this.
  4. Thank you. Are you using python / ib_insync by any chance?
     
  5. Great suggestion. Unfortunately, my TWS already restarted after last session, but now I will be on lookout for it.
     
  6. d08

    d08

    I'm using Python but with IbPythonic.
     
  7. Any reason you prefer it over ib_insync? I generally find ib_insync easy to use but I have not tried much else.
     
  8. d08

    d08

    I used IbPy until it was abandoned, syntax is practically identical with IbPythonic. Was the easiest transition at the time.
     
    nijshar28 likes this.
  9. Restarting TWS does not influence this. Usually you can see an overview of the order lines of the last x days. This overview persists, even if you close TWS and restart it.
    Normally I use Gateway to run my automated trading system. On occasion an order gets rejected. In those cases, and after I notice tthat something went wrong, I stop Gateway, start TWS and take a look at that order line. So in my case was TWS not even running when that order line got rejected.
     
    nijshar28 likes this.
  10. That's really cool. Can you please instruct me where to find it in TWS? I use mosaic mostly.

    Also, how do you monitor real-time performance with Gateway? Or you don't?
     
    #10     Jun 3, 2020