Below is my code for for the stock which are above specific price, specific dollar volumes and building the moving averages, volatility and ATR for each stocks, please confirm if below code is correct

    def CoarseSelectionFunction(self, coarse):
        selected = []
        for stock in coarse:
            if stock.Price > params.PRICE_THRESHOLD and stock.DollarVolume > params.DOLLAR_VOLUME_THRESHOLD:
                selected.append(stock.Symbol)
                if stock.Symbol not in self.history:
                    history = self.algorithm.History(stock.Symbol, params.MOVING_AVERAGE_200_DAYS, Resolution.Daily)
                    if not history.empty:
                        self.history[stock.Symbol] = history["close"] * history["volume"]
                        self.moving_averages_200[stock.Symbol] = history["close"].rolling(window=params.MOVING_AVERAGE_200_DAYS).mean().iloc[-1]
                        self.moving_averages_20[stock.Symbol] = history["close"].rolling(window=params.MOVING_AVERAGE_20_DAYS).mean().iloc[-1]
                        self.previous_close[stock.Symbol] = history["close"].iloc[-2]
                        self.atr[stock.Symbol] = self.algorithm.ATR(stock.Symbol, 14, MovingAverageType.Wilders)
                        # Calculate Volatility
                        daily_returns = history["close"].pct_change().dropna()
                        self.volatility[stock.Symbol] = daily_returns.std() * (252 ** 0.5)  # Annualized volatility
                        # Calculate 30-day average volatility
                        self.avg_volatility[stock.Symbol] = daily_returns.rolling(window=params.VOLATILITY_LOOKBACK_DAYS).std().mean() * (252 ** 0.5)
        return selected