Code Monkey home page Code Monkey logo

yahoo-stocks's Introduction

yahoo-stocks

Travis Coveralls branch license

Fetch stock data from Yahoo! Finance

Install

$ npm install --save yahoo-stocks

Usage

import { lookup, history } from 'yahoo-stocks';

lookup('AAPL').then(response => {
    console.log(response);
});

history('AAPL').then(response => {
    console.log(response);
});

API

lookup(symbol)

Returns a Promise that resolves the data for the symbol.

symbol

Type: String

The stock symbol.

history(symbol, [options])

Returns a Promise that resolves the price history for the symbol.

symbol

Type: String

The stock symbol.

options

Type: Object

A dictionary of customizable options

  • interval - Set the interval for the price changes, e.g. 1m, 1d, 5d, 1mo, 1y.
  • range - Set the range of dates to include in the output, value values are: 1d, 5d, 1mo, 3mo, 6mo, 1y, 2y, 5y, 10y, ytd, max

License

MIT © Vu Tran

yahoo-stocks's People

Contributors

cm45t3r avatar rmzg avatar vutran avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

yahoo-stocks's Issues

limits?

@vutran Have you encountered any limitations with this by any chance? Sick find btw =]

SyntaxError: Cannot use import statement outside a module

❯ node test.js
(node:87472) Warning: To load an ES module, set "type": "module" in the package.json or use the .mjs extension.
(Use `node --trace-warnings ...` to show where the warning was created)
/home/alper/doo/test.js:1
import { lookup, history } from 'yahoo-stocks';
^^^^^^

SyntaxError: Cannot use import statement outside a module
    at wrapSafe (internal/modules/cjs/loader.js:1001:16)
    at Module._compile (internal/modules/cjs/loader.js:1049:27)
    at Object.Module._extensions..js (internal/modules/cjs/loader.js:1114:10)
    at Module.load (internal/modules/cjs/loader.js:950:32)
    at Function.Module._load (internal/modules/cjs/loader.js:790:14)
    at Function.executeUserEntryPoint [as runMain] (internal/modules/run_main.js:76:12)
    at internal/main/run_main_module.js:17:47

.lookup function is broken

Tried to use the API: the lookup function no longer works but the history function works as expected. I've used this back in 2019 and everything worked fine.
My code

var stockAPI = require('yahoo-stocks');

stockAPI.lookup('AAPL').then(response => {
    console.log(response);
});

This is the output:

image

TypeError: Cannot read property 'map' of undefined

$ cat test.js
//import { lookup, history } from 'yahoo-stocks';
const { lookup, history } = require('yahoo-stocks');

lookup('AAPL').then(response => {
    console.log(response);
});

history('AAPL').then(response => {
    console.log(response);
});

$ node test.js
(node:22255) UnhandledPromiseRejectionWarning: Unhandled promise rejection (rejection id: 1): TypeError: Cannot read property 'map' of undefined
(node:22255) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

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.