Skip to content

Commit 10e17ae

Browse files
author
Shlomi Kushchi
authored
Merge pull request #255 from alpacahq/doc-add-historic-agg-minutes
Example of using historic_agg_v2 with minute bar
2 parents 3aeccd1 + 53bb629 commit 10e17ae

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

README.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -303,6 +303,17 @@ aapl = api.polygon.historic_agg_v2('AAPL', 1, 'day', _from=datetime.date(2019, 1
303303
aapl = api.polygon.historic_agg_v2('AAPL', 1, 'day', _from=pd.Timestamp('2019-01-01'), to='2019-02-01').df
304304
# timestamp should be in milliseconds datetime.datetime(2019, 1, 1).timestamp()*1000 == 1546293600000
305305
aapl = api.polygon.historic_agg_v2('AAPL', 1, 'day', _from=1546293600000, to='2019-02-01').df
306+
```
307+
and here's a minute example usage:
308+
```py
309+
import pytz
310+
NY = 'America/New_York'
311+
312+
start = pytz.timezone(NY).localize(datetime(2020,1,2,9,30)).timestamp()*1000 # timestamp in micro seconds
313+
# another alternative will be: start = pd.Timestamp('2020-01-02 09:30', tz=NY).value/1e6
314+
end = pytz.timezone(NY).localize(datetime(2020,1,2,16,0)).timestamp()*1000
315+
df = api.polygon.historic_agg_v2('AAPL', 1, 'minute', _from=start, to=end).df
316+
306317
```
307318

308319
## polygon/REST

0 commit comments

Comments
 (0)