Apps Script seems to be unable to deal with a cell that uses the average formula, when the average is over Google Finance data:
Consider that column A is full of dat
As written in the Official documentation,
Historical data cannot be downloaded or accessed via the Sheets API or Apps Script. If you attempt to do so, you will see a #N/A error in place of the values in the corresponding cells of your spreadsheet.
The average formula is NOT the problem. Any attempt to take historical finance data through any formula hoops doesn't seem to be possible.
However live data doesn't seem to be restricted the same way.