alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
142 stars 13 forks source link

Polygon Quote Data -- 18 month cap? #78

Closed gsko closed 5 years ago

gsko commented 5 years ago

When accessing Polygon historical quote data, I seem to hit an 18 month cap. Is this expected behavior? If so, can you please point me to the Alpaca documentation that describes this?

Today is 2019-07-14, and I'm able to access data after/including 2018-01-16, but fail to access anything before/including: 2018-01-12. (The specific error is copy pasted below)

Error when accessing data a few days older than 18 months:

Traceback (most recent call last):
  File "./alpaca.py", line 18, in <module>
    print(p/oly.historic_quotes(symbol, date, limit=num_quotes))
  File "/usr/lib/python3.7/site-packages/alpaca_trade_api/polygon/rest.py", line 63, in historic_quotes
    return Quotes(raw)
  File "/usr/lib/python3.7/site-packages/alpaca_trade_api/polygon/entity.py", line 166, in __init__
    for tick in raw['ticks']
TypeError: 'NoneType' object is not iterable

Script used to query alpaca/polygon:

#!/usr/bin/env python3
import alpaca_trade_api as tradeapi
api = tradeapi.REST(key_id, secret_key, api_version='v2')
poly = api.polygon
symbol = "AMZN"
date = "2018-1-16"
num_quotes = 10
print(poly.historic_quotes(symbol, date, limit=num_quotes))

As always, thanks for making such a great service! Look forward to your response.

ttt733 commented 5 years ago

Polygon's API is a separate service from Alpaca - you can ask their support directly at support@polygon.io. However, we have heard from them that data back to 2001 should become available in the next few weeks.