Overall Statistics |
Total Trades 36 Average Win 4.06% Average Loss -1.75% Compounding Annual Return 7.664% Drawdown 16.700% Expectancy 0.761 Net Profit 24.799% Sharpe Ratio 0.525 Probabilistic Sharpe Ratio 15.413% Loss Rate 47% Win Rate 53% Profit-Loss Ratio 2.33 Alpha 0.062 Beta 0.157 Annual Standard Deviation 0.112 Annual Variance 0.013 Information Ratio 0.339 Tracking Error 0.233 Treynor Ratio 0.375 Total Fees $36.00 Estimated Strategy Capacity $4400000.00 Lowest Capacity Asset BND TRO5ZARLX6JP |
from AlgorithmImports import * 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 self.Time.weekday() == 1: if self.spyMomentum.Current.Value > self.bondMomentum.Current.Value: self.Liquidate("BND") self.SetHoldings("SPY", 1) else: self.Liquidate("SPY") self.SetHoldings("BND", 1)