Overall Statistics |
Total Orders 280 Average Win 0.92% Average Loss -0.76% Compounding Annual Return -8.119% Drawdown 20.900% Expectancy -0.128 Start Equity 200000.00 End Equity 168773.71 Net Profit -15.613% Sharpe Ratio -0.959 Sortino Ratio -0.87 Probabilistic Sharpe Ratio 0.381% Loss Rate 61% Win Rate 39% Profit-Loss Ratio 1.22 Alpha -0.087 Beta 0.051 Annual Standard Deviation 0.092 Annual Variance 0.008 Information Ratio -0.088 Tracking Error 0.702 Treynor Ratio -1.74 Total Fees $4114.14 Estimated Strategy Capacity $41000000.00 Lowest Capacity Asset BTCBUSD 18R Portfolio Turnover 8.50% |
from AlgorithmImports import * class BinanceCryptoFutureDataAlgorithm(QCAlgorithm): def initialize(self) -> None: self.set_start_date(2021, 1, 1) self.set_end_date(2023, 1, 1) self.set_cash("BUSD", 100000) self.set_brokerage_model(BrokerageName.BINANCE_FUTURES, AccountType.MARGIN) crypto_future = self.add_crypto_future("BTCBUSD", Resolution.DAILY) self.btcbusd = crypto_future.symbol self.fast_ma = self.SMA(self.btcbusd, 5, Resolution.DAILY) self.slow_ma = self.SMA(self.btcbusd, 10, Resolution.DAILY) # Order variables self.stop_loss_percentage = 0.01 self.take_profit_percentage = 0.02 self.current_position = None def on_data(self, slice: Slice) -> None: if not slice.bars.contains_key(self.btcbusd) or not slice.quote_bars.contains_key(self.btcbusd): return if not self.fast_ma.IsReady or not self.slow_ma.IsReady: return # monitor price scale manually current_price = slice.bars[self.btcbusd].price if self.current_position is None and self.fast_ma.Current.Value > self.slow_ma.Current.Value: # Place a long trade self.current_position = self.MarketOrder(self.btcbusd, 1) entry_price = slice.bars[self.btcbusd].price self.entry_price = current_price self.Debug(f"Entered Long at {self.entry_price}") # Exit conditions: Stop-loss or take-profit for long position elif self.current_position is not None: stop_loss_price = self.entry_price * (1 - self.stop_loss_percentage) take_profit_price = self.entry_price * (1 + self.take_profit_percentage) if current_price <= stop_loss_price: self.Liquidate(self.btcbusd) self.current_position = None self.Debug(f"Exited Long for Stop Loss at {current_price}") elif current_price >= take_profit_price: self.Liquidate(self.btcbusd) self.current_position = None self.Debug(f"Exited Long for Take Profit at {current_price}") # Trend reversal exit if self.current_position is not None and self.fast_ma.Current.Value < self.slow_ma.Current.Value: self.Liquidate(self.btcbusd) self.current_position = None self.Debug(f"Exited Long on Trend Reversal at {current_price}")