Overall Statistics
Total Trades
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
42.370%
Drawdown
8.400%
Expectancy
0
Net Profit
19.729%
Sharpe Ratio
2.165
Probabilistic Sharpe Ratio
73.447%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.398
Beta
-0.113
Annual Standard Deviation
0.163
Annual Variance
0.027
Information Ratio
-0.185
Tracking Error
0.262
Treynor Ratio
-3.132
Total Fees
$1.00
from datetime import timedelta

class OptimizedMultidimensionalAtmosphericScrubbers(QCAlgorithm):
    
    #
    # buy when the SMA-200 > SMA-50
    # sell when the SMA-200 < SMA-50
    #

    def Initialize(self):
        self.SetStartDate(2020, 5, 9)
        self.SetCash(1000)  
        self.equity = self.AddEquity("SPY", Resolution.Daily)
        self.symbol = self.equity.Symbol
        
        # warm up and create our SMA indicators
        self.SetWarmUp(200)
        self.sma_50 = self.SMA(self.symbol, 50, Resolution.Daily)
        self.sma_200 = self.SMA(self.symbol, 200, Resolution.Daily)
        
        # setup the chart
        my_chart = Chart("Indicator Chart")
        my_chart.AddSeries(Series("SMA50", SeriesType.Line, 0))
        my_chart.AddSeries(Series("SMA200", SeriesType.Line, 0))
        self.AddChart(my_chart)
        
        
        # alternative plotting method
        self.PlotIndicator("Indicators", self.sma_50)
        self.PlotIndicator("Indicators", self.sma_200)

    def OnData(self, data):
        if not self.sma_50.IsReady or not self.sma_200.IsReady:
            return
        
        self.Plot("Indicator Chart", "SMA50", self.sma_50.Current.Value)
        self.Plot("Indicator Chart", "SMA200", self.sma_200.Current.Value)
    
    def OnWarmupFinished(self):
        if not self.Securities[self.symbol].Invested:
            self.SetHoldings(self.symbol, 1.0)