Overall Statistics
Total Trades
5799
Average Win
0.06%
Average Loss
-0.04%
Compounding Annual Return
11.932%
Drawdown
22.000%
Expectancy
1.180
Net Profit
341.162%
Sharpe Ratio
1.052
Probabilistic Sharpe Ratio
50.325%
Loss Rate
15%
Win Rate
85%
Profit-Loss Ratio
1.57
Alpha
0.106
Beta
-0.033
Annual Standard Deviation
0.097
Annual Variance
0.009
Information Ratio
0.02
Tracking Error
0.216
Treynor Ratio
-3.152
Total Fees
$5806.40
from datetime import timedelta

class MyAlphaModel(AlphaModel):
    def __init__(self):
        self.symbols = []

    def OnSecuritiesChanged(self, algorithm, changes):
        for security in changes.AddedSecurities:
            symbol = security.Symbol
            if symbol not in self.symbols:
                self.symbols.append(symbol)

        for security in changes.RemovedSecurities:
            symbol = security.Symbol
            if symbol in self.symbols:
                self.symbols.remove(symbol)

    def Update(self, algorithm, data):
        insights = []
        for symbol in self.symbols:
            insights.append(Insight.Price(symbol, timedelta(1), InsightDirection.Up))
            
        return insights


class EqualPortfolio(QCAlgorithm):
    
    def Initialize(self):
        self.SetStartDate(2008, 1, 1)     
        self.SetCash(100000)  

        _symbols = ["QQQ", "TLT"]
        
        self.SetUniverseSelection(CustomUniverseSelectionModel('CustomUniverseSelectionModel', lambda time:_symbols))    
        self.UniverseSettings.Resolution = Resolution.Daily
        self.SetAlpha(MyAlphaModel())
        self.SetPortfolioConstruction(EqualWeightingPortfolioConstructionModel())
        self.SetExecution(ImmediateExecutionModel())