Use the API to disable manual orders sent to TWS

Discussion in 'Interactive Brokers' started by Trade Prophet, Oct 16, 2021.

  1. Hi all,
    Does anyone know how to disable manual orders executing on TWS using the API? Can I somehow shutdown manual trading in TWS by a command from the API?
    Thanks.
     
  2. d08

    d08

    Maybe two accounts, one for API and orders, other will have no trading rights.
     
  3. I have a client who trades multiple accounts manually, sometimes he wants to stop trading on one of them when a specific condition is there,
    but in the heat of trading, he forgets that he is not supposed to trade that account,
    I offered help but was unable to find a way to disable manual trading in a specific account, that's my challenge
     
  4. d08

    d08

    What are the conditions? You can monitor the API for conditions and send a kill (or freeze?) signal to a TWS client.
     
  5. The condition is a daily drawdown, that part is easy
    a kill signal is too violent... I was thinking the API might have a switch to "Read Only" mode or something similar...
     
  6. d08

    d08

    Kill stop with continue should work.
     
    Trade Prophet likes this.
  7. I don't know whether it is possible to use the API to prevent trades being placed via TWS (i.e. blocking manual trades). However, it is possible to use the API to cancel orders which have been placed via TWS. But this is after the fact, after those orders have been placed.
     
  8. d08

    d08

    There's a cost associated with a large number of cancellations and some orders cannot be cancelled at all (auction lockups). Would work only in edge cases.
     
  9. The API won't serve you for this task. You want to enable read-only mode on TWS when your conditions are met.

    My guess is that you have to create a script to run TWS, that will replace the current launcher, and a service to listen to your conditions on the OS.

    Both, the script and the OS service will check your conditions before starting TWS, so you can enable the read-only mode.

    The tricky part will be to shutdown TWS if it is running already, that will be a job for the OS service.

    There are many libraries to start the IB gateway with a script, you could use them to start TWS. Try IBcontroller and similar libraries.
     
    Trade Prophet likes this.
  10. jharmon

    jharmon

    This guy needs to work on his personal psychology. If he can't figure out how to stop trading when rules have been clearly defined, he's more like an addict.
     
    #10     Oct 18, 2021