Skip to content

Commit

Permalink
Merge pull request #35 from zackurben/feature/add-batch-support
Browse files Browse the repository at this point in the history
Feature/add batch support
  • Loading branch information
zackurben committed Jan 3, 2018
2 parents d115eb3 + f21076c commit ba3fa64
Show file tree
Hide file tree
Showing 7 changed files with 1,537 additions and 980 deletions.
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

0 comments on commit ba3fa64

Please sign in to comment.