简体   繁体   English

如何将 Yahoo Finance 中的历史数据导入 Google 表格并使其自动更新?

[英]How to Import Historical Data from Yahoo Finance into Google Sheets and make it Auto-Update?

I've been trying to get Yahoo Finance ES symbol daily OHLC data into Google Sheet.我一直在尝试将 Yahoo Finance ES 符号每日 OHLC 数据导入 Google 表格。

I've checked the disabling javascript and reloading the page method by @Rubén and the OHLC data displays after reloading the page.我检查了禁用 javascript 并通过@Rubén重新加载页面方法,并且在重新加载页面后显示 OHLC 数据。 But the IMPORT formulas returns #N/A Resource at URL Not Found .但是 IMPORT 公式#N/A Resource at URL Not Found

I also tried @user0 methods (save the IMPORTJSON one) here but no luck there too.我还在这里尝试了@user0方法(保存 IMPORTJSON 方法) 但也没有运气。

Then I've tested the script by @JohnA and it does retrieve the data.然后我测试了@JohnA的脚本,它确实检索了数据。

Here's @JohnA Script output I got.这是我得到的@JohnA Script output

But now I'm wondering how to make it auto-update at least every day (it is daily data).但现在我想知道如何让它至少每天自动更新(它是每日数据)。

I'm not sure how to proceed since @JohnA's Script involves handling a CSV file.我不确定如何继续,因为@JohnA 的脚本涉及处理CSV文件。

I've enabled calculation on change and every minute as detailed here: How to Configure Auto Refresh for Googlesheets我已经启用calculation on change and every minute如下所述: 如何为 Googlesheets 配置自动刷新

Is there any workaround allowing to just get the data into Google Sheet without needing the csv step?是否有任何解决方法允许将数据放入 Google 表格而不需要 csv 步骤?

Or is it possible to still pull the data from the CSV while getting Google sheet to auto-update daily?或者,在让 Google 表格每天自动更新的同时,是否仍然可以从CSV中提取数据? If yes, how to do it?如果是,该怎么做?

Thanks for any advice, always very much appreciated!感谢您的任何建议,总是非常感谢!

The test Sheet1 and Sheet2 测试 Sheet1 和 Sheet2

Related scripts by @Tanaike 1 @Tanaike 2 @Tanaike 1的相关脚本@Tanaike 2

In script editor look for the clock在脚本编辑器中查找时钟

在此处输入图像描述

Then complete the form然后填写表格

在此处输入图像描述

Optionally, you can set a trigger via a script或者,您可以通过脚本设置触发器

/**
 * Creates time-driven triggers
 *
 * https://developers.google.com/apps-script/reference/script/clock-trigger-builder
 */
function createTimeDrivenTriggers() {
  // Trigger every day at 04:00AM CT.
  ScriptApp.newTrigger('csvDaily')
      .timeBased()
      .everyDays(1)
      .atHour(4)
      .create();
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM