-
Notifications
You must be signed in to change notification settings - Fork 229
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* removed formatting from docs and unwated comment dupe * Add headers from options * Added options parameter to rest api functions. * handle headers from options * edge-headers push * Attempting to use with options * created response options class * handle headers from options * merge headers * parameter type cleanup and None value handling in request. * attempting to revert conf.py changes * added concat_method to baseclient and test for requestoptions * refactored and introduced more optionals for stricter use * added type hinting to builder method returns. removed optional from edge_headers method * removed one example from ./example/launchpad and renamed function * lint * Update polygon/rest/base.py remove redundancy. * Update examples/launchpad/launchpad.py Co-authored-by: jbonzo <8647805+jbonzo@users.noreply.github.com>
- Loading branch information
Showing
15 changed files
with
414 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
# Launchpad | ||
|
||
Users of the Launchpad product will need to pass in certain headers in order to make API requests. | ||
|
||
```python | ||
|
||
# import RESTClient | ||
from polygon import RESTClient | ||
from polygon.rest.models.request import RequestOptionBuilder | ||
|
||
# create client | ||
c = RESTClient(api_key="API_KEY") | ||
|
||
# create request options | ||
options = RequestOptionBuilder().edge_headers( | ||
edge_id="YOUR_EDGE_ID", # required | ||
edge_ip_address="IP_ADDRESS", # required | ||
) | ||
# get response | ||
res = c.get_aggs("AAPL", 1, "day", "2022-04-04", "2022-04-04", options=options) | ||
|
||
# do something with response | ||
|
||
``` | ||
Launchpad users can also provide the optional User Agent value describing their Edge User's origination request. | ||
|
||
```python | ||
|
||
# import RESTClient | ||
from polygon import RESTClient | ||
from polygon.rest.models.request import RequestOptionBuilder | ||
|
||
# create client | ||
c = RESTClient(api_key="API_KEY") | ||
|
||
# create request options | ||
options = RequestOptionBuilder().edge_headers( | ||
edge_id="YOUR_EDGE_ID", # required | ||
edge_ip_address="IP_ADDRESS" # required | ||
).update_edge_header( | ||
edge_user="EDGE_USER" # optional | ||
) | ||
|
||
# get response | ||
res = c.get_aggs("AAPL", 1, "day", "2022-04-04", "2022-04-04", options=options) | ||
|
||
# do something with response | ||
|
||
``` |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
from polygon import RESTClient | ||
from polygon.rest.models.request import RequestOptionBuilder | ||
|
||
|
||
def get_list_trades_launchpad(): | ||
client = RESTClient() | ||
|
||
""" | ||
set headers example: | ||
options = RequestOptionBuilder() | ||
.edge_headers(edge_id="EDGE_ID", edge_ip_address="EDGE_ID_ADDRESS", edge_user="EDGE_USER") | ||
update headers example: | ||
options = options.update_edge_header(edge_ip_address="NEW_IP") | ||
""" | ||
options = RequestOptionBuilder().edge_headers( | ||
edge_id="EDGE_ID", edge_ip_address="EDGE_ID_ADDRESS", edge_user="EDGE_USER" | ||
) | ||
|
||
trades = [] | ||
for t in client.list_trades("AAA", "2022-04-04", limit=5, options=options): | ||
trades.append(t) | ||
print(trades) | ||
|
||
|
||
def main(): | ||
get_list_trades_launchpad() | ||
|
||
|
||
if __name__ == "__main__": | ||
main() |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,13 @@ | ||
from polygon import RESTClient | ||
from polygon.rest import models | ||
|
||
client = RESTClient() | ||
|
||
aggs = client.get_aggs("AAPL", 1, "day", "2022-04-04", "2022-04-04") | ||
aggs = client.get_aggs( | ||
"AAPL", | ||
1, | ||
"day", | ||
"2022-04-04", | ||
"2022-04-04", | ||
) | ||
print(aggs) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.