Overall Statistics |
Total Trades 36 Average Win 16.89% Average Loss -5.35% Compounding Annual Return 11.573% Drawdown 33.900% Expectancy 2.670 Net Profit 851.010% Sharpe Ratio 0.771 Probabilistic Sharpe Ratio 9.429% Loss Rate 12% Win Rate 88% Profit-Loss Ratio 3.16 Alpha 0.107 Beta -0.033 Annual Standard Deviation 0.135 Annual Variance 0.018 Information Ratio 0.137 Tracking Error 0.227 Treynor Ratio -3.16 Total Fees $36.00 |
class MomentumBasedTacticalAllocation(QCAlgorithm): def Initialize(self): self.SetStartDate(2000, 8, 1) #self.SetEndDate(2021, 8, 1) self.SetCash(3000) self.spy = self.AddEquity("SPY", Resolution.Daily) self.bnd = self.AddEquity("TLT", Resolution.Daily) self.spyMomentum = self.MOMP("SPY", 100, Resolution.Daily) self.bondMomentum = self.MOMP("TLT", 100, 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() == 0: return if self.spyMomentum.Current.Value > 0:#self.bondMomentum.Current.Value: self.Liquidate("TLT") self.SetHoldings("SPY", 1) else: self.Liquidate("SPY") self.SetHoldings("TLT", 1)