Overall Statistics
Total Orders
345
Average Win
6.06%
Average Loss
-2.08%
Compounding Annual Return
7.215%
Drawdown
69.100%
Expectancy
0.364
Start Equity
100000.00
End Equity
141774.53
Net Profit
41.775%
Sharpe Ratio
0.413
Sortino Ratio
0.475
Probabilistic Sharpe Ratio
9.127%
Loss Rate
65%
Win Rate
35%
Profit-Loss Ratio
2.91
Alpha
0.17
Beta
0.064
Annual Standard Deviation
0.573
Annual Variance
0.328
Information Ratio
-0.962
Tracking Error
0.825
Treynor Ratio
3.684
Total Fees
$178871.48
Estimated Strategy Capacity
$48000000.00
Lowest Capacity Asset
BTCUSD 2XR
Portfolio Turnover
18.16%
from AlgorithmImports import *

class BtcDailyStrategy(QCAlgorithm):
    def initialize(self):
        self.set_start_date(2020, 1, 1)
        self.set_end_date(2025, 1, 1)
        self.set_cash(100000)

        self.symbol = self.add_crypto("BTCUSD", Resolution.DAILY, Market.GDAX).symbol

        self.sma_50 = self.sma(self.symbol, 50, Resolution.DAILY)
        self.ema_7 = self.ema(self.symbol, 7, Resolution.DAILY)
        self.rsi_2 = self.rsi(self.symbol, 2, MovingAverageType.WILDERS, Resolution.DAILY)
        self.adx_2 = self.adx(self.symbol, 2, Resolution.DAILY)

        self.previous_rsi = None
        self.previous_adx = None

        self.set_brokerage_model(BrokerageName.KRAKEN)

    def on_data(self, slice: Slice):
        if not (self.sma_50.is_ready and self.ema_7.is_ready and self.rsi_2.is_ready and self.adx_2.is_ready):
            return

        price = self.securities[self.symbol].price
        sma = self.sma_50.current.value
        ema = self.ema_7.current.value
        rsi = self.rsi_2.current.value
        adx = self.adx_2.current.value

        invested = self.portfolio[self.symbol].invested

        # Buy condition
        if not invested and price > sma and price > ema and rsi > adx:
            self.set_holdings(self.symbol, 1)
            self.debug(f"BUY >> {self.time.date()} Price: {price:.2f} RSI: {rsi:.2f} ADX: {adx:.2f}")

        # Sell condition
        elif invested and rsi < adx:
            self.liquidate(self.symbol)
            self.debug(f"SELL >> {self.time.date()} Price: {price:.2f} RSI: {rsi:.2f} ADX: {adx:.2f}")