Overall Statistics |
Total Trades 2 Average Win 0.76% Average Loss 0% Compounding Annual Return 7.386% Drawdown 0.000% Expectancy 0 Net Profit 0.758% Sharpe Ratio 2.641 Probabilistic Sharpe Ratio 88.940% Loss Rate 0% Win Rate 100% Profit-Loss Ratio 0 Alpha 0.06 Beta -0.025 Annual Standard Deviation 0.02 Annual Variance 0 Information Ratio -1.807 Tracking Error 0.165 Treynor Ratio -2.069 Total Fees $2.00 Estimated Strategy Capacity $45000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion MA_FAST = 12; MA_SLOW = 26; MA_SIGNAL = 9; TYPE = "Exponential" class MACD_SignalCrossover(QCAlgorithm): def Initialize(self): self.SetStartDate(2008, 1, 19) self.SetEndDate(2008, 2, 26) self.SetCash(1000) self.AddEquity("SPY", Resolution.Minute).Symbol self.macd = self.MACD("SPY", MA_FAST, MA_SLOW, MA_SIGNAL, MovingAverageType.Exponential, Resolution.Minute ) #self.macd_ema = IndicatorExtensions.EMA(self.macd, MA_SIGNAL) self.SetWarmUp(MA_SLOW*5) self.bot = False def OnData(self, data): if self.bot: return if self.IsWarmingUp: return macd = self.macd.Current.Value macd_signal = self.macd.Signal.Current.Value #macd_signal_2 = self.macd_ema.Current.Value self.Plot("MACD", "macd_signal", self.macd.Signal.Current.Value) #self.Plot("MACD", "macd_ema", self.macd_ema.Current.Value) self.Plot("MACD", "Zero", 0) if macd > macd_signal: quantity = self.CalculateOrderQuantity("SPY", 1) fill_price = self.MarketOrder("SPY", quantity).AverageFillPrice self.bot = True self.LimitOrder("SPY", -quantity, 1.01 * fill_price)