【问题标题】:Getting stock's historical data获取股票的历史数据
【发布时间】:2014-09-25 16:38:01
【问题描述】:

我们想检查股票的历史数据,使用 HTTP 请求,并获取 JSON。

使用yahoo API,我发现不仅很难清楚地理解HTTP请求字段,而且获取某一天的数据(不是每天的平均值,而是期间的值)某天),用这个:

http://query.yahooapis.com/v1/public/yql?q=select%20*%20from%20yahoo.finance.historicaldata%20where%20symbol%20%3D%20%22AAPL%22%20and%20startDate%20%3D%20%222012-09-11%22%20and%20endDate%20%3D%20%222014-02-11%22&format=json&diagnostics=true&env=store%3A%2F%2Fdatatables.org%2Falltableswithkeys&callback=

1.没有任何地方解释如何设置每个字段(也没有在雅虎控制台上)。

2.你不能设置某一天,然后获取它的值。

除了现在免费的 Yahoo,还有其他稳定的解决方案吗? 或者,有人可以帮助我了解请求中的所有这些垃圾标志吗?

【问题讨论】:

    标签: yahoo-finance algorithmic-trading


    【解决方案1】:

    2. 中的广告假设:“不能设定某一天,并获得他的价值观”......好吧,你可以:

    URL> 本身包含数据选择标签:

    http://query.yahooapis.com/v1/public/yql?q=
    select * from   yahoo.finance.historicaldata
             where  symbol    = "AAPL"
             and    startDate = "2012-09-11"
             and    endDate   = "2014-02-11"
    &format=json
    &diagnostics=true
    &env=store://datatables.org/alltableswithkeys
    &callback=
    

    所以要获得 2014 年 8 月 10 日 .. 2014 年 8 月 12 日“AAPL”之间的最后几天(一对,注意结果中 endDate 的解释):


                    "results":{
                                "quote":[
                                         {
                                           "Symbol":"AAPL",
                                           "Date":"2014-08-12",
                                           "Open":"96.04",
                                           "High":"96.88",
                                           "Low":"95.61",
                                           "Close":"95.97",
                                           "Volume":"33795000",
                                           "Adj_Close":"95.97"
                                          },
                                         {
                                           "Symbol":"AAPL",
                                           "Date":"2014-08-11",
                                           "Open":"95.27",
                                           "High":"96.08",
                                           "Low":"94.84",
                                           "Close":"95.99",
                                           "Volume":"36585000",
                                           "Adj_Close":"95.99"
                                          }
                                        ]
                               }
    

    (完整的 Y! 响应记录)

    { 
     "query":{
              "count":2,
              "created":"2014-08-14T21:32:41Z",
              "lang":"en-EN",
              "diagnostics":{
                             "url":[
                                    { 
                                      "execution-start-time":"0",
                                      "execution-stop-time":"1",
                                      "execution-time":"1",
                                     "content":"http://www.datatables.org/yahoo/finance/yahoo.finance.historicaldata.xml"
                                     },
                                   {
                                     "execution-start-time":"5",
                                     "execution-stop-time":"16",
                                     "execution-time":"11",
                                     "content":"http://ichart.finance.yahoo.com/table.csv?g=d&f=2014&e=12&c=2014&b=10&a=7&d=7&s=AAPL"
                                    },
                                   {
                                     "execution-start-time":"18",
                                     "execution-stop-time":"28",
                                     "execution-time":"10",
                                     "content":"http://ichart.finance.yahoo.com/table.csv?g=d&f=2014&e=12&c=2014&b=10&a=7&d=7&s=AAPL"
                                    }
                                   ],
                                   "publiclyCallable":"true",
                                   "cache":[
                                             {
                                               "execution-start-time":"4",
                                               "execution-stop-time":"4",
                                               "execution-time":"0",
                                               "method":"GET",
                                               "type":"MEMCACHED",
                                               "content":"91a0664b4e7cf29d40cce123239fec85"
                                              },
                                             {
                                               "execution-start-time":"17",
                                               "execution-stop-time":"18",
                                               "execution-time":"1",
                                               "method":"GET",
                                               "type":"MEMCACHED",
                                               "content":"31dd9633be8581af77baa442f314c921"
                                              }
                                            ],
                                   "query":[
                                            {
                                              "execution-start-time":"5",
                                              "execution-stop-time":"17",
                                              "execution-time":"12",
                                              "params":"{url=[http://ichart.finance.yahoo.com/table.csv?g=d&f=2014&e=12&c=2014&b=10&a=7&d=7&s=AAPL]}",
                                              "content":"select * from csv(0,1) where url=@url"
                                             },
                                            {
                                              "execution-start-time":"18",
                                              "execution-stop-time":"28",
                                              "execution-time":"10",
                                              "params":"{columnsNames=[Date,Open,High,Low,Close,Volume,Adj_Close], url=[http://ichart.finance.yahoo.com/table.csv?g=d&f=2014&e=12&c=2014&b=10&a=7&d=7&s=AAPL]}",
                                              "content":"select * from csv(2,0) where url=@url and columns=@columnsNames"
                                             }
                                           ],
                           "javascript":{
                                          "execution-start-time":"3",
                                          "execution-stop-time":"29",
                                          "execution-time":"25",
                                          "instructions-used":"34359",
                                          "table-name":"yahoo.finance.historicaldata"
                                         },
                           "user-time":"31",
                           "service-time":"23",
                           "build-version":"0.2.2666"
                         },
                "results":{
                            "quote":[
                                     {
                                       "Symbol":"AAPL",
                                       "Date":"2014-08-12",
                                       "Open":"96.04",
                                       "High":"96.88",
                                       "Low":"95.61",
                                       "Close":"95.97",
                                       "Volume":"33795000",
                                       "Adj_Close":"95.97"
                                      },
                                     {
                                       "Symbol":"AAPL",
                                       "Date":"2014-08-11",
                                       "Open":"95.27",
                                       "High":"96.08",
                                       "Low":"94.84",
                                       "Close":"95.99",
                                       "Volume":"36585000",
                                       "Adj_Close":"95.99"
                                      }
                                    ]
                           }
          }
    }
    

    Nota Bene:

    人们可能会发现,成熟的查询处理重新包装了源自以下来源和后处理的数据源请求:

    http://ichart.finance.yahoo.com/table.csv?g=d&f=2014&e=12&c=2014&b=10&a=7&d=7&s=AAPL

    屈服:

    Date,Open,High,Low,Close,Volume,Adj Close
    2014-08-12,96.04,96.88,95.61,95.97,33795000,95.97
    2014-08-11,95.27,96.08,94.84,95.99,36585000,95.99
    

    Per aspera Ad Astra ...(...更多 GHz,更多 TB,更多 Gbps,更多...,更多...,摩尔!)

    【讨论】:

    • 请告诉我您为此使用了哪些文档。在我用谷歌搜索的每个地方,人们都在为雅虎财经使用不同的网址和不同的查询格式,但我找不到任何明确的信息。
    • 是的,Google 包含很多东西,但并不总是正确的答案...请随时 @Richard 提出问题
    • 有人提问了吗?因为我也对答案感兴趣?
    • @EugenevanderMerwe 我向 Stellenbosch、ZX-81 和 NetWare 3.x 致敬,这是您故事的一部分。根据你的问题,没有。据我所知,没有提出这样的问题。
    • Yahoo! query web service docsYQL Docs(尝试控制台)可能会有所帮助。我找到的最全的YQL数据表列表is on github
    猜你喜欢
    • 2016-08-13
    • 2011-03-23
    • 1970-01-01
    • 2023-03-10
    • 1970-01-01
    • 1970-01-01
    • 2010-10-19
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多