Hey QC forum

I coded up an algorithm, based on the QC framework (The alpha is taken from GitHub, and modified a bit). I am having trouble with my risk module because it takes a REALLY long time to compute and finish the backtest (24 hr for 2 years). The risk module is supposed to liquidate all of the holdings, as soon as SPY falls under the moving average. Without the risk module, the backtest does not take too long. 

Any way of optimizing the risk module, or in any way of making it faster? Maybe there are some bugs that I have been missing.

As always, thank you very much!

Lucas