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

Yahoo Finance v7 API (since 2017-05-16) - initial work (1/3) #37

Merged
merged 28 commits into from
May 25, 2017
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
28 commits
Select commit Hold shift + click to select a range
77f9e3e
initial work
gadicc May 17, 2017
1979f9b
support rest of 'period' options
gadicc May 17, 2017
70e8084
Catch and default
buzzcloudau May 18, 2017
aa4c1f0
Merge pull request #1 from buzzcloudau/patch-1
gadicc May 18, 2017
0e9d353
initial snapshot() work
gadicc May 18, 2017
9e4f30d
add some more resiliency and warnings to parseAndGetCrumb()
gadicc May 18, 2017
072c6ca
index: snapshot: remove console.log, change internal structure
gadicc May 21, 2017
8b9bac2
initial test framework (mocha/chai/babel) - unit + integration tests
gadicc May 21, 2017
bd9f1a4
move augmentHttpRequestOptions to utils
gadicc May 21, 2017
13b8b07
add a quote() method more faithful to current yahoo api
gadicc May 21, 2017
09e74a8
move cookies to utils, update on every request; rename yahooCrumb.js
gadicc May 22, 2017
851062d
crumb: fetch new crumb if the cookie is expired
gadicc May 22, 2017
bb46cdc
quote dividends, started snapshot fields._map, quote_MSFT.json
gadicc May 23, 2017
31e6946
fields: invert trailing/forward PE (thanks marcoschwartz)
gadicc May 23, 2017
9ae1ba8
fields: add missing comma before _map
gadicc May 23, 2017
f528313
quote->fetchQuote; convert dates; fetchQuote(symbol,modules)
gadicc May 23, 2017
cfa669c
quote -> fetchQuote
gadicc May 24, 2017
0909797
consolidate test functions in testUtils, move asserts to index
gadicc May 24, 2017
8b34272
yahooCrumb: replace console.log with debug() calls
gadicc May 24, 2017
3e40f01
index: historical: remove TODO tag, default to '1d' vs 'd'
gadicc May 24, 2017
cf46926
re-export quote from index
gadicc May 24, 2017
504a3e2
fix integration test from consolidated tests
gadicc May 24, 2017
3a082b6
update README, add some (temporary) warnings to all methods
gadicc May 24, 2017
fab4cc9
docs/quote: show the regular API first, more prominently
gadicc May 24, 2017
7f054c6
docs/quote: show Dates in sample output; shorten upgradeDowngrade
gadicc May 24, 2017
26d9377
commit accidentally un-addded docs/snapshot.md
gadicc May 24, 2017
06fe40f
README: a few more notes about current API state
gadicc May 24, 2017
e131130
docs/snapshot: deprecation notice
gadicc May 24, 2017
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
9 changes: 9 additions & 0 deletions .babelrc
Original file line number Diff line number Diff line change
@@ -0,0 +1,9 @@
{
"presets": [
["env", {
"targets": {
"node": "current"
}
}]
]
}
227 changes: 25 additions & 202 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,20 @@ The library handles fetching, parsing, and cleaning of CSV data and returns JSON
Also check out [google-finance](https://github.com/pilwon/node-google-finance).


## NB: Yahoo API

Yahoo's API has completely changed recently. This interim release is intended to get you up and running again quickly, but we're still working on it. Note also that Yahoo have stopped supporting their API for developers, so no guarantees can be made about service availability. This package relies entirely on open source contributions. Regarding this package's API:

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

* `snapshot()` - disabled in this release. It will be enabled again in the next release with a compatibility layer for SOME options. Since Yahoo's new API does not contain all the same data as the old version, 100% compatibility is impossible. As such, snapshot() is DEPRECATED and we suggest you switch to the new `quote()` API. However, the upcoming release should provide an easier upgrade for the most common use cases.

* `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 yahoo-finance
$ npm install --save yahoo-finance


## Usage
Expand All @@ -26,16 +37,23 @@ yahooFinance.historical({
//...
});

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

```

* [See more comprehensive examples here.](https://github.com/pilwon/node-yahoo-finance/tree/master/examples)

* See the [full quote() docs](docs/quote.md) for the list of all possible
modules and the data they return.

* See also the [deprecated snapshot() API](docs/snapshot.md) docs, for
reference.

## API

Expand Down Expand Up @@ -137,201 +155,6 @@ yahooFinance.historical({
});
```

### Download Snapshot Data (single symbol)

```js
yahooFinance.snapshot({
symbol: SYMBOL,
fields: FIELDS // ex: ['s', 'n', 'd1', 'l1', 'y', 'r']
}, function (err, snapshot) {
/*
{
symbol: 'AAPL',
name: 'Apple Inc.',
lastTradeDate: '11/15/2013',
lastTradePriceOnly: '524.88',
dividendYield: '2.23',
peRatio: '13.29'
}
*/
});
```

### Download Snapshot Data (multiple symbols)

```js
yahooFinance.snapshot({
symbols: [SYMBOL1, SYMBOL2],
fields: FIELDS // ex: ['s', 'n', 'd1', 'l1', 'y', 'r']
}, function (err, snapshot) {
/*
{
AAPL: {
symbol: 'AAPL',
name: 'Apple Inc.',
lastTradeDate: '11/15/2013',
lastTradePriceOnly: '524.88',
dividendYield: '2.23',
peRatio: '13.29'
},
GOOGL: {
symbol: 'GOOGL',
name: 'Google Inc.',
lastTradeDate: '11/15/2013',
lastTradePriceOnly: '1034.23',
dividendYield: 'N/A',
peRatio: '28.17'
}
}
*/
});
```



### Fields

```
s: Symbol
```

#### Pricing

```
a: Ask
b: Bid
b2: Ask (Realtime)
b3: Bid (Realtime)
p: Previous Close
o: Open
```

#### Dividends

```
y: Dividend Yield
d: Dividend Per Share
r1: Dividend Pay Date
q: Ex-Dividend Date
```

#### Date

```
c1: Change
c: Change And Percent Change
c6: Change (Realtime)
k2: Change Percent (Realtime)
p2: Change in Percent
d1: Last Trade Date
d2: Trade Date
t1: Last Trade Time
```

#### Averages

```
c8: After Hours Change (Realtime)
c3: Commission
g: Day’s Low
h: Day’s High
k1: Last Trade (Realtime) With Time
l: Last Trade (With Time)
l1: Last Trade (Price Only)
t8: 1 yr Target Price
m5: Change From 200-day Moving Average
m6: Percent Change From 200-day Moving Average
m7: Change From 50-day Moving Average
m8: Percent Change From 50-day Moving Average
m3: 50-day Moving Average
m4: 200-day Moving Average
```

#### Misc

```
w1: Day’s Value Change
w4: Day’s Value Change (Realtime)
p1: Price Paid
m: Day’s Range
m2: Day’s Range (Realtime)
g1: Holdings Gain Percent
g3: Annualized Gain
g4: Holdings Gain
g5: Holdings Gain Percent (Realtime)
g6: Holdings Gain (Realtime)
```

#### 52 Week Pricing

```
k: 52-week High
j: 52-week Low
j5: Change From 52-week Low
k4: Change From 52-week High
j6: Percent Change From 52-week Low
k5: Percebt Change From 52-week High
w: 52-week Range
```

#### System Info

```
i: More Info
j1: Market Capitalization
j3: Market Cap (Realtime)
f6: Float Shares
n: Name
n4: Notes
s1: Shares Owned
x: Stock Exchange
j2: Shares Outstanding
```

#### Volume

```
v: Volume
a5: Ask Size
b6: Bid Size
k3: Last Trade Size
a2: Average Daily Volume
```

#### Ratio

```
e: Earnings Per Share
e7: EPS Estimate Current Year
e8: EPS Estimate Next Year
e9: EPS Estimate Next Quarter
b4: Book Value
j4: EBITDA
p5: Price per Sales
p6: Price per Book
r: PE Ratio
r2: PE Ratio (Realtime)
r5: PEG Ratio
r6: Price Per EPS Estimate Current Year
r7: Price Per EPS Estimate Next Year
s7: Short Ratio
```

#### Misc

```
t7: Ticker Trend
t6: Trade Links
i5: Order Book (Realtime)
l2: High Limit
l3: Low Limit
v1: Holdings Value
v7: Holdings Value (Realtime)
s6: Revenue
e1: Error Indication (returned for symbol changed or invalid)
```


### Specifying request options

Optionally request options (such as a proxy) can be specified by inserting an
Expand All @@ -353,9 +176,9 @@ yahooFinance.historical({
});


yahooFinance.snapshot({
yahooFinance.quote({
symbol: SYMBOL,
fields: FIELDS // ex: ['s', 'n', 'd1', 'l1', 'y', 'r']
modules: MODULES // ex: ['price', 'summaryDetail']
}, httpRequestOptions, function (err, snapshot) {
// Result
});
Expand Down
Loading