Overall Statistics
Total Trades
0
Average Win
0%
Average Loss
0%
Compounding Annual Return
0%
Drawdown
0%
Expectancy
0
Net Profit
0%
Sharpe Ratio
0
Probabilistic Sharpe Ratio
0%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0
Beta
0
Annual Standard Deviation
0
Annual Variance
0
Information Ratio
0.965
Tracking Error
0.13
Treynor Ratio
0
Total Fees
$0.00
class TransdimensionalOptimizedChamber(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2021, 1, 9)  # Set Start Date
        self.SetCash(100000)  # Set Strategy Cash
        
        tickers = ["SPY"]
        symbols = [Symbol.Create(ticker, SecurityType.Equity, Market.USA) for ticker in tickers]
        self.AddUniverseSelection(ManualUniverseSelectionModel(symbols))
        self.UniverseSettings.Resolution = Resolution.Daily
        
        self.AddAlpha(A1())
        self.AddAlpha(A2())
        
        self.SetPortfolioConstruction(PCM())
        
        self.SetExecution(ImmediateExecutionModel())


class A1(AlphaModel):
    Name = 'A1'
    symbols = set([])
    
    def Update(self, algorithm, data):
        insights = []
        for symbol in self.symbols:
            insights.append(Insight.Price(symbol, timedelta(days=1), InsightDirection.Up))
        return insights
    
    def OnSecuritiesChanged(self, algorithm, changes):
        for security in changes.AddedSecurities:
            self.symbols.add(security.Symbol)
        for security in changes.RemovedSecurities:
            self.symbols.remove(security.Symbol)
            
class A2(AlphaModel):
    Name = 'A2'
    symbols = set([])
    
    def Update(self, algorithm, data):
        insights = []
        for symbol in self.symbols:
            insights.append(Insight.Price(symbol, timedelta(days=1), InsightDirection.Down))
        return insights
    
    def OnSecuritiesChanged(self, algorithm, changes):
        for security in changes.AddedSecurities:
            self.symbols.add(security.Symbol)
        for security in changes.RemovedSecurities:
            self.symbols.remove(security.Symbol)
            
class PCM(PortfolioConstructionModel):
    performance_by_alpha = {}
    
    # Create list of PortfolioTarget objects from Insights
    def CreateTargets(self, algorithm, insights):
        for insight in insights:
            algorithm.Log(f"Insight from {insight.SourceModel} at {algorithm.Time}")
            
            if insight.SourceModel not in self.performance_by_alpha:
                self.performance_by_alpha[insight.SourceModel] = AlphaPerformanceTracker()
            self.performance_by_alpha[insight.SourceModel].Update(algorithm, insight)
            
        return []
    
    # OPTIONAL: Security change details
    def OnSecuritiesChanged(self, algorithm, changes):
        pass
    
class AlphaPerformanceTracker:

    def Update(self, insight, algorithm):
        # Simluate entry/exit trades
        
        pass