Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 11 additions & 0 deletions docs/source/Aggs.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,17 @@
Aggs
==========

===========
List aggs
===========

- `Stocks aggs`_
- `Options aggs`_
- `Forex aggs`_
- `Crypto aggs`_

.. automethod:: polygon.RESTClient.list_aggs

===========
Get aggs
===========
Expand Down
9 changes: 6 additions & 3 deletions examples/rest/crypto-aggregates_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# docs
# https://polygon.io/docs/crypto/get_v2_aggs_ticker__cryptoticker__range__multiplier___timespan___from___to
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.get_aggs
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs

# API key injected below for easy use. If not provided, the script will attempt
# to use the environment variable "POLYGON_API_KEY".
Expand All @@ -16,12 +16,15 @@
# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"X:BTCUSD",
1,
"day",
"2023-01-30",
"2023-02-03",
)
limit=50000,
):
aggs.append(a)

print(aggs)
9 changes: 6 additions & 3 deletions examples/rest/forex-aggregates_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# docs
# https://polygon.io/docs/forex/get_v2_aggs_ticker__forexticker__range__multiplier___timespan___from___to
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.get_aggs
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs

# API key injected below for easy use. If not provided, the script will attempt
# to use the environment variable "POLYGON_API_KEY".
Expand All @@ -16,12 +16,15 @@
# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"C:EURUSD",
1,
"day",
"2023-01-30",
"2023-02-03",
)
limit=50000,
):
aggs.append(a)

print(aggs)
11 changes: 7 additions & 4 deletions examples/rest/indices-aggregates_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# docs
# https://polygon.io/docs/indices/get_v2_aggs_ticker__indicesticker__range__multiplier___timespan___from___to
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.get_aggs
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs

# API key injected below for easy use. If not provided, the script will attempt
# to use the environment variable "POLYGON_API_KEY".
Expand All @@ -16,12 +16,15 @@
# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"I:SPX",
1,
"day",
"2023-03-10",
"2023-03-10",
)
"2023-05-12",
limit=50000,
):
aggs.append(a)

print(aggs)
9 changes: 6 additions & 3 deletions examples/rest/options-aggregates_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# docs
# https://polygon.io/docs/options/get_v2_aggs_ticker__optionsticker__range__multiplier___timespan___from___to
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.get_aggs
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs

# API key injected below for easy use. If not provided, the script will attempt
# to use the environment variable "POLYGON_API_KEY".
Expand All @@ -16,12 +16,15 @@
# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"O:SPY251219C00650000",
1,
"day",
"2023-01-30",
"2023-02-03",
)
limit=50000,
):
aggs.append(a)

print(aggs)
13 changes: 8 additions & 5 deletions examples/rest/stocks-aggregates_bars.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

# docs
# https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.get_aggs
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs

# API key injected below for easy use. If not provided, the script will attempt
# to use the environment variable "POLYGON_API_KEY".
Expand All @@ -16,12 +16,15 @@
# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"AAPL",
1,
"day",
"2023-01-30",
"minute",
"2022-01-01",
"2023-02-03",
)
limit=50000,
):
aggs.append(a)

print(aggs)
9 changes: 6 additions & 3 deletions examples/rest/stocks-aggregates_bars_extra.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,18 +16,21 @@

# docs
# https://polygon.io/docs/stocks/get_v2_aggs_ticker__stocksticker__range__multiplier___timespan___from___to
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.get_aggs
# https://polygon-api-client.readthedocs.io/en/latest/Aggs.html#polygon.RESTClient.list_aggs

# client = RESTClient("XXXXXX") # hardcoded api_key is used
client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"AAPL",
1,
"hour",
"2023-01-30",
"2023-02-03",
)
limit=50000,
):
aggs.append(a)

print(aggs)

Expand Down
6 changes: 4 additions & 2 deletions examples/rest/stocks-aggregates_bars_highcharts.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,14 +70,16 @@

client = RESTClient() # POLYGON_API_KEY environment variable is used

aggs = client.get_aggs(
aggs = []
for a in client.list_aggs(
"AAPL",
1,
"day",
"2019-01-01",
"2023-02-16",
limit=50000,
)
):
aggs.append(a)

# print(aggs)

Expand Down