Overall Statistics |
Total Trades 2235 Average Win 2.62% Average Loss -1.06% Compounding Annual Return 584.629% Drawdown 38.100% Expectancy 0.197 Net Profit 705.493% Sharpe Ratio 4.189 Probabilistic Sharpe Ratio 85.152% Loss Rate 65% Win Rate 35% Profit-Loss Ratio 2.46 Alpha 4.787 Beta 1.006 Annual Standard Deviation 1.177 Annual Variance 1.385 Information Ratio 4.087 Tracking Error 1.172 Treynor Ratio 4.898 Total Fees $0.00 Estimated Strategy Capacity $500000.00 Lowest Capacity Asset BTCUSD E3 |
from datetime import datetime, timedelta class SimplePullBackStrategy(QCAlgorithm): def Initialize(self): self.SetStartDate(2021, 1, 1) # Set Start Date self.InitCash = 10000 self.SetCash(self.InitCash) self.profitTargetPercent = 0.02 self.trailingStopLossPercent = 0.01 btc = self.AddCrypto("BTCUSD", Resolution.Minute, Market.Bitfinex) self.btc = btc.Symbol self.SetWarmUp(14) self.entryPrice = 0 self.period = timedelta(minutes=120) self.nextEntryTime = self.Time # relative strength index self.rsi = self.RSI(self.btc, 14, MovingAverageType.Wilders, Resolution.Minute) def OnData(self, data): price = self.Securities[self.btc].Price if not self.Portfolio.Invested: if self.nextEntryTime <= self.Time and self.rsi.Current.Value < 30 and not self.IsWarmingUp: self.SetHoldings(self.btc, 1, True) qty = self.Portfolio[self.btc].Quantity self.Log("Bought " + "{:.2f}".format(qty) + " BTC @" + str(int(price))) self.entryPrice = price elif self.entryPrice * (1 + self.profitTargetPercent) < price or self.entryPrice * (1 - self.trailingStopLossPercent) > price: pnl = self.Portfolio.TotalUnrealisedProfit qty = self.Portfolio[self.btc].Quantity self.Liquidate() self.Log("Sold " + "{:.2f}".format(qty) + " BTC @" + str(int(price)) + ' for a profit of ' + str(int(pnl)) ) self.nextEntryTime = self.Time + self.period