pilwon / node-yahoo-finance

Yahoo Finance historical quotes and snapshot data downloader written in Node.js
495 stars 123 forks source link

How to get historical data of last hour #77

Open MehbubRashid opened 3 years ago

MehbubRashid commented 3 years ago

How can i get historical data of last hour?

gadicc commented 3 years ago

Not sure if this is possible, but keep an eye on https://github.com/pilwon/node-yahoo-finance/pull/76.

Otherwise maybe through the chart data but we don't have an API for that (yet).

jasonjason1207 commented 3 years ago

1) Got a question while looking into the library. What is period "v"?
if (!_.includes(['d', 'w', 'm', 'v'], options.period)) { throw new Error('"options.period" must be "d", "w", "m", or "v".'); }

d - day w - week m - month v - what is v ?

2) And, is there any way to indicate what currency the data is?

gadicc commented 3 years ago

@jasonjason1207 if you look a few lines further down you'll see:

  // Convert to yahoo v7 API
  switch (options.period) {
    case 'd': options.period = '1d'; break;
    case 'w': options.period = '1wk'; break;
    case 'm': options.period = '1mo'; break;
    case 'v': options.period = '1d'; options.events = 'div'; break;
    // No default case needed, options are sanitized above.
  }

So actually the 'v' option is from the previous Yahoo API but was kept for consistency so as to not introduce a breaking change into the current major version of node-yahoo-finance. It sets the period to 1d and requests that Dividend events be included in the history.

And, is there any way to indicate what currency the data is?

Not in the history request, but you can map this later to a quote request after.

If you're just starting off, check out https://github.com/gadicc/node-yahoo-finance2 which is the beta release of what will likely be our next major release. The quote API there is a little more developed and you can query all the symbols in a single network request.