Overall Statistics
Total Trades
75
Average Win
0.18%
Average Loss
-2.38%
Compounding Annual Return
-54.717%
Drawdown
79.300%
Expectancy
-0.740
Net Profit
-32.628%
Sharpe Ratio
0.298
Probabilistic Sharpe Ratio
28.069%
Loss Rate
76%
Win Rate
24%
Profit-Loss Ratio
0.08
Alpha
0.443
Beta
-0.938
Annual Standard Deviation
1.396
Annual Variance
1.949
Information Ratio
0.247
Tracking Error
1.56
Treynor Ratio
-0.443
Total Fees
$79.46
class ParticleModulatedFlange(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2019, 12, 21)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        
        symbols = [ Symbol.Create("SPY", SecurityType.Equity, Market.USA) ]
        self.SetUniverseSelection( ManualUniverseSelectionModel(symbols) )
        self.UniverseSettings.Resolution = Resolution.Daily
        self.SetSecurityInitializer(self.CustomSecurityInitializer)
        
        self.AddAlpha(MyAlphaModel(symbols[0]))
        
        self.SetPortfolioConstruction(MyPCM())
        
        self.SetExecution(ImmediateExecutionModel())

    def CustomSecurityInitializer(self, security):
        security.SetLeverage(3.5)
        
        
class MyAlphaModel(AlphaModel):
    def __init__(self, symbol):
        self.symbol = symbol
    
    def Update(self, algorithm, data):
        if algorithm.Portfolio.Invested:
            return []
        return [Insight.Price(self.symbol, timedelta(365), InsightDirection.Up, None, None, None, 1)]
    
    def OnSecuritiesChanged(self, algorithm, changes):
        for added in changes.AddedSecurities:
            self.symbol = added.Symbol
            
            
class MyPCM(InsightWeightingPortfolioConstructionModel):
    def CreateTargets(self, algorithm, insights):
        targets = super().CreateTargets(algorithm, insights)
        return [PortfolioTarget(x.Symbol, x.Quantity*algorithm.Securities[x.Symbol].Leverage) for x in targets]