From c900e5fe370f2f6fd6380cd9de8a0c1fe9e60fa6 Mon Sep 17 00:00:00 2001 From: Robert Grzesik Date: Thu, 4 Jul 2024 02:22:14 -0400 Subject: [PATCH] polygon max retry bug fix --- lumibot/tools/polygon_helper.py | 7 ++++++- setup.py | 2 +- 2 files changed, 7 insertions(+), 2 deletions(-) diff --git a/lumibot/tools/polygon_helper.py b/lumibot/tools/polygon_helper.py index 1a964590..76073411 100644 --- a/lumibot/tools/polygon_helper.py +++ b/lumibot/tools/polygon_helper.py @@ -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. @@ -548,10 +552,11 @@ def _get(self, *args, **kwargs): try: return super()._get(*args, **kwargs) - except MaxRetryError: + except MaxRetryError as e: 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) \ No newline at end of file diff --git a/setup.py b/setup.py index 7eac6546..b46714a6 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setuptools.setup( name="lumibot", - version="3.5.10", + version="3.5.11", author="Robert Grzesik", author_email="rob@lumiwealth.com", description="Backtesting and Trading Library, Made by Lumiwealth",