Overall Statistics |
Total Trades 81 Average Win 0.10% Average Loss -0.20% Compounding Annual Return -0.470% Drawdown 5.600% Expectancy -0.655 Net Profit -5.497% Sharpe Ratio -0.982 Probabilistic Sharpe Ratio 0.000% Loss Rate 78% Win Rate 22% Profit-Loss Ratio 0.53 Alpha -0.001 Beta -0.02 Annual Standard Deviation 0.003 Annual Variance 0 Information Ratio -0.805 Tracking Error 0.144 Treynor Ratio 0.159 Total Fees $81.00 Estimated Strategy Capacity $16000000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
from AlgorithmImports import * # endregion class UpgradedYellowScorpion(QCAlgorithm): stopMarketTicket = None stopMarketOrderFillTime = datetime.min highestSPYPrice = -1 def Initialize(self): self.SetStartDate(2010, 1, 1) self.SetEndDate(2022, 1, 1) self.SetCash(10000) spy = self.AddEquity("SPY" , Resolution.Daily) spy.SetDataNormalizationMode(DataNormalizationMode.Raw) self.Pair = "SPY" self.symbols = [self.Pair] self.prevPrices = { symbol : RollingWindow[TradeBar](7) for symbol in self.symbols } self.Long = None self.Short = None def OnData(self, data): self.Plot("Indicator", "Price", self.Securities["SPY"].Price) self.Plot("Indicator", "high", self.highestSPYPrice) self.Plot("Indicator", "updated", self.highestSPYPrice * 1.05) for symbol in self.symbols: if data.ContainsKey(symbol): self.prevPrices[symbol].Add( data[symbol] ) if not all([ window.IsReady for window in self.prevPrices.values() ]): return Pair1_window = self.prevPrices[self.Pair] Pair1_1D = Pair1_window[1].Close Pair1_0D = Pair1_window[0].Close self.Plot("Indicator", "1d", Pair1_1D) self.Plot("Indicator", "0d", Pair1_0D) if Pair1_0D > Pair1_1D: self.highestSPYPrice = Pair1_0D # short position if not self.Portfolio.Invested and Pair1_0D > Pair1_1D: self.Short = self.MarketOrder("SPY", -1) self.stopMarketTicket = self.StopMarketOrder("SPY", 1, 1.05 * self.Securities["SPY"].Close) if self.Short is not None and self.Securities["SPY"].Close < self.highestSPYPrice: self.highestSPYPrice = self.Securities["SPY"].Close updateFields = UpdateOrderFields() updateFields.StopPrice = self.highestSPYPrice * 1.05 self.stopMarketTicket.Update(updateFields) def OnOrderEvent(self, orderEvent): if orderEvent.Status != OrderStatus.Filled: return if self.stopMarketTicket is not None and self.stopMarketTicket.OrderId == orderEvent.OrderId: self.stopMarketOrderFillTime = self.Time