Back to Community
Power outage - question


What would happen if there is a power outage?

If there is an open trade, and you have a Stop programmed with algorithm. Will the Stop (or a Profit taken) be triggered?

From what I understood, reading on this site, you have to restart the algorithm, but... in the process... ?



4 responses

Does somebody have an answer for me : that would be great. Even if I'm a beginner, I'm doing my best to read as much material that I can. I didn't see anything on this...

Thanks in advance


Any idea on this? Somebody

All the algorithms are run 'in the cloud'. Once you start or 'deploy' them they run on their own completely independent of your local machine. As a practical matter there will never be a 'power outage'. The data centers running the hardware have that possibility covered pretty well with UPS systems.

Now, there are other reasons an algorithm can stop. A bug in one's code probably tops the list. There have been occasions where Quantopian had some database issues and all the algorithms needed to be restarted.

It's generally a good idea to make your code 'stateless' and not depend upon any stored variables. (at least stored for more than a day). Put any code to re-initialize things in the 'initialize' method. The algorithm should just look at your portfolio positions and current data and continue trading. That way it can always be restarted and pick up where you left off. The worst that might happen is you wouldn't make a trade in a timely manner. All your current positions remain (ie any stock you own is still there). Any orders that you placed are still out there (though all orders get canceled at the end of the day anyway). In reality, if missing some trades is an issue with your strategy, then it's not a very robust, or even realistic, strategy.

"If there is an open trade, and you have a Stop programmed with algorithm. Will the Stop (or a Profit taken) be triggered?". By 'open trade' I assume you mean an 'open position'. You purchased a stock (long or short) and now you have an open position. By 'stop programmed' I assume your algorithm is checking for some condition(s) before then placing an order to 'close' that position. If your algorithm, for some reason, is not running (remember its in the cloud) then it can't do any checks and won't place any orders to close your positions. The simplest is to have your algorithm look for any open positions on restart and carry on just as if nothing happened. One other technique is to enter an order to close the position immediately after it is opened. Enter a stop or limit order immediately. This will then remain an open order with the broker and NOT be impacted if the algorithm stops. (All orders are canceled at the end of the day though and would need to be re-entered the next day if needed).

Thank you so much for your answer : it's helpful!