I have a table (StockList) containing a single column of tickers and I have a cell (labelled NumDays) that specifies the number of days of stock history to return.

The table of stock prices is generated by the function shown below. However, it intermittently fails, particularly when NumDays is large.
=LET(
endDate, TODAY(),
startDate, endDate - NumDays,
allDates, SEQUENCE(endDate - startDate, 1, startDate),
numStocks, ROWS(StockList),
stockSymbols, CHOOSECOLS(StockList, 1),
prices, REDUCE(
allDates,
SEQUENCE(numStocks, 1, 1),
LAMBDA(acc,i,
LET(
history, STOCKHISTORY(INDEX(stockSymbols, i, 1), startDate, endDate, 0, 1),
HSTACK(
acc,
IFERROR(XLOOKUP(allDates, CHOOSECOLS(history, 1), CHOOSECOLS(history, 2),NA(), -1), NA())
)
)
)
),
header, HSTACK("Date", TRANSPOSE(stockSymbols)),
VSTACK(header, prices)
)