Overall Statistics
Total Orders
1
Average Win
0%
Average Loss
0%
Compounding Annual Return
192.504%
Drawdown
7.100%
Expectancy
0
Start Equity
100000
End Equity
130921.81
Net Profit
30.922%
Sharpe Ratio
4.253
Sortino Ratio
5.92
Probabilistic Sharpe Ratio
88.420%
Loss Rate
0%
Win Rate
0%
Profit-Loss Ratio
0
Alpha
0.372
Beta
2.919
Annual Standard Deviation
0.265
Annual Variance
0.07
Information Ratio
4.942
Tracking Error
0.176
Treynor Ratio
0.386
Total Fees
$4.91
Estimated Strategy Capacity
$11000000.00
Lowest Capacity Asset
BGU U7EC123NWZTX
Portfolio Turnover
1.08%
from AlgorithmImports import *

class CryptoStrategy(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2024, 1, 1)
        self.SetEndDate(2024, 4, 1)
        self.SetCash(100000)

        self.symbol = "SPXL"
        self.SetBenchmark("SPY")

        try:
            self.AddEquity(self.symbol, Resolution.Minute)
        except Exception as e:
            self.Debug(f"Unable to add symbol: {self.symbol}. Exception: {e}")

        self.atr = self.ATR(self.symbol, 10, MovingAverageType.Wilders, Resolution.Minute)
        self.supertrend_sma = self.SMA(self.symbol, 10, Resolution.Minute)
        self.entry_price = None

        self.SetWarmUp(100, Resolution.Minute)

    def OnData(self, data):
        if self.IsWarmingUp:
            return

        if not data.Bars.ContainsKey(self.symbol):
            return

        bar = data.Bars[self.symbol]
        current_price = bar.Close
        atr_value = self.atr.Current.Value
        supertrend_value = self.supertrend_sma.Current.Value - 10 * atr_value

        if self.entry_price is None:
            if current_price > supertrend_value:
                self.Debug(f"{self.symbol}: Supertrend={supertrend_value}, Current Price={current_price}")
                self.SetHoldings(self.symbol, 1.0)
                self.entry_price = current_price

        elif current_price < supertrend_value:
            self.Liquidate(self.symbol)
            self.entry_price = None