diff --git a/FinMesh.egg-info/PKG-INFO b/FinMesh.egg-info/PKG-INFO index b94ff01..1357bb0 100644 --- a/FinMesh.egg-info/PKG-INFO +++ b/FinMesh.egg-info/PKG-INFO @@ -1,6 +1,6 @@ Metadata-Version: 2.1 Name: FinMesh -Version: 2.0.1 +Version: 2.0.9 Summary: A Python wrapper to bring together various financial APIs. Home-page: UNKNOWN Author: Michael and Josh Hartmann diff --git a/FinMesh/iex/_common.py b/FinMesh/iex/_common.py index f640400..b2878e3 100644 --- a/FinMesh/iex/_common.py +++ b/FinMesh/iex/_common.py @@ -66,15 +66,15 @@ class iexCommon(): :type external: Boolean or String. Default is False, insert token here to bypass using environment variables. """ - def __init__(self, endpoint, symbol, external=False): + def __init__(self, section, symbol, endpoint, external=False): self.url = f'iexapis.com/stable/{section}/{symbol}/{endpoint}?' - if external not False: + if not external == False: self.token = external self.parse_token_sandbox(self.token) else: self.sandbox_state = self.get_env_sandbox() self.token = self.get_env_token() - if sandbox_state is True: + if self.sandbox_state is True: self.url = 'https://sandbox.' + self.url else: self.url = 'https://cloud.' + self.url @@ -121,14 +121,19 @@ def get_env_token(self): Variable name is either 'IEX_SANDBOX_TOKEN' or 'IEX_TOKEN' Whether the sandbox or production token is retrieved is determined by the environment SANDBOX state. """ - if sandboxState: + if self.sandbox_state: token = os.getenv('IEX_SANDBOX_TOKEN') else: token = os.getenv('IEX_TOKEN') return token + def append_subdirectory_to_url(self, *subdir): + subdirectory_to_add = F"/{subdir}?" + self.url = self.url.replace("?", subdirectory_to_add) + return self.url + # Adds query paramters to the url - def add_query_params_to_url(self, **query_params): + def append_query_params_to_url(self, **query_params): """Appends query parameters onto the target URL. Performs operations on the url attribute. Returns the URL with query parameters attached to the end. @@ -137,7 +142,7 @@ def add_query_params_to_url(self, **query_params): :type query_params: Keyword arguments, required. """ for key, value in query_params.items(): - self.url += (f"&{key}={value}") + self.url += (F"&{key}={value}") return self.url # Finalizes the url with the appropriate token - method does not determine which token to append @@ -170,11 +175,20 @@ def make_iex_request(self): # Step One # Execution of class is split into two parts so that changes to the url can be made halfway through - def pre_execute(self, query_params): - self.add_query_params_to_url(self, query_params=None) + def pre_execute(self, **query_params): + self.add_query_params_to_url(self, query_params) # Step Two # Final execution step where token is added and request is made. def execute(self): self.append_token_to_url() - self.make_iex_request() + return self.make_iex_request() + +# +# # Standard Usage of Class +# def iex_endpoint_request_dummy(section, symbol, endpoint, external=False): +# """Documentation""" +# instance = iexCommon(section, symbol, endpoint, external=external).pre_execute() +# # Here is where you would add extra things to the url by directly accessing instance.url +# return instance.execute() +# diff --git a/FinMesh/iex/stock.py b/FinMesh/iex/stock.py index 1e0afce..420e660 100644 --- a/FinMesh/iex/stock.py +++ b/FinMesh/iex/stock.py @@ -70,14 +70,16 @@ def collection(collectionType, collectionName, external=False, vprint=False): # Company IEX_COMPANY_URL = prepend_iex_url('stock') + '{symbol}/company?' -def company(symbol, external=False, vprint=False): +def company(symbol, external=False, vprint=False, **query_params): """:return: Company data such as website, address, and description for the requested company. :param symbol: The ticker or symbol of the stock you would like to request. :type symbol: string, required """ - url = replace_url_var(IEX_COMPANY_URL, symbol=symbol) - return get_iex_json_request(url, external=external, vprint=vprint) + instance = iexCommon('stock', symbol, 'company', external=external) + return instance.execute() + # url = replace_url_var(IEX_COMPANY_URL, symbol=symbol) + # return get_iex_json_request(url, external=external, vprint=vprint) # Delayed Quote diff --git a/build/lib/FinMesh/iex/_common.py b/build/lib/FinMesh/iex/_common.py index f640400..b2878e3 100644 --- a/build/lib/FinMesh/iex/_common.py +++ b/build/lib/FinMesh/iex/_common.py @@ -66,15 +66,15 @@ class iexCommon(): :type external: Boolean or String. Default is False, insert token here to bypass using environment variables. """ - def __init__(self, endpoint, symbol, external=False): + def __init__(self, section, symbol, endpoint, external=False): self.url = f'iexapis.com/stable/{section}/{symbol}/{endpoint}?' - if external not False: + if not external == False: self.token = external self.parse_token_sandbox(self.token) else: self.sandbox_state = self.get_env_sandbox() self.token = self.get_env_token() - if sandbox_state is True: + if self.sandbox_state is True: self.url = 'https://sandbox.' + self.url else: self.url = 'https://cloud.' + self.url @@ -121,14 +121,19 @@ def get_env_token(self): Variable name is either 'IEX_SANDBOX_TOKEN' or 'IEX_TOKEN' Whether the sandbox or production token is retrieved is determined by the environment SANDBOX state. """ - if sandboxState: + if self.sandbox_state: token = os.getenv('IEX_SANDBOX_TOKEN') else: token = os.getenv('IEX_TOKEN') return token + def append_subdirectory_to_url(self, *subdir): + subdirectory_to_add = F"/{subdir}?" + self.url = self.url.replace("?", subdirectory_to_add) + return self.url + # Adds query paramters to the url - def add_query_params_to_url(self, **query_params): + def append_query_params_to_url(self, **query_params): """Appends query parameters onto the target URL. Performs operations on the url attribute. Returns the URL with query parameters attached to the end. @@ -137,7 +142,7 @@ def add_query_params_to_url(self, **query_params): :type query_params: Keyword arguments, required. """ for key, value in query_params.items(): - self.url += (f"&{key}={value}") + self.url += (F"&{key}={value}") return self.url # Finalizes the url with the appropriate token - method does not determine which token to append @@ -170,11 +175,20 @@ def make_iex_request(self): # Step One # Execution of class is split into two parts so that changes to the url can be made halfway through - def pre_execute(self, query_params): - self.add_query_params_to_url(self, query_params=None) + def pre_execute(self, **query_params): + self.add_query_params_to_url(self, query_params) # Step Two # Final execution step where token is added and request is made. def execute(self): self.append_token_to_url() - self.make_iex_request() + return self.make_iex_request() + +# +# # Standard Usage of Class +# def iex_endpoint_request_dummy(section, symbol, endpoint, external=False): +# """Documentation""" +# instance = iexCommon(section, symbol, endpoint, external=external).pre_execute() +# # Here is where you would add extra things to the url by directly accessing instance.url +# return instance.execute() +# diff --git a/build/lib/FinMesh/iex/stock.py b/build/lib/FinMesh/iex/stock.py index bf4657e..420e660 100644 --- a/build/lib/FinMesh/iex/stock.py +++ b/build/lib/FinMesh/iex/stock.py @@ -16,7 +16,7 @@ def balance_sheet(symbol, external=False, vprint=False, **queries): url += '?' for key, value in queries.items(): url += (f"&{key}={value}") - return get_iex_json_request(url, external=external, external=external, vprint=vprint) + return get_iex_json_request(url, external=external, vprint=vprint) # Batch Requests @@ -70,14 +70,16 @@ def collection(collectionType, collectionName, external=False, vprint=False): # Company IEX_COMPANY_URL = prepend_iex_url('stock') + '{symbol}/company?' -def company(symbol, external=False, vprint=False): +def company(symbol, external=False, vprint=False, **query_params): """:return: Company data such as website, address, and description for the requested company. :param symbol: The ticker or symbol of the stock you would like to request. :type symbol: string, required """ - url = replace_url_var(IEX_COMPANY_URL, symbol=symbol) - return get_iex_json_request(url, external=external, vprint=vprint) + instance = iexCommon('stock', symbol, 'company', external=external) + return instance.execute() + # url = replace_url_var(IEX_COMPANY_URL, symbol=symbol) + # return get_iex_json_request(url, external=external, vprint=vprint) # Delayed Quote diff --git a/dist/FinMesh-2.0.2-py3-none-any.whl b/dist/FinMesh-2.0.2-py3-none-any.whl new file mode 100644 index 0000000..6c9b746 Binary files /dev/null and b/dist/FinMesh-2.0.2-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.2.tar.gz b/dist/FinMesh-2.0.2.tar.gz new file mode 100644 index 0000000..10daa22 Binary files /dev/null and b/dist/FinMesh-2.0.2.tar.gz differ diff --git a/dist/FinMesh-2.0.3-py3-none-any.whl b/dist/FinMesh-2.0.3-py3-none-any.whl new file mode 100644 index 0000000..2590fdb Binary files /dev/null and b/dist/FinMesh-2.0.3-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.3.tar.gz b/dist/FinMesh-2.0.3.tar.gz new file mode 100644 index 0000000..1428c98 Binary files /dev/null and b/dist/FinMesh-2.0.3.tar.gz differ diff --git a/dist/FinMesh-2.0.4-py3-none-any.whl b/dist/FinMesh-2.0.4-py3-none-any.whl new file mode 100644 index 0000000..c3614cf Binary files /dev/null and b/dist/FinMesh-2.0.4-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.4.tar.gz b/dist/FinMesh-2.0.4.tar.gz new file mode 100644 index 0000000..9ec4238 Binary files /dev/null and b/dist/FinMesh-2.0.4.tar.gz differ diff --git a/dist/FinMesh-2.0.5-py3-none-any.whl b/dist/FinMesh-2.0.5-py3-none-any.whl new file mode 100644 index 0000000..68a57b5 Binary files /dev/null and b/dist/FinMesh-2.0.5-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.5.tar.gz b/dist/FinMesh-2.0.5.tar.gz new file mode 100644 index 0000000..98f3ad2 Binary files /dev/null and b/dist/FinMesh-2.0.5.tar.gz differ diff --git a/dist/FinMesh-2.0.6-py3-none-any.whl b/dist/FinMesh-2.0.6-py3-none-any.whl new file mode 100644 index 0000000..fc6795a Binary files /dev/null and b/dist/FinMesh-2.0.6-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.6.tar.gz b/dist/FinMesh-2.0.6.tar.gz new file mode 100644 index 0000000..16a9830 Binary files /dev/null and b/dist/FinMesh-2.0.6.tar.gz differ diff --git a/dist/FinMesh-2.0.7-py3-none-any.whl b/dist/FinMesh-2.0.7-py3-none-any.whl new file mode 100644 index 0000000..037bc18 Binary files /dev/null and b/dist/FinMesh-2.0.7-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.7.tar.gz b/dist/FinMesh-2.0.7.tar.gz new file mode 100644 index 0000000..b0fe59a Binary files /dev/null and b/dist/FinMesh-2.0.7.tar.gz differ diff --git a/dist/FinMesh-2.0.8-py3-none-any.whl b/dist/FinMesh-2.0.8-py3-none-any.whl new file mode 100644 index 0000000..1c75d2c Binary files /dev/null and b/dist/FinMesh-2.0.8-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.8.tar.gz b/dist/FinMesh-2.0.8.tar.gz new file mode 100644 index 0000000..ae7350e Binary files /dev/null and b/dist/FinMesh-2.0.8.tar.gz differ diff --git a/dist/FinMesh-2.0.9-py3-none-any.whl b/dist/FinMesh-2.0.9-py3-none-any.whl new file mode 100644 index 0000000..d3ebd97 Binary files /dev/null and b/dist/FinMesh-2.0.9-py3-none-any.whl differ diff --git a/dist/FinMesh-2.0.9.tar.gz b/dist/FinMesh-2.0.9.tar.gz new file mode 100644 index 0000000..fe5e2ac Binary files /dev/null and b/dist/FinMesh-2.0.9.tar.gz differ diff --git a/setup.py b/setup.py index 5a78a37..e3e5d05 100644 --- a/setup.py +++ b/setup.py @@ -13,7 +13,7 @@ setuptools.setup( name = "FinMesh", - version = "2.0.2", + version = "2.0.9", author = "Michael and Josh Hartmann", author_email = "mph101mph@gmail.com", description = "A Python wrapper to bring together various financial APIs.", diff --git a/testupdate.sh b/testupdate.sh index 80b5a5c..7cc2707 100644 --- a/testupdate.sh +++ b/testupdate.sh @@ -1,7 +1,7 @@ echo Creating new distributions... python3 setup.py sdist bdist_wheel echo Uploading new version to Pypi... -twine upload --repository testpypi dist/* +twine upload --skip-existing --repository testpypi dist/* echo Upgrading FinMesh... pip install --force-reinstall --index-url https://test.pypi.org/simple/ FinMesh