Hi there,

I have implemented a custom fee model trying to charge a 2% spread while entering trade but when I run the backtest there is no fee accrued. What is wrong in this code?

from AlgorithmImports import *

class BTCUSDTrendFollowingAlgorithm(QCAlgorithm):
    def Initialize(self):
        self.SetStartDate(2023, 1, 1)    # Set Start Date
        self.SetEndDate(2024, 12, 1)      # Set End Date
        self.SetCash(2_000)             # Set Strategy Cash
        self.symbol = self.AddCrypto("BTCUSD", Resolution.Minute).Symbol
        
        self.highest_close = None
        self.breakout_volume = None
        self.trailing_stop = None
        
        self.daily_closes = RollingWindow[float](5)
        self.volume_sma = SimpleMovingAverage(20)
        
        # Set the custom fee model
        self.Securities[self.symbol].SetFeeModel(MyFeeModel())
        
    def OnData(self, data):
        if not data.Bars.ContainsKey(self.symbol):
            return
        
        bar = data.Bars[self.symbol]
        
        # Update daily closes
        if self.Time.hour == 0 and self.Time.minute == 0:
            if self.daily_closes.IsReady:
                self.daily_closes.Add(bar.Close)
            else:
                self.daily_closes.Add(bar.Close)
        
        # Update volume SMA
        self.volume_sma.Update(self.Time, bar.Volume)
        
        # Check for breakout condition
        if self.daily_closes.IsReady and self.volume_sma.IsReady:
            highest_close = max(self.daily_closes)
            breakout_volume = self.volume_sma.Current.Value * 5
            
            if bar.Close > highest_close and bar.Volume > breakout_volume:
                self.SetHoldings(self.symbol, 1)
                self.trailing_stop = bar.Close * 0.98
        
        # Implement trailing stop loss
        if self.Portfolio[self.symbol].Invested:
            if bar.Close < self.trailing_stop:
                self.Liquidate(self.symbol)
            else:
                self.trailing_stop = max(self.trailing_stop, bar.Close * 0.95)

class MyFeeModel(FeeModel):
    def GetOrderFee(self, parameters: OrderFeeParameters) -> OrderFee:
        # Implementing a 2% spread fee
        order = parameters.Order
        fee = order.AbsoluteQuantity * order.Price * 0.02
        return OrderFee(CashAmount(fee, 'USD'))