Red alert, stop trading

Discussion in 'Automated Trading' started by nooby_mcnoob, Feb 23, 2018.

  1. Portions of my log file look something like this:

    YYYY-MM-DD HH:MM:SS,mmm;DEBUG;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26>
    YYYY-MM-DD HH:MM:SS,mmm;DEBUG;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26>
    YYYY-MM-DD HH:MM:SS,mmm;DEBUG;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26>
    YYYY-MM-DD HH:MM:SS,mmm;DEBUG;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26>
    YYYY-MM-DD HH:MM:SS,mmm;DEBUG;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26>
    YYYY-MM-DD HH:MM:SS,mmm;DEBUG;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26>

    In the case of an order or trade:

    YYYY-MM-DD HH:MM:SS,mmm;INFO;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26> Trade opened
    YYYY-MM-DD HH:MM:SS,mmm;INFO;YYYY-MM-DD HH:MM:SS #<O (X=2.27),P=2.26> Trade closed. Net: Y

    For now, I want to monitor 3 things:

    1. Am I updating values for X and P -> Need notification if fails to update for some reason
    2. When a trade is opened and a trade is closed -> Need notification on either event
    3. If, for some reason the algo process exits -> "Trading done" message

    I already have this done, but it is cloud agnostic and works with one command :D
     
    Last edited: Feb 24, 2018
    #41     Feb 24, 2018
  2. You need to thoroughly understand and trust your front end. In my case, if things get out of whack:

    1. Direct my front end to completely disconnect from IB, which simultaneously disables all automation/trade management.

    2. Use the IB “Close All Positions” feature. This instantly flattens out the account.
    https://www.interactivebrokers.com/...book/thetradingwindow/close_all_positions.htm

    I rarely ever have problems that dictate these measures. It’s all about front end stability and power/internet reliability.
     
    #42     Feb 24, 2018
  3. zzulus

    zzulus

    2. Use the IB “Close All Positions” feature. This instantly flattens out the account.
    IO is expensive af, hope you are using SSD and async logging.

    1. It makes sense to implement 1 as part of your order validation pipeline.

    2. Overall looks like you need a log tail nanny process. It should read your log file, match trades and validate whatever conditions you set.

    As for 3 you can either just do the "Trading done", or you can have a more advanced architecture with several trading processes and the coordinator, the coordinator monitors the state of the child processes and decide which one is active. If the active process dies for some reason, the coordinator switches one of passive traders to active state and instruct it to take over existing trades. Or the coordinator can be the one taking and executing orders, similar to LMAX shadow execution architecture.
     
    #43     Feb 24, 2018
  4. Canoe007

    Canoe007

    Blast from the past.
    A Stop All Trading Button was the very first thing I coded
     
    #44     Feb 24, 2018
    nooby_mcnoob likes this.
  5. Lee17

    Lee17

    I think every broker would have a mechanism to close all the deals on behalf of its client in case of a request and it could even be a regulatory mandate from risk management perspective.
     
    #45     Feb 27, 2018
    nooby_mcnoob likes this.
  6. Only if the algorithm is going to be affected by such considerations. Mine is not (yet!)

    Exactly! I'm looking at fluentd
     
    #46     Feb 27, 2018
  7. I have an equity drawdown warning and then after the my charts shut down ending my EA algorithm, I handle things after that
     
    #47     Mar 1, 2018
  8. It's really annoying that the market has to push things so far every so often to cause this upset, the forex market is the worst for extreme conditions
     
    #48     Mar 1, 2018