Closed
Description
Describe the bug
The example code listed in the README runs BUT will fail near the end. My guess is because my "free" API key is hitting its query limit.
To Reproduce
- Make a python file with the example code.
- Run the file.
Expected behavior
The file should run without error/crashing.
Screenshots
This code will error using a "free" API key:
import os
from dotenv import load_dotenv
from polygon import RESTClient
load_dotenv()
def main():
client = RESTClient(api_key=os.getenv("API_KEY"))
ticker = "AAPL"
# List Aggregates (Bars)
aggs = []
for a in client.list_aggs(
ticker=ticker,
multiplier=1,
timespan="minute",
from_="2023-01-01",
to="2023-06-13",
limit=50000,
):
aggs.append(a)
print(aggs)
# Get Last Trade
trade = client.get_last_trade(ticker=ticker)
print(trade)
# List Trades
trades = client.list_trades(
ticker=ticker,
timestamp="2022-01-04",
)
for trade in trades:
print(trade)
# Get Last Quote
quote = client.get_last_quote(ticker=ticker)
print(quote)
# List Quotes
quotes = client.list_quotes(
ticker=ticker,
timestamp="2022-01-04",
)
for quote in quotes:
print(quote)
if __name__ == "__main__":
main()
I'm guessing that reducing the 'limit' value from 50,000 to just 5000 would fix the problem. I cannot confirm this as now I can't run any queries. (I waited over 30 minutes to try again but am still getting 429 errors.)