Overall Statistics |
Total Trades 2518 Average Win 0.25% Average Loss -0.27% Compounding Annual Return 69.260% Drawdown 9.100% Expectancy 0.015 Net Profit 4.722% Sharpe Ratio 1.267 Probabilistic Sharpe Ratio 51.358% Loss Rate 48% Win Rate 52% Profit-Loss Ratio 0.94 Alpha 0.382 Beta 0.605 Annual Standard Deviation 0.253 Annual Variance 0.064 Information Ratio 1.727 Tracking Error 0.244 Treynor Ratio 0.529 Total Fees $0.00 Estimated Strategy Capacity $100000.00 Lowest Capacity Asset BTCUSD 2MN |
# CRYPTO curr_price and price_paid # -------------------------- CRYPTO = "BTCUSD"; BARS = 2; # -------------------------- class CryptoConsolidator(QCAlgorithm): def Initialize(self): self.SetStartDate(2022, 3, 21) self.SetEndDate(2022, 4, 21) self.SetCash(1000) self.crypto = self.AddCrypto(CRYPTO, Resolution.Minute, Market.FTX).Symbol self.window = RollingWindow[TradeBar](BARS) self.Consolidate(self.crypto, Resolution.Minute, self.CustomBarHandler) def CustomBarHandler(self, bar): self.window.Add(bar) def OnData(self, data): if not self.window.IsReady: return curr_close = np.array([self.window[i].Close for i in range(BARS)])[0] past_close = np.array([self.window[i].Close for i in range(BARS)])[1] if not self.Portfolio[self.crypto].Invested: if curr_close <= past_close*0.999: self.SetHoldings(self.crypto, 1.00 ) elif self.Portfolio[self.crypto].Invested: curr_price = self.Securities[self.crypto].Price price_paid = self.Securities[self.crypto].Holdings.AveragePrice if curr_price >= price_paid*1.002: self.Liquidate(self.crypto, "Take Profit") elif curr_price < price_paid*0.998: self.Liquidate(self.crypto, "Stop Loss")