Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feat/historical v8 #328

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ const results = await yahooFInance.search('AAPL', { someOption: true, etc });
Available modules:
[`autoc`](./docs/modules/autoc.md),
[`historical`](./docs/modules/historical.md),
[_historicalv8(./docs/modules/_historicalv8.md),
[`quote`](./docs/modules/quote.md),
[`quoteSummary`](./docs/modules/quoteSummary.md) (submodules:
assetProfile, balanceSheetHistory, balanceSheetHistoryQuarterly,
Expand Down
104 changes: 104 additions & 0 deletions docs/modules/_historicalv8.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
# _historicalv8

**IMPORTANT** This module is not production ready and may change at any time.
It uses a newer Yahoo Finance API to fetch historical prices, splits, and
dividends all in one network request. The historical module can fetch prices,
dividends, and splits as well but it requires three network requests.

## Usage:

```js
import yahooFinance from 'yahoo-finance2';

const query = 'AAPL';
const queryOptions = {
period1: '2020-01-03',
period2: '2021-01-04',
events: 'div|split' // 'div', 'split', or 'div|split'
}
const result = await yahooFinance._historicalv8(query, queryOptions);

// NOTE the output format is different from that of the historical module
{
meta: {
currency: 'USD',
symbol: 'AAPL',
exchangeName: 'NMS',
instrumentType: 'EQUITY',
firstTradeDate: 1980-12-12T14:30:00.000Z,
regularMarketTime: 2021-11-12T21:00:03.000Z,
gmtoffset: -18000,
timezone: 'EST',
exchangeTimezoneName: 'America/New_York',
regularMarketPrice: 149.99,
chartPreviousClose: 75.088,
priceHint: 2,
currentTradingPeriod: { pre: [Object], regular: [Object], post: [Object] },
dataGranularity: '1d',
range: '',
validRanges: [
'1d', '5d', '1mo',
'3mo', '6mo', '1y',
'2y', '5y', '10y',
'ytd', 'max'
]
},
quote: [
{
date: 2020-01-03T14:30:00.000Z,
open: 74.2874984741211,
close: 74.35749816894531,
high: 75.1449966430664,
low: 74.125,
volume: 146322800,
adjClose: 73.26914978027344
},
{
date: 2020-01-06T14:30:00.000Z,
open: 73.44750213623047,
close: 74.94999694824219,
high: 74.98999786376953,
low: 73.1875,
volume: 118387200,
adjClose: 73.85298156738281
},
// ... more omitted
],
splits: [
{
date: 2020-08-31T13:30:00.000Z,
numerator: 4,
denominator: 1,
splitRatio: '4:1'
}
],
dividends: [
{ amount: 0.1925, date: 2020-02-07T14:30:00.000Z },
{ amount: 0.205, date: 2020-05-08T13:30:00.000Z },
{ amount: 0.205, date: 2020-08-07T13:30:00.000Z },
{ amount: 0.205, date: 2020-11-06T14:30:00.000Z }
]
}


```

## API

```js
await yahooFinance._historicalv8(query, queryOptions, moduleOptions);
```

### Query term

Symbol, company name, SEDOL, etc

### Query Options

As in the historical module with one difference:

The events property can be "div", "split", or "div|split".

### Module Options

See [Common Options](../README.md#common-options).
Loading