Skip to content

Commit 320bb79

Browse files
authored
Merge pull request #160 from alpacahq/feature/polygon-daily-oc
Add support for daily open/close Polygon endpoint
2 parents 1aed6c9 + 0a3ef95 commit 320bb79

File tree

3 files changed

+16
-9
lines changed

3 files changed

+16
-9
lines changed

alpaca_trade_api/polygon/entity.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -314,3 +314,7 @@ class NewsList(EntityList):
314314

315315
class Ticker(Entity):
316316
pass
317+
318+
319+
class DailyOpenClose(Entity):
320+
pass

alpaca_trade_api/polygon/rest.py

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,8 @@
44
Trade, Trades, TradesV2,
55
Quote, Quotes, QuotesV2,
66
Exchange, SymbolTypeMap, ConditionMap,
7-
Company, Dividends, Splits, Earnings, Financials, NewsList, Ticker
7+
Company, Dividends, Splits, Earnings, Financials, NewsList, Ticker,
8+
DailyOpenClose
89
)
910
from alpaca_trade_api.common import get_polygon_credentials
1011
from deprecated import deprecated
@@ -134,20 +135,18 @@ def historic_agg_v2(self, symbol, multiplier, timespan, _from, to,
134135
raw = self.get(path, params, version='v2')
135136
return Aggsv2(raw)
136137

137-
138-
def daily_open_close(self, symbol, date):
139-
path = '/open-close/{}/{}'.format(symbol, date)
140-
raw = self.get(path)
141-
return raw
142-
143-
144138
def grouped_daily(self, date, unadjusted=False):
145139
path = '/aggs/grouped/locale/US/market/STOCKS/{}'.format(date)
146140
params = {}
147141
params['unadjusted'] = unadjusted
148142
raw = self.get(path, params, version='v2')
149143
return Aggsv2Set(raw)
150144

145+
def daily_open_close(self, symbol, date):
146+
path = '/open-close/{}/{}'.format(symbol, date)
147+
raw = self.get(path)
148+
return DailyOpenClose(raw)
149+
151150
def last_trade(self, symbol):
152151
path = '/last/stocks/{}'.format(symbol)
153152
raw = self.get(path)

setup.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,11 @@
2323
author_email='oss@alpaca.markets',
2424
url='https://github.com/alpacahq/alpaca-trade-api-python',
2525
keywords='financial,timeseries,api,trade',
26-
packages=['alpaca_trade_api', 'alpaca_trade_api.polygon', 'alpaca_trade_api.alpha_vantage'],
26+
packages=[
27+
'alpaca_trade_api',
28+
'alpaca_trade_api.polygon',
29+
'alpaca_trade_api.alpha_vantage',
30+
],
2731
install_requires=[
2832
'asyncio-nats-client',
2933
'pandas',

0 commit comments

Comments
 (0)