title: Returning array of historical prices from yahoo finance API in apps script
body: <p>I'm trying to get historical prices for a number of tickers in my google sheets by creating a custom function. The below code seems to run fine in apps script, but it doesn't output anything in my spreadsheet, just giving the error #NUM! The result was not a number. Obviously I need to turn this into an array, but I'm not sure how to do it. Any help would be greatly appreciated.</p>
  <pre><code> /**
   * Fetch historical prices from Yahoo Finance
   * 
   * @param ticker The ticker to fetch historical prices for, e.g. &quot;AAPL&quot;
   * @param range The range to return (e.g. &quot;1y&quot;)
   * @param interval e.g. &quot;1d&quot;
   * @param metrics e.g. &quot;Close&quot;
   * @customfunction
   */
  
  function YFHistorical(ticker, range, interval, metrics) {
    var ticker = ticker || &quot;GOOG&quot;;
    var range = range || &quot;1y&quot;;
    var interval = interval || &quot;1d&quot;;
    var metrics = metrics || &quot;close&quot;;
    var uri = (&quot;https://query1.finance.yahoo.com/v8/finance/chart/&quot; + ticker + &quot;?metrics=&quot; + metrics + &quot;&amp;interval=&quot; + interval + &quot;&amp;range=&quot; + range);
   
    var response = UrlFetchApp.fetch(uri);
    var json = response.getContentText();
    var data = JSON.parse(json);
    var data2 = data.chart.result[0].indicators.quote;
    return parseFloat(data2);
  }
  </code></pre>