community: Update Polygon.io API (#27552)

**Description:** 
Update the wrapper to support the Polygon API if not you get an error. I
keeped `STOCKBUSINESS` for retro-compatbility with older endpoints /
other uses
Old Code:
```
 if status not in ("OK", "STOCKBUSINESS"):
    raise ValueError(f"API Error: {data}")

```
API Respond:
```
API Error: {'results': {'P': 0.22, 'S': 0, 'T': 'ZOM', 'X': 5, 'p': 0.123, 'q': 0, 's': 200, 't': 1729614422813395456, 'x': 1, 'z': 1}, 'status': 'STOCKSBUSINESS', 'request_id': 'XXXXXX'}
```

- **Issue:** N/A Polygon API update
- **Dependencies:** N/A
- **Twitter handle:** @wgcv

---------

Co-authored-by: ccurme <chester.curme@gmail.com>
This commit is contained in:
W. Gustavo Cevallos 2024-10-31 13:14:06 -05:00 committed by GitHub
parent 621f78babd
commit f94125a325
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -45,7 +45,7 @@ class PolygonAPIWrapper(BaseModel):
data = response.json()
status = data.get("status", None)
if status not in ("OK", "STOCKBUSINESS"):
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
raise ValueError(f"API Error: {data}")
return data.get("results", None)
@ -61,7 +61,7 @@ class PolygonAPIWrapper(BaseModel):
data = response.json()
status = data.get("status", None)
if status not in ("OK", "STOCKBUSINESS"):
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
raise ValueError(f"API Error: {data}")
return data.get("results", None)
@ -82,7 +82,7 @@ class PolygonAPIWrapper(BaseModel):
data = response.json()
status = data.get("status", None)
if status not in ("OK", "STOCKBUSINESS"):
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
raise ValueError(f"API Error: {data}")
return data.get("results", None)
@ -116,7 +116,7 @@ class PolygonAPIWrapper(BaseModel):
data = response.json()
status = data.get("status", None)
if status not in ("OK", "STOCKBUSINESS"):
if status not in ("OK", "STOCKBUSINESS", "STOCKSBUSINESS"):
raise ValueError(f"API Error: {data}")
return data.get("results", None)