Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

polygon max retry bug fix #482

Merged
merged 1 commit into from
Jul 4, 2024
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
7 changes: 6 additions & 1 deletion lumibot/tools/polygon_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -132,6 +132,10 @@ def get_price_data_from_polygon(
polygon_client = PolygonClient.create(api_key=api_key)
symbol = get_polygon_symbol(asset, polygon_client, quote_asset) # Will do a Polygon query for option contracts

# Check if symbol is None, which means we couldn't find the option contract
if symbol is None:
return None

# To reduce calls to Polygon, we call on full date ranges instead of including hours/minutes
# get the full range of data we need in one call and ensure that there won't be any intraday gaps in the data.
# Option data won't have any extended hours data so the padding is extra important for those.
Expand Down Expand Up @@ -548,10 +552,11 @@ def _get(self, *args, **kwargs):
try:
return super()._get(*args, **kwargs)

except MaxRetryError:
except MaxRetryError as e:
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

category Naming

In the exception handling block for MaxRetryError, the variable name 'e' is not descriptive. Consider renaming it to 'max_retry_error' to provide more context about what it represents.

colored_message = colored(
f"Polygon rate limit reached. Sleeping for {PolygonClient.WAIT_SECONDS_RETRY} seconds before trying again. If you want to avoid this, consider a paid subscription with Polygon at https://polygon.io/?utm_source=affiliate&utm_campaign=lumi10 Please use the full link to give us credit for the sale, it helps support this project. You can use the coupon code 'LUMI10' for 10% off.",
"red",
)
logging.error(colored_message)
logging.debug(f"Error: {e}")
time.sleep(PolygonClient.WAIT_SECONDS_RETRY)
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

setuptools.setup(
name="lumibot",
version="3.5.10",
version="3.5.11",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

category Documentation

I noticed that you've updated the version of the software package in the setup.py file, but this change is not reflected in the README.md file. It's important to keep the README.md file up-to-date with the latest version of the software package. Could you please update the README.md file to reflect this change?

author="Robert Grzesik",
author_email="[email protected]",
description="Backtesting and Trading Library, Made by Lumiwealth",
Expand Down
Loading