-
Notifications
You must be signed in to change notification settings - Fork 50
Closed
Labels
bugSomething isn't workingSomething isn't working
Description
Describe the bug
Rate Limitation is not correctly being detected and reported
To Reproduce
Run the snippet of code below multiple times until you hit your rate limit:
API_KEY := os.Getenv("POLYGON_API_KEY")
client := polygon.New(API_KEY)
adjusted := true
limit := 50000
from := time.Now().AddDate(-2, 0, 0)
to := time.Now()
params := models.ListAggsParams{
Ticker: "AAPL",
From: models.Millis(from),
To: models.Millis(to),
Limit: &limit,
Adjusted: &adjusted,
Timespan: models.Day,
Multiplier: 1,
}
iter := client.ListAggs(context.TODO(), ¶ms, models.WithTrace(true))
count := 0
for iter.Next() {
if iter.Err() != nil {
log.Fatal(iter.Err())
}
count += 1
}
log.Printf("Found %d results", count)
Expected behavior
When rate limitation is reached, iter.Err
contains an error stating that the rate limitation has been encountered
Screenshots
Output from the snipped above:
Additional context
I've tried this several different ways, but there's not "good" way to detect the rate limitation, and we cannot inspect the response inside of the Polygon.io client.
Metadata
Metadata
Assignees
Labels
bugSomething isn't workingSomething isn't working