Overall Statistics |
Total Trades 46 Average Win 10.90% Average Loss -11.04% Compounding Annual Return 9.747% Drawdown 22.400% Expectancy 0.469 Net Profit 229.207% Sharpe Ratio 0.619 Probabilistic Sharpe Ratio 4.335% Loss Rate 26% Win Rate 74% Profit-Loss Ratio 0.99 Alpha 0.011 Beta 0.681 Annual Standard Deviation 0.12 Annual Variance 0.014 Information Ratio -0.224 Tracking Error 0.082 Treynor Ratio 0.109 Total Fees $202.74 Estimated Strategy Capacity $970000000.00 Lowest Capacity Asset SPY R735QTJ8XC9X |
# region imports from AlgorithmImports import * # endregion class spy_algo_1(QCAlgorithm): def Initialize(self): self.SetStartDate(2010, 1, 1) self.SetCash(100000) spy = self.AddEquity("SPY", Resolution.Daily) spy.SetDataNormalizationMode(DataNormalizationMode.Raw) self.spy = spy.Symbol self.SetBenchmark("SPY") self.SetBrokerageModel(BrokerageName.InteractiveBrokersBrokerage, AccountType.Margin) self.EntryPrice = 0 self.period = timedelta(31) self.nextEntryTime = self.Time def OnData(self, data: Slice): if not self.spy in data: return price = data[self.spy].Close if not self.Portfolio.Invested: if self.nextEntryTime <= self.Time: # self.MarketOrder(self.spy, int(self.Portfolio.Cash / Price) self.SetHoldings("SPY", 1) self.Log("BUY SPY @" + str(price)) self.entryPrice = price elif self.entryPrice * 1.1 < price or self.entryPrice * 0.9 > price: self.Liquidate(self.spy) self.Log("SELL SPY @" + str(price)) self.nextEntryTime = self.Time + self.period