如何使用 API 在 Google 工作表中检索 Google 财务历史数据?

How do I retrieve Google Finance Historical data in Google Sheets using the API?

要重现此问题,请创建一个新的 sheet。 在单元格 A1 中,插入此公式:

=GoogleFinance("AMZN", "all", "1/1/2018", "2/1/2018")

输出(格式与此问题无关):

Date    Open    High    Low Close   Volume
1/2/2018 16:00:00   1172    1190    1170.51 1189.01 2694494
1/3/2018 16:00:00   1188.3  1205.49 1188.3  1204.2  3108793
1/4/2018 16:00:00   1205    1215.8699   1204.66 1209.59 3022089
1/5/2018 16:00:00   1217.51 1229.14 1210    1229.14 3544743
1/8/2018 16:00:00   1236    1253.079    1232.03 1246.87 4279475
1/9/2018 16:00:00   1256.9  1259.33 1241.76 1252.7  3661316
1/10/2018 16:00:00  1245.15 1254.33 1237.23 1254.33 2686017
1/11/2018 16:00:00  1259.74 1276.77 1256.46 1276.68 3125048
1/12/2018 16:00:00  1273.3925   1305.76 1273.3925   1305.2  5443730
1/16/2018 16:00:00  1323    1339.94 1292.3  1304.86 7220701
1/17/2018 16:00:00  1312.24 1314    1280.88 1295    5253754
1/18/2018 16:00:00  1293.95 1304.6  1284.02 1293.32 4026915
1/19/2018 16:00:00  1312    1313    1292.99 1294.58 4578536
1/22/2018 16:00:00  1297.17 1327.45 1296.6636   1327.31 4140061
1/23/2018 16:00:00  1338.09 1364.9  1337.34 1362.54 5169306
1/24/2018 16:00:00  1374.82 1388.16 1338    1357.51 6807457
1/25/2018 16:00:00  1368    1378.34 1357.62 1377.95 4753012
1/26/2018 16:00:00  1392.01 1402.53 1380.91 1402.05 4857310
1/29/2018 16:00:00  1409.18 1431.39 1400.44 1417.68 5701898
1/30/2018 16:00:00  1403.17 1439.25 1392    1437.82 5871942
1/31/2018 16:00:00  1451.3  1472.58 1450.04 1450.89 6424693

到目前为止一切都很好。但是,当我尝试通过 API 检索此数据时(并且我想指出所有其他数据都可以很好地检索),我得到了单元格 A1 的简单“#N/A”,并且所有其他单元格都没有值。就好像他们是空的。我试过只检索值,还有所有的网格信息,这两种情况,就像这些值从未存在过一样。

我尝试过的事情:

当使用来自 google 财务的历史数据时(根据 API 调用),似乎数据不存在。

我还没有发布我的代码,因为这似乎更像是 googlefinance 不工作的情况,特别是当返回 'range' 数据而不是单个单元格值时.

想法?

呃。

藏在 Google Finance Documentation 的最底部我终于注意到这个小 gem:

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.