node-google-finance, 面向 node.js的Google财经客户端库

分享于 

13分钟阅读

GitHub

  繁體 雙語
Google Finance client library for Node.js.
  • 源代码名称:node-google-finance
  • 源代码网址:http://www.github.com/pilwon/node-google-finance
  • node-google-finance源代码文档
  • node-google-finance源代码下载
  • Git URL:
    git://www.github.com/pilwon/node-google-finance.git
    Git Clone代码到本地:
    git clone http://www.github.com/pilwon/node-google-finance
    Subversion代码到本地:
    $ svn co --depth empty http://www.github.com/pilwon/node-google-finance
    Checked out revision 1.
    $ cd repo
    $ svn up trunk
    
    google财经

    google-financeGoogle 公司新闻和历史报价数据下载器write在 node.js。

    库处理获取。解析和清理CSV数据,并返回方便且易于使用的JSON结果。 支持回调( 最后一个参数) 和 promise ( 使用蓝鸟 ) 样式。

    另外,请查阅雅虎雅虎财务网站。

    安装

    
    $ npm install google-finance
    
    
    
    

    用法

    var googleFinance =require('google-finance');googleFinance.companyNews({
     symbol:'NASDAQ:AAPL'}, function (err, news) {
     //...});googleFinance.historical({
     symbol:'NASDAQ:AAPL',
     from:'2014-01-01',
     to:'2014-12-31'}, function (err, quotes) {
     //...});

    API

    下载公司新闻数据( 单一符号)

    googleFinance.companyNews({
     symbol:SYMBOL}, function (err, news) {
     /* [ {"id":"52778621773856","symbol":"NASDAQ:AAPL","title":"After Apple Inc. dodged the iPhone 6 Plus BendGate bullet, detractors wounded.. .","description":"After Apple Inc. dodged the iPhone 6 Plus BendGate bullet, detractors wounded.. .n Apple Insider - Sep 27, 2014 nWith new, larger iPhone 6 models now hitting the market, one Samsung executive reportedly acknowledged that"the positive reaction from consumers to those two Apple devices" forced the company to rush its Note 4 launch ahead of schedule, adding"it's.. .nWill Apple's 'Bendgate' Give Samsung, BlackBerry An Opening? - Seeking Alpha (registration)","summary":"After Apple Inc. dodged the iPhone 6 Plus BendGate bullet, detractors wounded.. .n Apple Insider - Sep 27, 2014 nWith new, larger iPhone 6 models now hitting the market, one Samsung executive reportedly acknowledged that"the positive reaction from consumers to those two Apple devices" forced the company to rush its Note 4 launch ahead of schedule, adding"it's.. .nWill Apple's 'Bendgate' Give Samsung, BlackBerry An Opening? - Seeking Alpha (registration)","date":"2014-09-27T06:23:41.000Z","link":"http://appleinsider.com/articles/14/09/27/after-apple-inc-dodged-the-iphone-6-plus-bendgate-bullet-detractors-wounded-by-ricochet" }. . . {"id":"//www.fool.com/investing/general/2014/10/01/the-death-of-apple-incs-i.aspx","symbol":"NASDAQ:AAPL","title":"The Death of Apple, Inc's"i" Branding","description":"The Death of Apple, Inc's"i" Brandingn Motley Fool - 27 minutes ago nIn a recent blog post, he notes that neither of the two new products Apple unveiled earlier this month carried the iBranding, with the company instead opting for"Apple Pay"and"Apple Watch." Segall believes that the only explanation for this is that.. .","summary":"The Death of Apple, Inc's"i" Brandingn Motley Fool - 27 minutes ago nIn a recent blog post, he notes that neither of the two new products Apple unveiled earlier this month carried the iBranding, with the company instead opting for"Apple Pay"and"Apple Watch." Segall believes that the only explanation for this is that.. .","date":"2014-10-01T21:45:00.000Z","link":"http://www.fool.com/investing/general/2014/10/01/the-death-of-apple-incs-i.aspx" } ]*/});

    下载公司新闻数据( 多个符号)

    googleFinance.companyNews({
     symbols: [SYMBOL1, SYMBOL2]
    }, function (err, news) {
     /* {"NASDAQ:AAPL": [ {"id":"52778621773856","symbol":"NASDAQ:AAPL","title":"After Apple Inc. dodged the iPhone 6 Plus BendGate bullet, detractors wounded.. .","description":"After Apple Inc. dodged the iPhone 6 Plus BendGate bullet, detractors wounded.. .n Apple Insider - Sep 27, 2014 nWith new, larger iPhone 6 models now hitting the market, one Samsung executive reportedly acknowledged that"the positive reaction from consumers to those two Apple devices" forced the company to rush its Note 4 launch ahead of schedule, adding"it's.. .nWill Apple's 'Bendgate' Give Samsung, BlackBerry An Opening? - Seeking Alpha (registration)","summary":"After Apple Inc. dodged the iPhone 6 Plus BendGate bullet, detractors wounded.. .n Apple Insider - Sep 27, 2014 nWith new, larger iPhone 6 models now hitting the market, one Samsung executive reportedly acknowledged that"the positive reaction from consumers to those two Apple devices" forced the company to rush its Note 4 launch ahead of schedule, adding"it's.. .nWill Apple's 'Bendgate' Give Samsung, BlackBerry An Opening? - Seeking Alpha (registration)","date":"2014-09-27T06:23:41.000Z","link":"http://appleinsider.com/articles/14/09/27/after-apple-inc-dodged-the-iphone-6-plus-bendgate-bullet-detractors-wounded-by-ricochet" }. . . {"id":"//www.fool.com/investing/general/2014/10/01/the-death-of-apple-incs-i.aspx","symbol":"NASDAQ:AAPL","title":"The Death of Apple, Inc's"i" Branding","description":"The Death of Apple, Inc's"i" Brandingn Motley Fool - 29 minutes ago nIn a recent blog post, he notes that neither of the two new products Apple unveiled earlier this month carried the iBranding, with the company instead opting for"Apple Pay"and"Apple Watch." Segall believes that the only explanation for this is that.. .","summary":"The Death of Apple, Inc's"i" Brandingn Motley Fool - 29 minutes ago nIn a recent blog post, he notes that neither of the two new products Apple unveiled earlier this month carried the iBranding, with the company instead opting for"Apple Pay"and"Apple Watch." Segall believes that the only explanation for this is that.. .","date":"2014-10-01T21:45:00.000Z","link":"http://www.fool.com/investing/general/2014/10/01/the-death-of-apple-incs-i.aspx" } ],"NYSE:TWTR": [ {"id":"//www.benzinga.com/tech/14/09/4854209/why-is-twitter-inc-borrowing-more-money","symbol":"NYSE:TWTR","title":"Why Is Twitter Inc Borrowing More Money?","description":"Why Is Twitter Inc Borrowing More Money?n Benzinga - Sep 16, 2014 nTwitter Inc (NYSE: TWTR) is borrowing $1.5 billion to expand the business, but is it wise for the company to take on new debt?","summary":"Why Is Twitter Inc Borrowing More Money?n Benzinga - Sep 16, 2014 nTwitter Inc (NYSE: TWTR) is borrowing $1.5 billion to expand the business, but is it wise for the company to take on new debt?","date":"2014-09-16T21:22:30.000Z","link":"http://www.benzinga.com/tech/14/09/4854209/why-is-twitter-inc-borrowing-more-money" }. . . {"id":"52778622630300","symbol":"NYSE:TWTR","title":"Making Twitter Inc (TWTR) A Friendly Place","description":"Making Twitter Inc (TWTR) A Friendly Placen ETF Daily News - 5 hours ago ntwitter Discussing the problems Twitter Inc (NYSE:TWTR) faces within the social media network, with author of"Hatching Twitter" Nick Bilton.nDrama at Twitter Inc (TWTR) Has Subsided Under The New Management: Nick.. . - Insider Monkey (blog)","summary":"Making Twitter Inc (TWTR) A Friendly Placen ETF Daily News - 5 hours ago ntwitter Discussing the problems Twitter Inc (NYSE:TWTR) faces within the social media network, with author of"Hatching Twitter" Nick Bilton.nDrama at Twitter Inc (TWTR) Has Subsided Under The New Management: Nick.. . - Insider Monkey (blog)","date":"2014-10-01T16:18:45.000Z","link":"http://etfdailynews.com/2014/10/01/making-twitter-inc-twtr-a-friendly-place/" } ] }*/});

    下载历史数据( 单个符号)

    googleFinance.historical({
     symbol:SYMBOL,
     from:START_DATE,
     to:END_DATE}, function (err, quotes) {
     /* [ {"date":"2014-01-02T05:00:00.000Z","open": 79.38,"high": 79.58,"low": 78.86,"close": 79.02,"volume": 58791957,"symbol":"NASDAQ:AAPL" }. . . {"date":"2014-10-01T04:00:00.000Z","open": 100.59,"high": 100.69,"low": 98.7,"close": 99.18,"volume": 51304344,"symbol":"NASDAQ:AAPL" } ]*/});

    下载历史数据( 多个符号)

    googleFinance.historical({
     symbols: [SYMBOL1, SYMBOL2],
     from:START_DATE,
     to:END_DATE}, function (err, result) {
     /* {"NASDAQ:GOOGL": [ {"date":"2014-01-02T05:00:00.000Z","open": 558.29,"high": 559.43,"low": 554.68,"close": 557.12,"volume": 1822719,"symbol":"NASDAQ:GOOGL" }. . . {"date":"2014-10-01T04:00:00.000Z","open": 586.8,"high": 588.72,"low": 578.02,"close": 579.63,"volume": 1444055,"symbol":"NASDAQ:GOOGL" } ],"NASDAQ:YHOO": [ {"date":"2014-01-02T05:00:00.000Z","open": 40.37,"high": 40.49,"low": 39.31,"close": 39.59,"volume": 21514650,"symbol":"NASDAQ:YHOO" }. . . {"date":"2014-10-01T04:00:00.000Z","open": 40.66,"high": 41.24,"low": 40.11,"close": 40.32,"volume": 35130364,"symbol":"NASDAQ:YHOO" } ],. . . }*/});

    指定请求选项

    可以通过在回调之前插入额外参数来指定请求选项( 例如代理):

    var httpRequestOptions = {
     proxy:'http://localproxy.com'};googleFinance.companyNews({
     symbol:SYMBOL}, httpRequestOptions, function (err, news) {
     // Result});googleFinance.historical({
     symbol:SYMBOL,
     from:START_DATE,
     to:END_DATE}, httpRequestOptions, function (err, quotes) {
     // Result});

    Credits

    请参见 contributor

    许可证

    The MIT License (MIT)
    Copyright (c) 2014-2016 Pilwon Huh
    Permission is hereby granted, free of charge, to any person obtaining a copy
    of this software and associated documentation files (the"Software"), to deal
    in the Software without restriction, including without limitation the rights
    to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
    copies of the Software, and to permit persons to whom the Software is
    furnished to do so, subject to the following conditions:
    The 上面 copyright notice and this permission notice shall be included in
    all copies or substantial portions of the Software.
    THE SOFTWARE IS PROVIDED"AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
    IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
    FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
    AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
    LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
    OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
    THE SOFTWARE.

    Analytics