Instead of looping all symbols on by one and get the history for each symbol, is it optimal to get history for all symbols as below code as an example. Please confirm it below optimization is correct and best practice

Before Optimization

for index, row in self.breakout_symbols:
symbol_str = row['Symbol']
symbol = Symbol.Create(symbol_str, SecurityType.Equity, Market.USA)
breakout_date = row['Date']
initial_price = row['close_price']
history =  self.History(symbol, 1, Resolution.Daily)
if history.empty:
               continue
   current_price = history['close'].iloc[0]

//logic for using current_price

After Optimization

symbols_to_check = []
for idx, row in self.breakout_symbols:
	symbol = Symbol.Create(row['Symbol'], SecurityType.Equity, Market.USA)
	symbol_index_map[symbol] = idx
    symbols_to_check.append(symbol)

history = self.History(symbols_to_check, 1, Resolution.Daily) if symbols_to_check else pd.DataFrame()
for symbol, idx in symbol_index_map.items():
	row = self.breakout_stocks.loc[idx]
	breakout_date = row['Date']
	initial_price = row['close_price']
	sym_hist = history.xs(symbol, level=0) if not history.empty else pd.DataFrame()
	if sym_hist.empty:
                continue
	current_price = sym_hist['close'].iloc[0]

	//logic for using current_price