Overall Statistics |
Total Orders 36640 Average Win 0.04% Average Loss -0.04% Compounding Annual Return 947.304% Drawdown 1.900% Expectancy 0.137 Start Equity 86000.00 End Equity 236257.70 Net Profit 174.718% Sharpe Ratio 14.641 Sortino Ratio 0 Probabilistic Sharpe Ratio 100.000% Loss Rate 43% Win Rate 57% Profit-Loss Ratio 1.01 Alpha 3.662 Beta -0.094 Annual Standard Deviation 0.25 Annual Variance 0.063 Information Ratio 13.339 Tracking Error 0.277 Treynor Ratio -39.093 Total Fees â‚®0.00 Estimated Strategy Capacity â‚®1500000.00 Lowest Capacity Asset BTCUSDT 2UZ Portfolio Turnover 11409.89% |
# region imports from AlgorithmImports import * # endregion class CasualBlueHornet(QCAlgorithm): def initialize(self): self.set_start_date(2024, 10, 1) self.set_account_currency('USDT', 86_000) #self.set_brokerage_model(BrokerageName.INTERACTIVE_BROKERS_BROKERAGE, AccountType.MARGIN) self._spot = self.add_crypto("BTCUSDT", Resolution.SECOND, market=Market.BYBIT) self._future = self.add_crypto_future("BTCUSDT", Resolution.SECOND, market=Market.BYBIT) self._bb = BollingerBands(30*24*60*60, 2) self.set_warm_up(timedelta(30)) def on_data(self, data: Slice): if not (self._spot.symbol in data and self._future.symbol in data): return spread = self._spot.price - self._future.price if not self._bb.update(self.time, spread): return if not self.portfolio.invested: if spread < self._bb.lower_band.current.value: # Sell future; buy spot self.set_holdings(self._future.symbol, -0.5) self.set_holdings(self._spot.symbol, 0.5) elif spread > self._bb.upper_band.current.value: # Sell spot; buy future self.set_holdings(self._spot.symbol, -0.5) self.set_holdings(self._future.symbol, 0.5) elif (self._spot.holdings.is_long and spread >= self._bb.middle_band.current.value or self._future.holdings.is_long and spread <= self._bb.middle_band.current.value): self.liquidate() #self.plot('BTCUSD', 'SPREAD', spread) #self.plot('BTCUSD', 'Upper Band', self._bb.upper_band.current.value) #self.plot('BTCUSD', 'Middle Band', self._bb.middle_band.current.value) #self.plot('BTCUSD', 'Lower Band', self._bb.lower_band.current.value)