新雅虎财经 URL
New Yahoo Finance URL
由于之前的 Yahoo Finance 下载 URL 不再可用,我现在只剩下这样的东西:
有谁知道 period1(和 period2)如何转换为日期(反之亦然)
感谢任何帮助!
谢谢!
看起来它们只是 unix 时间戳,或者 Epoch 的秒数。这是一个可以为您隐藏信息的网站:http://www.unixtimestamp.com
这是为了重新创建(有点)旧功能。我是 运行 Fedora 和 Chrome.
(1) 找出您的网络浏览器的用户代理字符串(我用谷歌搜索了类似 "what's my user agent string" 的内容,并很快找到了一个页面,可以为您正在使用的浏览器打印它)。它将类似于 "Mozilla/5.0 (X11; Linux x86_64) ..."
(2) 安装一个包,它将为 Chrome 导出一个 "cookies.txt" 文件(也用谷歌搜索了类似 "Chrome export cookies.txt" 的东西,并很快找到了一个 chrome 扩展为您正在查看的页面导出 cookies.txt。
(3) 转到历史下载页面以获取 Yahoo 财经上感兴趣的符号。保存下载 link 中的 "crumb"(如上所示)和该页面的 cookies.txt。
(4) 现在可以使用wget获取数据了。该命令类似于:
wget --load-cookies [您保存的 COOKIES 文件] -U “[您找到的用户代理字符串]” -O [期望的输出 CSV] https://query1.finance.yahoo.com/v7/finance/download/[THE 您想要历史数据的符号]? period1=[UNIX 开始时间]\&period2=[UNIX 结束时间]\&interval=1d\&events=history\&crumb=[你保存的面包屑]
period1=... 是开始日期的 UNIX 时间戳(自 1970 年 1 月 1 日 00:00:00 GMT 以来的秒数),period2=... 是结束日期的 UNIX 时间戳。
我能够以这种方式以编程方式下载许多符号。生成的 CSV 文件的列顺序与旧 ichart 有所不同 API,我在历史数据中发现的错误数量明显高于数据中已经相当高的错误率。
不知道这会工作多久,或者它是否能在很长一段时间内保持稳定。 YMMV.
period1 和 period2 只是时间戳(POSIX 时间戳)。我认为您可以使用您想要使用的日期的任何时间。例如,对于 2014-05-20,您可以使用从 00:00:00 到 23:59:59 的任何时间。 (更新:雅虎刚刚在这里做了一个改变。你必须使用收市后的时间,否则数据将错过最后一天。我认为 18:00:00 工作正常。)
我已经整理了一些快速 Python3 代码来使用新的 API。请查看 GitHub 以获取源代码 yahoo_quote_download。
它们是 unix 时间戳,或者自 Epoch 以来的秒数。
引用自http://www.unixtimestamp.com/
What is the unix time stamp?
The unix time stamp is a way to track
time as a running total of seconds. This count starts at the Unix
Epoch on January 1st, 1970 at UTC. Therefore, the unix time stamp is
merely the number of seconds between a particular date and the Unix
Epoch. It should also be pointed out (thanks to the comments from
visitors to this site) that this point in time technically does not
change no matter where you are located on the globe. This is very
useful to computer systems for tracking and sorting dated information
in dynamic and distributed applications both online and client side
以下 C# 代码有助于将日期时间转换为 Unix 时间戳
//credits to ScottCher
//reference
private static DateTime UnixTimestampToDateTime(double unixTimeStamp)
{
//Unix timestamp Is seconds past epoch
return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(unixTimeStamp).ToLocalTime();
}
//credits to Dmitry Fedorkov
//reference
private static double DateTimeToUnixTimestamp(DateTime dateTime)
{
//Unix timestamp Is seconds past epoch
return (dateTime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
}
注意:确保在代入 period1 和 period2
之前四舍五入到小数点零
由于之前的 Yahoo Finance 下载 URL 不再可用,我现在只剩下这样的东西:
有谁知道 period1(和 period2)如何转换为日期(反之亦然)
感谢任何帮助!
谢谢!
看起来它们只是 unix 时间戳,或者 Epoch 的秒数。这是一个可以为您隐藏信息的网站:http://www.unixtimestamp.com
这是为了重新创建(有点)旧功能。我是 运行 Fedora 和 Chrome.
(1) 找出您的网络浏览器的用户代理字符串(我用谷歌搜索了类似 "what's my user agent string" 的内容,并很快找到了一个页面,可以为您正在使用的浏览器打印它)。它将类似于 "Mozilla/5.0 (X11; Linux x86_64) ..."
(2) 安装一个包,它将为 Chrome 导出一个 "cookies.txt" 文件(也用谷歌搜索了类似 "Chrome export cookies.txt" 的东西,并很快找到了一个 chrome 扩展为您正在查看的页面导出 cookies.txt。
(3) 转到历史下载页面以获取 Yahoo 财经上感兴趣的符号。保存下载 link 中的 "crumb"(如上所示)和该页面的 cookies.txt。
(4) 现在可以使用wget获取数据了。该命令类似于:
wget --load-cookies [您保存的 COOKIES 文件] -U “[您找到的用户代理字符串]” -O [期望的输出 CSV] https://query1.finance.yahoo.com/v7/finance/download/[THE 您想要历史数据的符号]? period1=[UNIX 开始时间]\&period2=[UNIX 结束时间]\&interval=1d\&events=history\&crumb=[你保存的面包屑]
period1=... 是开始日期的 UNIX 时间戳(自 1970 年 1 月 1 日 00:00:00 GMT 以来的秒数),period2=... 是结束日期的 UNIX 时间戳。
我能够以这种方式以编程方式下载许多符号。生成的 CSV 文件的列顺序与旧 ichart 有所不同 API,我在历史数据中发现的错误数量明显高于数据中已经相当高的错误率。
不知道这会工作多久,或者它是否能在很长一段时间内保持稳定。 YMMV.
period1 和 period2 只是时间戳(POSIX 时间戳)。我认为您可以使用您想要使用的日期的任何时间。例如,对于 2014-05-20,您可以使用从 00:00:00 到 23:59:59 的任何时间。 (更新:雅虎刚刚在这里做了一个改变。你必须使用收市后的时间,否则数据将错过最后一天。我认为 18:00:00 工作正常。)
我已经整理了一些快速 Python3 代码来使用新的 API。请查看 GitHub 以获取源代码 yahoo_quote_download。
它们是 unix 时间戳,或者自 Epoch 以来的秒数。
引用自http://www.unixtimestamp.com/
What is the unix time stamp?
The unix time stamp is a way to track time as a running total of seconds. This count starts at the Unix Epoch on January 1st, 1970 at UTC. Therefore, the unix time stamp is merely the number of seconds between a particular date and the Unix Epoch. It should also be pointed out (thanks to the comments from visitors to this site) that this point in time technically does not change no matter where you are located on the globe. This is very useful to computer systems for tracking and sorting dated information in dynamic and distributed applications both online and client side
以下 C# 代码有助于将日期时间转换为 Unix 时间戳
//credits to ScottCher
//reference
private static DateTime UnixTimestampToDateTime(double unixTimeStamp)
{
//Unix timestamp Is seconds past epoch
return new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc).AddSeconds(unixTimeStamp).ToLocalTime();
}
//credits to Dmitry Fedorkov
//reference
private static double DateTimeToUnixTimestamp(DateTime dateTime)
{
//Unix timestamp Is seconds past epoch
return (dateTime.ToUniversalTime() - new DateTime(1970, 1, 1, 0, 0, 0, 0, DateTimeKind.Utc)).TotalSeconds;
}
注意:确保在代入 period1 和 period2
之前四舍五入到小数点零