diff --git a/cschwabpy/SchwabAsyncClient.py b/cschwabpy/SchwabAsyncClient.py index e635790..6456a88 100644 --- a/cschwabpy/SchwabAsyncClient.py +++ b/cschwabpy/SchwabAsyncClient.py @@ -379,8 +379,13 @@ async def download_option_chain_async( response = await client.get( url=target_url, params={}, headers=self.__auth_header() ) - json_res = response.json() - return OptionChain(**json_res) + if response.status_code == 200: + json_res = response.json() + return OptionChain(**json_res) + else: + raise Exception( + "Failed to download option chain. Status: ", response.status_code + ) finally: if not self.__keep_client_alive: await client.aclose() diff --git a/cschwabpy/SchwabClient.py b/cschwabpy/SchwabClient.py index 902b778..214d4bf 100644 --- a/cschwabpy/SchwabClient.py +++ b/cschwabpy/SchwabClient.py @@ -381,8 +381,13 @@ def download_option_chain( response = client.get( url=target_url, params={}, headers=self.__auth_header() ) - json_res = response.json() - return OptionChain(**json_res) + if response.status_code == 200: + json_res = response.json() + return OptionChain(**json_res) + else: + raise Exception( + "Failed to download option chain. Status: ", response.status_code + ) finally: if not self.__keep_client_alive: client.close() diff --git a/pyproject.toml b/pyproject.toml index 5b7661f..ccd74da 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "cschwabpy" -version = "0.1.3.2" +version = "0.1.3.3" description = "" authors = ["Tony Wang "] readme = "README.md" diff --git a/setup.py b/setup.py index 886672f..0c151ee 100644 --- a/setup.py +++ b/setup.py @@ -5,7 +5,7 @@ setup( name="CSchwabPy", - version="0.1.3.2", + version="0.1.3.3", description="Charles Schwab Stock & Option Trade API Client for Python.", long_description=long_description, long_description_content_type="text/markdown",