Skip to content

Commit bdb2897

Browse files
authored
Merge pull request #40 from alpacahq/feature/polygon-v2-upgrade
Begin upgrade to v2 Polygon endpoints
2 parents 89d5837 + bae4b7e commit bdb2897

2 files changed

Lines changed: 24 additions & 0 deletions

File tree

lib/alpaca-trade-api.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,9 @@ Alpaca.prototype.getBars = bars.getBars
7979
Alpaca.prototype.getExchanges = polygon.exchanges
8080
Alpaca.prototype.getSymbolTypeMap = polygon.symbolTypeMap
8181
Alpaca.prototype.getHistoricTrades = polygon.historicTrades
82+
Alpaca.prototype.getHistoricTradesV2 = polygon.historicTradesV2
8283
Alpaca.prototype.getHistoricQuotes = polygon.historicQuotes
84+
Alpaca.prototype.getHistoricQuotesV2 = polygon.historicQuotesV2
8385
Alpaca.prototype.getHistoricAggregates = polygon.historicAggregates
8486
Alpaca.prototype.getHistoricAggregatesV2 = polygon.historicAggregatesV2
8587
Alpaca.prototype.getLastTrade = polygon.lastTrade

lib/resources/polygon.js

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,17 +11,37 @@ function symbolTypeMap() {
1111
}
1212

1313
// options: limit, offset
14+
/*
15+
* @deprecated Will be removed in a future release, and will be removed from the Polygon API. Please use historicTradesV2 instead.
16+
*/
1417
function historicTrades(symbol, date, options = {}) {
18+
console.warn('Calling deprecated function historicTrades. Please use historicTradesV2 instead.')
1519
const path = `/historic/trades/${symbol}/${toDateString(date)}`
1620
return this.polygonHttpRequest(path, options)
1721
}
1822

23+
// options: limit, timestamp, timestamp_limit, reverse
24+
function historicTradesV2(symbol, date, options = {}) {
25+
const path = `/ticks/stocks/trades/${symbol}/${toDateString(date)}`
26+
return this.polygonHttpRequest(path, options, null, null, 'v2')
27+
}
28+
1929
// options: limit, offset
30+
/*
31+
* @deprecated Will be removed in a future release, and will be removed from the Polygon API. Please use historicQuotesV2 instead.
32+
*/
2033
function historicQuotes(symbol, date, options = {}) {
34+
console.warn('Calling deprecated function historicQuotes. Please use historicQuotesV2 instead.')
2135
const path = `/historic/quotes/${symbol}/${toDateString(date)}`
2236
return this.polygonHttpRequest(path, options)
2337
}
2438

39+
// options: limit, timestamp, timestamp_limit, reverse
40+
function historicQuotesV2(symbol, date, options = {}) {
41+
const path = `ticks/stocks/nbbo/${symbol}/${toDateString(date)}`
42+
return this.polygonHttpRequest(path, options, null, null, 'v2')
43+
}
44+
2545
// size: 'day', 'minute'
2646
// options: from, to, limit, unadjusted
2747
function historicAggregates(size, symbol, options = {}) {
@@ -70,7 +90,9 @@ module.exports = {
7090
exchanges,
7191
symbolTypeMap,
7292
historicTrades,
93+
historicTradesV2,
7394
historicQuotes,
95+
historicQuotesV2,
7496
historicAggregates,
7597
historicAggregatesV2,
7698
lastTrade,

0 commit comments

Comments
 (0)