Overall Statistics
Total Trades
37
Average Win
4.05%
Average Loss
-1.77%
Compounding Annual Return
7.534%
Drawdown
16.900%
Expectancy
0.739
Net Profit
24.338%
Sharpe Ratio
0.516
Probabilistic Sharpe Ratio
15.027%
Loss Rate
47%
Win Rate
53%
Profit-Loss Ratio
2.28
Alpha
0.062
Beta
0.158
Annual Standard Deviation
0.113
Annual Variance
0.013
Information Ratio
0.34
Tracking Error
0.233
Treynor Ratio
0.369
Total Fees
$37.00
Estimated Strategy Capacity
$4400000.00
Lowest Capacity Asset
BND TRO5ZARLX6JP
class MomentumBasedTacticalAllocation(QCAlgorithm):
    
    def Initialize(self):
        
        self.SetStartDate(2007, 8, 1) 
        self.SetEndDate(2010, 8, 1)  
        self.SetCash(3000)  
        
        self.spy = self.AddEquity("SPY", Resolution.Daily)  
        self.bnd = self.AddEquity("BND", Resolution.Daily)  
      
        self.spyMomentum = self.MOMP("SPY", 50, Resolution.Daily) 
        self.bondMomentum = self.MOMP("BND", 50, Resolution.Daily) 
       
        self.SetBenchmark(self.spy.Symbol)  
        self.SetWarmUp(50) 
  
    def OnData(self, data):
        
        if self.IsWarmingUp:
            return
        
        #1. Limit trading to happen once per week
        if not self.Time.weekday() == 1:
            return
        
        if self.spyMomentum.Current.Value > self.bondMomentum.Current.Value:
            self.Liquidate("BND")
            self.SetHoldings("SPY", 1)
            
        else:
            self.Liquidate("SPY")
            self.SetHoldings("BND", 1)