Overall Statistics |
Total Trades 8 Average Win 11.09% Average Loss -12.00% Compounding Annual Return 20.566% Drawdown 18.900% Expectancy 0.443 Net Profit 20.628% Sharpe Ratio 1.066 Probabilistic Sharpe Ratio 49.096% Loss Rate 25% Win Rate 75% Profit-Loss Ratio 0.92 Alpha 0.201 Beta -0.083 Annual Standard Deviation 0.173 Annual Variance 0.03 Information Ratio -0.05 Tracking Error 0.37 Treynor Ratio -2.229 Total Fees $12.59 Estimated Strategy Capacity $700000000.00 |
class FormalFluorescentYellowArmadillo(QCAlgorithm): def Initialize(self): self.SetStartDate(2020, 1, 1) # Set Start Date self.SetEndDate(2021, 1, 1) # Set End Date self.SetCash(100000) # Set Strategy Cash spy = self.AddEquity("SPY", Resolution.Daily) # self.AddForex, self.AddFuture... 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): if not self.spy in data: return # price = data.Bars[self.spy].Close price = data[self.spy].Close # price = self.Securities[self.spy].Close if not self.Portfolio.Invested: if self.nextEntryTime <= self.Time: self.SetHoldings(self.spy, 1) # self.MarketOrder(self.spy, int(self.Portfolio.Cash / price) ) self.Log("BUY SPY @" + str(price)) self.entryPrice = price elif self.entryPrice * 1.1 < price or self.entryPrice * 0.90 > price: self.Liquidate() self.Log("SELL SPY @" + str(price)) self.nextEntryTime = self.Time + self.period