I seem to have boxed myself into a corner here. I added some code to my strat that says whenever the connection is lost, send an email so I know about it. I can then call my broker and get out.
That works fine in most instances when the connection is lost because the feed from my broker (NT) went down. If the connection from my server is lost, I obviously can't send myself an email.
It goes to a deeper problem. If my strat runs 24x7 I'm not up at 3 am monitoring it. If the connection is lost in the middle of the night I can end up with an open order/trade and potentially without a stop or target. This is a dangerous situation that I want to avoid. Just today I saw it happen and had to go in and flatten everything.
One thing I thought of is having a strat that does nothing but monitor itself for a re-connection. When it connects, flatten everything (assuming there was an orphan). This may or may not do much to ameliorate the issue (if the reconnection come's on 5 hours later I could have lost my butt!).
Is there a best practice (from a coding point of view) to deal with "orphan" trades? If there is a trade and no associated stop and target, then as far a I'm concerned, call the fire department!!! The problem is how to know at 3am or if I'm out running an errand. Is there a code solution (I can't see one)?
I'm sure this is not a new issue. But I would love to hear other people's ideas on this subject. Otherwise, I am going to have to scale back my strat to on run when I am sitting there to monitor it. I can't tell you how much fun that sounds like!
Thanks ... Ed
Comment