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

Add entitlement parameter #363

Open
wants to merge 4 commits into
base: develop
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
9 changes: 6 additions & 3 deletions alpha_vantage/alphavantage.py
Expand Up @@ -26,7 +26,7 @@ class AlphaVantage(object):
_RAPIDAPI_URL = "https://alpha-vantage.p.rapidapi.com/query?"

def __init__(self, key=None, output_format='json',
treat_info_as_error=True, indexing_type='date', proxy=None, rapidapi=False):
treat_info_as_error=True, indexing_type='date', proxy=None, rapidapi=False, entitlement=None):
""" Initialize the class

Keyword Arguments:
Expand Down Expand Up @@ -61,6 +61,7 @@ def __init__(self, key=None, output_format='json',
}
self.rapidapi = rapidapi
self.key = key
self.entitlement = entitlement
self.output_format = output_format
if self.output_format == 'pandas' and not _PANDAS_FOUND:
raise ValueError("The pandas library was not found, therefore can "
Expand Down Expand Up @@ -153,10 +154,12 @@ def _call_wrapper(self, *args, **kwargs):
self.output_format.lower()))
apikey_parameter = "" if self.rapidapi else "&apikey={}".format(
self.key)
entitlement_parameter = "" if self.entitlement is None else "&entitlement={}".format(
self.entitlement)
if self._append_type:
url = '{}{}&datatype={}'.format(url, apikey_parameter, oformat)
url = '{}{}{}&datatype={}'.format(url, apikey_parameter, entitlement_parameter, oformat)
else:
url = '{}{}'.format(url, apikey_parameter)
url = '{}{}{}'.format(url, apikey_parameter, entitlement_parameter)
return self._handle_api_call(url), data_key, meta_data_key
return _call_wrapper

Expand Down
2 changes: 1 addition & 1 deletion alpha_vantage/cryptocurrencies.py
Expand Up @@ -60,7 +60,7 @@ def get_digital_currency_monthly(self, symbol, market):

@av._output_format
@av._call_api_on_func
def get_digital_currency_exchange_rate(self, from_currency, to_currency):
def get_digital_currency_exchange_rate(self, from_currency, to_currency, entitlement=None):
""" Returns the realtime exchange rate for any pair of digital
currency (e.g., BTC) or physical currency (e.g., USD).
Keyword Arguments:
Expand Down
2 changes: 1 addition & 1 deletion alpha_vantage/timeseries.py
Expand Up @@ -8,7 +8,7 @@ class TimeSeries(av):
@av._output_format
@av._call_api_on_func
def get_intraday(self, symbol: str, interval:str='15min', outputsize:str='compact',
month:str=None, extended_hours:str='true', adjusted:str='true'):
month:str=None, extended_hours:str='true', adjusted:str='true', entitlement:str=None):
""" Return intraday time series in two json objects as data and
meta_data. It raises ValueError when problems arise

Expand Down