stock list_aggs throw errors
I am using version: 1.14.6
When calling client.list_aggs, now it's throw error:
polygon.exceptions.BadResponse: {"status":"ERROR","request_id":"708a85cecad66756c956da798714ac63","error":"The parameter 'to' cannot be a time that occurs before 'from'"}
I didn't change my calling code. Even I used the example code: aggs = [] for a in client.list_aggs( "AAPL", 1, "day", "2023-01-09", "2023-02-10", adjusted="true", sort="desc", limit=2, ): aggs.append(a)
I still get same error: Request URL: https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2023-01-09/2023-02-10?adjusted=true&sort=desc&limit=2 Request Headers: {'Authorization': 'Bearer REDACTED', 'Accept-Encoding': 'gzip', 'User-Agent': 'Polygon.io PythonClient/1.14.6'} Response Headers: {'Date': 'Mon, 16 Jun 2025 12:26:53 GMT', 'Content-Type': 'application/json', 'Content-Length': '348', 'Connection': 'keep-alive', 'Content-Encoding': 'gzip', 'Vary': 'Accept-Encoding', 'X-Polygon-Cluster-Name': 'polygon-ny5', 'X-Request-Id': '294c7b52f57a6ee48a895473ab336ca2', 'Strict-Transport-Security': 'max-age=15724800; includeSubDomains'}
polygon.exceptions.BadResponse: {"status":"ERROR","request_id":"708a85cecad66756c956da798714ac63","error":"The parameter 'to' cannot be a time that occurs before 'from'"}
I set trace=True, and got this from the log: Request URL: https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2025-06-10/2025-06-16?adjusted=true&sort=desc&limit=2 And copy and request from the browser, I could get the correct response.
Hey @investment-radar, do you mind trying this again? I tried to reproduce this and it seems to work. Here's what I see. Can you also say what plan you're on. I'll try it with those entitlements.
{
"ticker": "AAPL",
"queryCount": 2,
"resultsCount": 2,
"adjusted": true,
"results": [
{
"v": 57388108,
"vw": 150.4054,
"o": 149.46,
"c": 151.01,
"h": 151.3401,
"l": 149.22,
"t": 1676005200000,
"n": 443405
},
{
"v": 55994243,
"vw": 152.2769,
"o": 153.775,
"c": 150.87,
"h": 154.33,
"l": 150.42,
"t": 1675918800000,
"n": 471973
}
],
"status": "OK",
"request_id": "2530ab020d35373f10cef17f1a4cace7",
"count": 2,
"next_url": "https://api.polygon.io/v2/aggs/ticker/AAPL/range/1/day/2023-01-09/1675918799999?cursor=bGltaXQ9MiZzb3J0PWRlc2M"
}
I found the issue is when you set the limit less then 5, I still got the error. but set limit to 5, then it works. aggs = [] for a in client.list_aggs( "AAPL", 1, "day", "2023-01-09", "2023-02-10", adjusted="true", sort="desc", limit=5, ):
Hey @investment-radar, I'm still not able to reproduce the issue. Do you mind contacting https://polygon.io/contact since they can look up your account and plans to see if their might be a restriction there. I've tried a bunch of different ways / dates but not seeing the same thing on my end. So, I suspect if might be the plan but support can look that up easily.
Ok, thanks.
Sorry, I could not be more helpful here.