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

Feature/add batch support #35

Merged
merged 4 commits into from
Jan 3, 2018
Merged
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
4 changes: 4 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -37,3 +37,7 @@
BREAKING
- Changing the daily adjusted data to be under the daily_adjusted namespace from
adjusted

1.1.0
- Adding batch quote support
- Updating jest to 22.0.4
5 changes: 5 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,10 @@ alpha.data.intraday(`msft`).then(data => {
console.log(data);
});

alpha.data.batch([`msft`, `aapl`]).then(data => {
console.log(data);
});

alpha.forex.rate('btc', 'usd').then(data => {
console.log(data);
})
Expand Down Expand Up @@ -68,6 +72,7 @@ alpha.data.weekly(symbol, interval)
alpha.data.weekly_adjusted(symbol, interval)
alpha.data.monthly(symbol, interval)
alpha.data.monthly_adjusted(symbol, interval)
alpha.data.batch([symbol1, symbol2..])
```

## Forex
Expand Down
10 changes: 9 additions & 1 deletion lib/data.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,14 @@ module.exports = config => {
weekly: series('TIME_SERIES_WEEKLY'),
weekly_adjusted: series('TIME_SERIES_WEEKLY_ADJUSTED'),
monthly: series('TIME_SERIES_MONTHLY'),
monthly_adjusted: series('TIME_SERIES_MONTHLY_ADJUSTED')
monthly_adjusted: series('TIME_SERIES_MONTHLY_ADJUSTED'),
batch: symbols => {
// Convert array to csv string.
if (symbols instanceof Array) {
symbols = symbols.join(',');
}

return util.fn('BATCH_STOCK_QUOTES')({ symbols });
}
};
};
4 changes: 4 additions & 0 deletions lib/util.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ const keys = {
'Weekly Adjusted Time Series': 'data',
'Monthly Adjusted Time Series': 'data',
'Monthly Time Series': 'data',
'Stock Quotes': 'data',
'Technical Analysis: SMA': 'data',
'Technical Analysis: EMA': 'data',
'Technical Analysis: WMA': 'data',
Expand Down Expand Up @@ -120,6 +121,7 @@ const keys = {
'1. open': 'open',
'1b. price (USD)': 'usd',
'1b. open (USD)': 'usd_open',
'2. price': 'price',
'2. high': 'high',
'2. From_Currency Name': 'from_currency_name',
'2. Symbol': 'symbol',
Expand All @@ -132,13 +134,15 @@ const keys = {
'3. Last Refreshed': 'updated',
'3. Digital Currency Name': 'coin_name',
'3. market cap (USD)': 'cap',
'3. volume': 'volume',
'3b. low (USD)': 'usd_low',
'4. Output Size': 'size',
'4. To_Currency Name': 'to_currency_name',
'4. close': 'close',
'4. Interval': 'interval',
'4. Market Code': 'market',
'4. Time Zone': 'zone',
'4. timestamp': 'updated',
'4b. close (USD)': 'usd_close',
'5. adjusted close': 'adjusted',
'5. Exchange Rate': 'value',
Expand Down
Loading