Overall Statistics
Total Trades
128
Average Win
0.26%
Average Loss
-0.02%
Compounding Annual Return
8.710%
Drawdown
18.300%
Expectancy
11.994
Net Profit
55.577%
Sharpe Ratio
0.948
Probabilistic Sharpe Ratio
41.843%
Loss Rate
8%
Win Rate
92%
Profit-Loss Ratio
13.11
Alpha
0.048
Beta
0.446
Annual Standard Deviation
0.098
Annual Variance
0.01
Information Ratio
-0.062
Tracking Error
0.115
Treynor Ratio
0.207
Total Fees
$167.24
class SPYTLT6040InsightWeighted(QCAlgorithm):

    def Initialize(self):
        
        self.SetStartDate(2015, 1, 1)  # Set Start Date
        self.SetCash(1000000)  # Set Strategy Cash
        
        self.trigger = False
        self.Settings.RebalancePortfolioOnInsightChanges = False
        self.Settings.RebalancePortfolioOnSecurityChanges = True
        
        self.spy = self.AddEquity("SPY", Resolution.Minute).Symbol
        self.tlt = self.AddEquity("TLT", Resolution.Minute).Symbol
        
        self.SetBenchmark('SPY')
        
        # Scheduled event
        self.Schedule.On(self.DateRules.MonthStart(self.spy), self.TimeRules.AfterMarketOpen(self.spy, 5), self.emitNewInsights)
        
        # Use the Alpha Streams Brokerage Model
        self.SetBrokerageModel(AlphaStreamsBrokerageModel())
        
        # Immediate execution model
        self.SetExecution(ImmediateExecutionModel())

        # Insight Weighted portfolio construction
        self.SetPortfolioConstruction(InsightWeightingPortfolioConstructionModel(self.RebalanceFunction, PortfolioBias.Long))



    def emitNewInsights(self):
        
        insights = []
        
        # Up insight for SPY with weight 60%
        insights.append(Insight.Price(self.spy, timedelta(days=35), InsightDirection.Up, None, None, None, 0.6))
        
        # Up insight for TLT with weight 40%
        insights.append(Insight.Price(self.tlt, timedelta(days=35), InsightDirection.Up, None, None, None, 0.4))
        
        self.trigger = True
        self.EmitInsights(insights)



    def RebalanceFunction(self, time):
        
        if self.trigger:
            self.trigger = False
            return time
            
        return None