Overall Statistics |
Total Trades 612 Average Win 0.05% Average Loss -0.05% Compounding Annual Return -53.452% Drawdown 12.100% Expectancy -0.596 Net Profit -11.758% Sharpe Ratio -10.397 Probabilistic Sharpe Ratio 0% Loss Rate 80% Win Rate 20% Profit-Loss Ratio 0.98 Alpha 0 Beta 0 Annual Standard Deviation 0.04 Annual Variance 0.002 Information Ratio -10.397 Tracking Error 0.04 Treynor Ratio 0 Total Fees $2105.30 Estimated Strategy Capacity $71000000.00 Lowest Capacity Asset ZF MD |
class SmoothApricotCaribou(QCAlgorithm): def Initialize(self): self.SetStartDate(2019, 1, 1) # Set Start Date self.SetEndDate(2019, 3, 1) self.SetCash(50000) # Set Strategy Cash # self.AddEquity("SPY", Resolution.Minute) self.y5treasurynote = self.AddFuture(Futures.Financials.Y5TreasuryNote) self.slowema = self.EMA(self.y5treasurynote.Symbol, 21, Resolution.Minute) self.fastema = self.EMA(self.y5treasurynote.Symbol, 9, Resolution.Minute) self.Schedule.On(self.DateRules.EveryDay(self.y5treasurynote.Symbol), self.TimeRules.At(13, 00), self.ClosePositions) self.Schedule.On(self.DateRules.EveryDay(self.y5treasurynote.Symbol), self.TimeRules.Every(timedelta(hours=1)), self.PlotEMAs) self.SetBenchmark(self.y5treasurynote.Symbol) self.SetWarmup(30) def OnData(self, data): if not self.slowema.IsReady: return if not self.fastema.IsReady: return self.Debug("EMAs are ready.") if self.Time.hour >= 9 and self.Time.hour <= 12: self.Debug(f"Time is between 9h and 12h inclusive. Time is: {self.Time}") if not self.Portfolio.Invested: if self.fastema.Current.Value > self.slowema.Current.Value: self.MarketOrder(self.y5treasurynote.Symbol, 1) elif self.fastema.Current.Value < self.slowema.Current.Value: self.MarketOrder(self.y5treasurynote.Symbol, -1) elif self.Portfolio[self.y5treasurynote.Symbol].Quantity > 0: if self.fastema.Current.Value < self.slowema.Current.Value: self.MarketOrder(self.y5treasurynote.Symbol, -2) elif self.Portfolio[self.y5treasurynote.Symbol].Quantity < 0: if self.fastema.Current.Value > self.slowema.Current.Value: self.MarketOrder(self.y5treasurynote.Symbol, 2) else: pass def ClosePositions(self): self.Liquidate(self.y5treasurynote.Symbol) def PlotEMAs(self): self.Plot("EMAs", "Fast", self.fastema.Current.Value) self.Plot("EMAs", "Slow", self.slowema.Current.Value)