please help my code is failing here: 

Runtime Error: 'TradeBar' object has no attribute 'BidVolume'  at    if pair.Key != self._basketSymbol and pair.Value.BidVolume > 2 * pair.Value.AskVolume] in main.py: line 41  at GetBestStock    stocks = [SecurityData(pair.Key in main.py: line 40  at OnData    best_stock = self.GetBestStock(data)   at Python.Runtime.PythonException.ThrowLastAsClrException()   at Python.Runtime.PyObject.Invoke(PyTuple args in main.py: line 22

 

from AlgorithmImports import *

class MyAlgorithm(QCAlgorithm):

    def Initialize(self):
        self.SetStartDate(2020, 1, 1)
        self.SetCash(100000)
        self._basketSymbol = Symbol.Create('Basket', SecurityType.Equity, Market.USA)
        self._lastTradeDate = datetime.min
        self._purchasePrice = 0
        self._targetProfit = 0.05  # 5% profit
        self._stopLoss = 0.02  # 2% stop loss

        self.UniverseSettings.Resolution = Resolution.Minute
        self.AddUniverse(self.CoarseSelectionFunction)

    def CoarseSelectionFunction(self, coarse):
        selected = [x for x in coarse if 0.01 < x.Price < 1 and x.HasFundamentalData and x.Volume > 800000]
        return [x.Symbol for x in selected]

    def OnData(self, data):
        if not self.Portfolio.Invested:
            best_stock = self.GetBestStock(data)

            if best_stock is not None:
                self._currentStockSymbol = best_stock.Symbol
                self._purchasePrice = best_stock.Price

                self.SetHoldings(self._currentStockSymbol, 1.0)

        elif self._currentStockSymbol is not None and self._currentStockSymbol in data:
            current_price = data[self._currentStockSymbol].Price

            if current_price >= self._purchasePrice * (1 + self._targetProfit):
                self.Liquidate()

            elif current_price <= self._purchasePrice * (1 - self._stopLoss):
                self.Liquidate()

    def GetBestStock(self, data):
        stocks = [SecurityData(pair.Key, pair.Value.Close, pair.Value.Volume, pair.Value.BidVolume, pair.Value.AskVolume) for pair in data
                  if pair.Key != self._basketSymbol and pair.Value.BidVolume > 2 * pair.Value.AskVolume]

        if not stocks:
            return None

        stocks.sort(key=lambda x: x.DailyVolume, reverse=True)

        return stocks[0]

class SecurityData:
    def __init__(self, symbol, price, daily_volume, bid_volume, ask_volume):
        self.Symbol = symbol
        self.Price = price
        self.DailyVolume = daily_volume
        self.BidVolume = bid_volume
        self.AskVolume = ask_volume