When using RESTClient, I receive result in a variable, how to read Open price?
from polygon import RESTClient
client = RESTClient("xxxxxxxxx")
aggs = []
for a in client.list_aggs("SPY",1,"minute","2023-07-25","2023-07-25",limit=50000,):
aggs.append(a)
>>print(a)
Agg(open=455.34, high=455.34, low=455.3101, close=455.3101, volume=3797, vwap=455.3239,
timestamp=1690329540000, transactions=9, otc=None)
>>type(a)
Out[40]: polygon.rest.models.aggs.Agg
EDIT:
In your for loop, update the aggs.append(a) to aggs.append(a.open). This will build your list of open prices within aggs that you can then access.
I'm not completely familiar with the Polygon library for their platform, but their API guide for pulling aggregates may be a better option.
https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to
Here you could utilize Requests or urllib3 with a GET after authenticating and then parse the JSON response from the Results section.
So it would look something like this:
You could parameterize the URL a bit cleaner, but let me know if this gets you going.