GithubHelp home page GithubHelp logo

hhy5277 / node-yahoo-finance Goto Github PK

View Code? Open in Web Editor NEW

This project forked from pilwon/node-yahoo-finance

0.0 1.0 0.0 370 KB

Yahoo Finance historical quotes and snapshot data downloader written in Node.js

JavaScript 100.00%

node-yahoo-finance's Introduction

PLEASE READ: This library is partially broken due to sudden API change by Yahoo Finance. The fantastic @gadicc is currently working on a fix to support the new API. Please follow PR #42 for the progress.

yahoo-finance

yahoo-finance is Yahoo Finance historical quotes and snapshot data downloader written in Node.js.

The library handles fetching, parsing, and cleaning of CSV data and returns JSON result that is convenient and easy to work with. Both callback (last parameter) and promises (using Bluebird) styles are supported.

Also check out google-finance.

Important: New Yahoo API

Yahoo completely replaced their API on 2017-05-16. This interim release is intended to get you up and running again quickly, but we're still working on it. Note also that Yahoo stopped supporting their API for developers some time ago, so no guarantees can be made about service availability, but probably this package will keep working thanks to the magic of open-source. Regarding the package API:

  • historical() - should work as expected - please check the output and report any inconsistencies.

  • snapshot() - deprecated - returns the original format for SOME old options via a mapping layer. Since Yahoo's new API does not contain all the same data as the old version, 100% compatibility is impossible - but for the most common options, this should ease upgrade pains. When you can, transition to the new quote() API instead.

  • quote() - NEW API more faithful to Yahoo's new API. See below. This replaces snapshot() and we suggest you use it instead.

Installation

$ npm install --save yahoo-finance

Usage

var yahooFinance = require('yahoo-finance');

yahooFinance.historical({
  symbol: 'AAPL',
  from: '2012-01-01',
  to: '2012-12-31',
  // period: 'd'  // 'd' (daily), 'w' (weekly), 'm' (monthly), 'v' (dividends only)
}, function (err, quotes) {
  //...
});

// This replaces the deprecated snapshot() API
yahooFinance.quote({
  symbol: 'AAPL',
  modules: [ 'price', 'summaryDetail' ] // see the docs for the full list
}, function (err, quotes) {
  // ...
});

API

Download Historical Data (single symbol)

yahooFinance.historical({
  symbol: SYMBOL,
  from: START_DATE,
  to: END_DATE
}, function (err, quotes) {
  /*
  [
    {
      date: Thu Nov 07 2013 00:00:00 GMT-0500 (EST),
      open: 45.1,
      high: 50.09,
      low: 44,
      close: 44.9,
      volume: 117701700,
      adjClose: 44.9,
      symbol: 'TWTR'
    },
    ...
    {
      date: Thu Nov 14 2013 00:00:00 GMT-0500 (EST),
      open: 42.34,
      high: 45.67,
      low: 42.24,
      close: 44.69,
      volume: 11090800,
      adjClose: 44.69,
      symbol: 'TWTR'
    }
  ]
  */
});

Download Historical Data (multiple symbols)

yahooFinance.historical({
  symbols: [SYMBOL1, SYMBOL2],
  from: START_DATE,
  to: END_DATE
}, function (err, result) {
  /*
  {
    YHOO: [
      {
        date: Fri Apr 12 1996 00:00:00 GMT-0400 (EDT),
        open: 25.25,
        high: 43,
        low: 24.5,
        close: 33,
        volume: 408720000,
        adjClose: 1.38,
        symbol: 'YHOO'
      },
      ...
      {
        date: Thu Nov 14 2013 00:00:00 GMT-0500 (EST),
        open: 35.07,
        high: 35.89,
        low: 34.76,
        close: 35.69,
        volume: 21368600,
        adjClose: 35.69,
        symbol: 'YHOO'
      }
    ],
    GOOGL: [
      {
        date: Thu Aug 19 2004 00:00:00 GMT-0400 (EDT),
        open: 100,
        high: 104.06,
        low: 95.96,
        close: 100.34,
        volume: 22351900,
        adjClose: 100.34,
        symbol: 'GOOGL'
      },
      ...
      {
        date: Thu Nov 14 2013 00:00:00 GMT-0500 (EST),
        open: 1033.92,
        high: 1039.75,
        low: 1030.35,
        close: 1035.23,
        volume: 1166700,
        adjClose: 1035.23,
        symbol: 'GOOGL'
      }
    ],
    ...
  }
  */
});

Specifying request options

Optionally request options (such as a proxy) can be specified by inserting an extra parameter just before the callback:

var httpRequestOptions = {
  proxy: 'http://localproxy.com'
};


yahooFinance.historical({
  symbol: SYMBOL,
  from: START_DATE,
  to: END_DATE
}, httpRequestOptions, function (err, quotes) {
  // Result
});


yahooFinance.quote({
  symbol: SYMBOL,
  modules: MODULES  // ex: ['price', 'summaryDetail']
}, httpRequestOptions, function (err, snapshot) {
  // Result
});

Credits

See the contributors.

  • Special thanks to @gadicc who brought the broken library back to life when Yahoo suddently changed their API. (check out his hero work at PR #37, #41, and #42)

License

The MIT License (MIT)

Copyright (c) 2013-2017 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 above 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

node-yahoo-finance's People

Contributors

ajbarry avatar beastlytheos avatar biggestt avatar brianedgerton avatar buzzcloudau avatar capsl avatar dylants avatar gadicc avatar idants avatar neverfox avatar pilwon avatar richie765 avatar yagop avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.