Red alert, stop trading

Elastic Search? I don't know what you are looking for, but I guess that is not it.

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

If you want to have a remote kill switch, then SQS or its analogue from Azure / Google Cloud is what you can use. Halt all your trading workflows and initiate the liquidation.

I already have this done, but it is cloud agnostic and works with one command :D
 
Last edited:
You want to shut down all trading and liquidate. How would you do this?
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.
 
2. Use the IB “Close All Positions” feature. This instantly flattens out the account.
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>
IO is expensive af, hope you are using SSD and async logging.

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
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.
 
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.
 
IO is expensive af, hope you are using SSD and async logging.

Only if the algorithm is going to be affected by such considerations. Mine is not (yet!)

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.

Exactly! I'm looking at fluentd
 
I have an equity drawdown warning and then after the my charts shut down ending my EA algorithm, I handle things after that
 
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
 
Back
Top