Overall Statistics
Total Trades
84
Average Win
0.04%
Average Loss
-0.07%
Compounding Annual Return
-7.077%
Drawdown
12.900%
Expectancy
-0.897
Net Profit
-2.619%
Sharpe Ratio
-0.19
Probabilistic Sharpe Ratio
21.763%
Loss Rate
93%
Win Rate
7%
Profit-Loss Ratio
0.51
Alpha
-0.044
Beta
0.087
Annual Standard Deviation
0.207
Annual Variance
0.043
Information Ratio
-0.313
Tracking Error
0.28
Treynor Ratio
-0.452
Total Fees
$84.59
Estimated Strategy Capacity
$460000000.00
import clr
clr.AddReference("System")
clr.AddReference("QuantConnect.Algorithm")
clr.AddReference("QuantConnect.Indicators")
clr.AddReference("QuantConnect.Common")
from System import *
from QuantConnect import *
from QuantConnect.Algorithm import *
from QuantConnect.Indicators import *
import decimal as d

class QQQAlert(QCAlgorithm):

    def Initialize(self):
        self.symbol = "QQQ"
        self.fast_sma_period = 1
        self.slow_sma_period = 200
        
        
        self.SetStartDate(2021, 1, 1)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        self.resolution = Resolution.Daily
        self.AddEquity(self.symbol, self.resolution)
        
        
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())
        
        self.SetWarmUp(self.slow_sma_period)
        self.fast_sma = self.SMA(self.symbol, self.fast_sma_period, self.resolution)
        self.slow_sma = self.SMA(self.symbol, self.slow_sma_period, self.resolution)
        
        self.SetBenchmark(self.symbol)
        
        coinPlot = Chart('Strategy Equity')
        # On the Trade Plotter Chart we want 3 series: trades and price:
        coinPlot.AddSeries(Series('Benchmark', SeriesType.Line, 0))
        coinPlot.AddSeries(Series('Fast SMA', SeriesType.Line, 0))
        coinPlot.AddSeries(Series('Slow SMA', SeriesType.Line, 0))
        
    def OnData(self, data):
        
        if not self.slow_sma.IsReady:
            return
        
        currentPrice = self.Securities[self.symbol].Close
        
        weight = 1
        if currentPrice > self.fast_sma.Current.Value:
            insight = Insight.Price(self.symbol, timedelta(days=25), InsightDirection.Up, None, None, None, weight) # manual insight emission
            self.EmitInsights(insight)
        else:
            insight = Insight.Price(self.symbol, timedelta(days=25), InsightDirection.Down, None, None, None, weight) # manual insight emission
            self.EmitInsights(insight)
            
        self.Plot('Strategy Equity', 'Benchmark', self.Securities[self.symbol].Price)
        self.Plot('Strategy Equity', 'Fast SMA', self.slow_sma.Current.Value)
        self.Plot('Strategy Equity', 'Slow SMA', self.fast_sma.Current.Value)