From fa6b811c93e9ce0e6c2552069675a66df9917e46 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 23 Oct 2020 21:12:21 -0400 Subject: [PATCH 1/6] reformat docstrings, add stocktwits --- README.md | 14 +- docs/index.md | 14 +- examples/all.ipynb | 16 +- pyEX/account/__init__.py | 32 ++-- pyEX/alternative/alternative.py | 52 +++--- pyEX/client.py | 4 +- pyEX/cryptocurrency/cryptocurrency.py | 48 +++--- pyEX/fx/fx.py | 48 +++--- pyEX/marketdata/cryptocurrency.py | 18 +- pyEX/marketdata/fx.py | 6 +- pyEX/marketdata/http.py | 158 +++++++++--------- pyEX/marketdata/sse.py | 78 ++++----- pyEX/options/options.py | 32 ++-- pyEX/points/points.py | 20 +-- pyEX/premium/auditanalytics/__init__.py | 8 +- pyEX/premium/brain/__init__.py | 44 ++--- pyEX/premium/extractalpha/__init__.py | 52 +++--- pyEX/premium/fraudfactors/__init__.py | 8 +- pyEX/premium/kavout/__init__.py | 4 +- pyEX/premium/precisionalpha/__init__.py | 4 +- pyEX/premium/stocktwits/__init__.py | 44 +++++ pyEX/premium/valuengine/__init__.py | 2 +- pyEX/premium/wallstreethorizon/__init__.py | 104 ++++++------ pyEX/refdata/calendar.py | 52 +++--- pyEX/refdata/exchanges.py | 24 +-- pyEX/refdata/figi.py | 12 +- pyEX/refdata/refdata.py | 48 +++--- pyEX/refdata/sectors.py | 24 +-- pyEX/refdata/symbols.py | 120 +++++++------- pyEX/rules/__init__.py | 6 +- pyEX/stats/stats.py | 99 ++++------- pyEX/stocks/batch.py | 56 +++---- pyEX/stocks/corporateActions.py | 90 +++++----- pyEX/stocks/fundamentals.py | 74 ++++----- pyEX/stocks/marketInfo.py | 120 +++++++------- pyEX/stocks/news.py | 28 ++-- pyEX/stocks/prices.py | 182 ++++++++++----------- pyEX/stocks/profiles.py | 120 +++++++------- pyEX/stocks/research.py | 164 +++++++++---------- pyEX/stocks/stocks.py | 36 ++-- pyEX/stocks/timeseries.py | 6 +- 41 files changed, 1042 insertions(+), 1029 deletions(-) create mode 100644 pyEX/premium/stocktwits/__init__.py diff --git a/README.md b/README.md index d50afe8..3d6b290 100644 --- a/README.md +++ b/README.md @@ -41,12 +41,12 @@ All others: -Prior trading day available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - timeframe (string); Timeframe to request e.g. 1m + symbol (str); Ticker to request + timeframe (str); Timeframe to request e.g. 1m date (datetime): date, if requesting intraday - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str); Access token + version (str); API version + filter (str); filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -79,8 +79,8 @@ IEX Cloud Client Client has access to all methods provided as standalone, but in an authenticated way Args: - api_token (string): api token (can pickup from IEX_TOKEN environment variable) - version (string): api version to use (defaults to v1) + api_token (str): api token (can pickup from IEX_TOKEN environment variable) + version (str): api version to use (defaults to v1) set version to 'sandbox' to run against the IEX sandbox api_limit (int): cache calls in this interval File: ~/Programs/projects/iex/pyEX/pyEX/client.py diff --git a/docs/index.md b/docs/index.md index a455bed..be01e94 100644 --- a/docs/index.md +++ b/docs/index.md @@ -41,12 +41,12 @@ All others: -Prior trading day available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - timeframe (string); Timeframe to request e.g. 1m + symbol (str); Ticker to request + timeframe (str); Timeframe to request e.g. 1m date (datetime): date, if requesting intraday - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str); Access token + version (str); API version + filter (str); filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -79,8 +79,8 @@ IEX Cloud Client Client has access to all methods provided as standalone, but in an authenticated way Args: - api_token (string): api token (can pickup from IEX_TOKEN environment variable) - version (string): api version to use (defaults to v1) + api_token (str): api token (can pickup from IEX_TOKEN environment variable) + version (str): api version to use (defaults to v1) set version to 'sandbox' to run against the IEX sandbox api_limit (int): cache calls in this interval File: ~/Programs/projects/iex/pyEX/pyEX/client.py diff --git a/examples/all.ipynb b/examples/all.ipynb index c71b7c1..51376cd 100644 --- a/examples/all.ipynb +++ b/examples/all.ipynb @@ -3170,10 +3170,10 @@ "https://iexcloud.io/docs/api/#collections\n", "\n", "Args:\n", - " tag (string); Sector, Tag, or List\n", - " collectionName (string); Associated name for tag\n", - " token (string); Access token\n", - " version (string); API version\n", + " tag (str); Sector, Tag, or List\n", + " collectionName (str); Associated name for tag\n", + " token (str); Access token\n", + " version (str); API version\n", "\n", "Returns:\n", " dict: result\n", @@ -3215,10 +3215,10 @@ "https://iexcloud.io/docs/api/#collections\n", "\n", "Args:\n", - " tag (string); Sector, Tag, or List\n", - " collectionName (string); Associated name for tag\n", - " token (string); Access token\n", - " version (string); API version\n", + " tag (str); Sector, Tag, or List\n", + " collectionName (str); Associated name for tag\n", + " token (str); Access token\n", + " version (str); API version\n", "\n", "Returns:\n", " DataFrame: result\n", diff --git a/pyEX/account/__init__.py b/pyEX/account/__init__.py index e14933b..1159e58 100644 --- a/pyEX/account/__init__.py +++ b/pyEX/account/__init__.py @@ -9,9 +9,9 @@ def messageBudget(totalMessages=None, token='', version=''): https://iexcloud.io/docs/api/#message-budget Args: - totalMessages (int); The total messages your account is allowed to consume for the current month above your quota. For example: If your account is allowed 5 million messages, and you do not want to exceed 10 million for the month, then you will pass 10000000 as total messages. - token (string); Access token - version (string); API version + totalMessages (int): The total messages your account is allowed to consume for the current month above your quota. For example: If your account is allowed 5 million messages, and you do not want to exceed 10 million for the month, then you will pass 10000000 as total messages. + token (str): Access token + version (str): API version ''' _requireSecret(token) if not isinstance(totalMessages, int): @@ -25,8 +25,8 @@ def metadata(token='', version=''): https://iexcloud.io/docs/api/#metadata Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: dict: result @@ -41,8 +41,8 @@ def metadataDF(token='', version=''): https://iexcloud.io/docs/api/#metadata Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -56,9 +56,9 @@ def payAsYouGo(allow=False, token='', version=''): https://iexcloud.io/docs/api/#pay-as-you-go Args: - allow (bool); Enable or disable pay-as-you-go - token (string); Access token - version (string); API version + allow (bool): Enable or disable pay-as-you-go + token (str): Access token + version (str): API version ''' _requireSecret(token) if not isinstance(allow, bool): @@ -72,9 +72,9 @@ def usage(type=None, token='', version=''): https://iexcloud.io/docs/api/#usage Args: - type (Optional[string]); Used to specify which quota to return. Ex: messages, rules, rule-records, alerts, alert-records - token (string); Access token - version (string); API version + type (Optional[string]): Used to specify which quota to return. Ex: messages, rules, rule-records, alerts, alert-records + token (str): Access token + version (str): API version Returns: dict: result @@ -93,9 +93,9 @@ def usageDF(type=None, token='', version=''): https://iexcloud.io/docs/api/#usage Args: - type (Optional[string]); Used to specify which quota to return. Ex: messages, rules, rule-records, alerts, alert-records - token (string); Access token - version (string); API version + type (Optional[string]): Used to specify which quota to return. Ex: messages, rules, rule-records, alerts, alert-records + token (str): Access token + version (str): API version Returns: DataFrame: result diff --git a/pyEX/alternative/alternative.py b/pyEX/alternative/alternative.py index f20513f..46989f0 100644 --- a/pyEX/alternative/alternative.py +++ b/pyEX/alternative/alternative.py @@ -9,9 +9,9 @@ def crypto(token='', version='', filter=''): https://iexcloud.io/docs/api/#crypto Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -25,9 +25,9 @@ def cryptoDF(token='', version='', filter=''): https://iexcloud.io/docs/api/#crypto Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -45,12 +45,12 @@ def sentiment(symbol, type='daily', date=None, token='', version='', filter=''): Continuous Args: - symbol (string); Ticker to request - type (string); 'daily' or 'minute' - date (string); date in YYYYMMDD or datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + type (str): 'daily' or 'minute' + date (str): date in YYYYMMDD or datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -69,12 +69,12 @@ def sentimentDF(symbol, type='daily', date=None, token='', version='', filter='' Continuous Args: - symbol (string); Ticker to request - type (string); 'daily' or 'minute' - date (string); date in YYYYMMDD or datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + type (str): 'daily' or 'minute' + date (str): date in YYYYMMDD or datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -95,10 +95,10 @@ def ceoCompensation(symbol, token='', version='', filter=''): 1am daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -114,10 +114,10 @@ def ceoCompensationDF(symbol, token='', version='', filter=''): 1am daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/client.py b/pyEX/client.py index 8d21fc3..cb38b5e 100644 --- a/pyEX/client.py +++ b/pyEX/client.py @@ -648,8 +648,8 @@ class Client(object): Client has access to all methods provided as standalone, but in an authenticated way Args: - api_token (string): api token (can pickup from IEX_TOKEN environment variable) - version (string): api version to use (defaults to v1) + api_token (str): api token (can pickup from IEX_TOKEN environment variable) + version (str): api version to use (defaults to v1) set version to 'sandbox' to run against the IEX sandbox api_limit (int): cache calls in this interval ''' diff --git a/pyEX/cryptocurrency/cryptocurrency.py b/pyEX/cryptocurrency/cryptocurrency.py index b54798f..ff8dc28 100644 --- a/pyEX/cryptocurrency/cryptocurrency.py +++ b/pyEX/cryptocurrency/cryptocurrency.py @@ -10,10 +10,10 @@ def cryptoBook(symbol, token='', version='', filter=''): continuous Args: - symbol (string); cryptocurrency ticker - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): cryptocurrency ticker + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -28,10 +28,10 @@ def cryptoBookDF(symbol, token='', version='', filter=''): continuous Args: - symbol (string); cryptocurrency ticker - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): cryptocurrency ticker + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -46,10 +46,10 @@ def cryptoPrice(symbol, token='', version='', filter=''): continuous Args: - symbol (string); cryptocurrency ticker - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): cryptocurrency ticker + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -64,10 +64,10 @@ def cryptoPriceDF(symbol, token='', version='', filter=''): continuous Args: - symbol (string); cryptocurrency ticker - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): cryptocurrency ticker + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -83,10 +83,10 @@ def cryptoQuote(symbol, token='', version='', filter=''): continuous Args: - symbol (string); cryptocurrency ticker - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): cryptocurrency ticker + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -101,10 +101,10 @@ def cryptoQuoteDF(symbol, token='', version='', filter=''): continuous Args: - symbol (string); cryptocurrency ticker - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): cryptocurrency ticker + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/fx/fx.py b/pyEX/fx/fx.py index 360c1ea..8b05012 100644 --- a/pyEX/fx/fx.py +++ b/pyEX/fx/fx.py @@ -11,10 +11,10 @@ def latestFX(symbols=None, token='', version='', filter=''): 5pm Sun-4pm Fri UTC Args: - symbols (string): comma seperated list of symbols - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbols (str): comma seperated list of symbols + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -33,10 +33,10 @@ def latestFXDF(symbols=None, token='', version='', filter=''): 5pm Sun-4pm Fri UTC Args: - symbols (string): comma seperated list of symbols - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbols (str): comma seperated list of symbols + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: @@ -52,11 +52,11 @@ def convertFX(symbols=None, amount=None, token='', version='', filter=''): 5pm Sun-4pm Fri UTC Args: - symbols (string): comma seperated list of symbols + symbols (str): comma seperated list of symbols amount (float): amount to convert - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -76,11 +76,11 @@ def convertFXDF(symbols=None, amount=None, token='', version='', filter=''): 5pm Sun-4pm Fri UTC Args: - symbols (string): comma seperated list of symbols + symbols (str): comma seperated list of symbols amount (float): amount to convert - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: @@ -97,15 +97,15 @@ def historicalFX(symbols=None, from_='', to_='', on='', last=0, first=0, token=' 1am Mon-Sat UTC Args: - symbols (string): comma seperated list of symbols + symbols (str): comma seperated list of symbols from_ (str or datetime): Returns data on or after the given from date. Format YYYY-MM-DD to_ (str or datetime): Returns data on or before the given to date. Format YYYY-MM-DD on (str or datetime): Returns data on the given date. Format YYYY-MM-DD last (int): Returns the latest n number of records in the series first (int): Returns the first n number of records in the series - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -139,15 +139,15 @@ def historicalFXDF(symbols=None, from_='', to_='', on='', last=0, first=0, token 1am Mon-Sat UTC Args: - symbols (string): comma seperated list of symbols + symbols (str): comma seperated list of symbols from_ (str or datetime): Returns data on or after the given from date. Format YYYY-MM-DD to_ (str or datetime): Returns data on or before the given to date. Format YYYY-MM-DD on (str or datetime): Returns data on the given date. Format YYYY-MM-DD last (int): Returns the latest n number of records in the series first (int): Returns the first n number of records in the series - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: diff --git a/pyEX/marketdata/cryptocurrency.py b/pyEX/marketdata/cryptocurrency.py index 4d9c654..de8f8d0 100644 --- a/pyEX/marketdata/cryptocurrency.py +++ b/pyEX/marketdata/cryptocurrency.py @@ -22,10 +22,10 @@ def cryptoBookSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#cryptocurrency-book Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('cryptoBook', symbols, on_data, token, version) @@ -37,10 +37,10 @@ def cryptoEventsSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#cryptocurrency-events Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('cryptoEvents', symbols, on_data, token, version) @@ -52,10 +52,10 @@ def cryptoQuotesSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#cryptocurrency-quote Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('cryptoQuotes', symbols, on_data, token, version) diff --git a/pyEX/marketdata/fx.py b/pyEX/marketdata/fx.py index 00d3004..0104abf 100644 --- a/pyEX/marketdata/fx.py +++ b/pyEX/marketdata/fx.py @@ -20,10 +20,10 @@ def fxSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#forex-currencies Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('forex', symbols, on_data, token, version) diff --git a/pyEX/marketdata/http.py b/pyEX/marketdata/http.py index 3c2c084..72116b4 100644 --- a/pyEX/marketdata/http.py +++ b/pyEX/marketdata/http.py @@ -10,9 +10,9 @@ def tops(symbols=None, token='', version=''): https://iexcloud.io/docs/api/#tops Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -30,9 +30,9 @@ def topsDF(symbols=None, token='', version=''): https://iexcloud.io/docs/api/#tops Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -50,9 +50,9 @@ def last(symbols=None, token='', version=''): https://iexcloud.io/docs/api/#last Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -70,9 +70,9 @@ def lastDF(symbols=None, token='', version=''): https://iexcloud.io/docs/api/#last Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -94,9 +94,9 @@ def deep(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -118,9 +118,9 @@ def deepDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -137,9 +137,9 @@ def auction(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-auction Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -157,9 +157,9 @@ def auctionDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-auction Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -175,9 +175,9 @@ def book(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-book Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -194,9 +194,9 @@ def bookDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-book Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -224,9 +224,9 @@ def opHaltStatus(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-operational-halt-status Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -249,9 +249,9 @@ def opHaltStatusDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-operational-halt-status Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -275,9 +275,9 @@ def officialPrice(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-official-price Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -296,9 +296,9 @@ def officialPriceDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-official-price Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -314,9 +314,9 @@ def securityEvent(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-security-event Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -333,9 +333,9 @@ def securityEventDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-security-event Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -362,9 +362,9 @@ def ssrStatus(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-short-sale-price-test-status Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -386,9 +386,9 @@ def ssrStatusDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-short-sale-price-test-status Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -412,8 +412,8 @@ def systemEvent(token='', version=''): https://iexcloud.io/docs/api/#deep-system-event Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: dict: result @@ -429,8 +429,8 @@ def systemEventDF(token='', version=''): https://iexcloud.io/docs/api/#deep-system-event Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -446,9 +446,9 @@ def trades(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trades Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -465,9 +465,9 @@ def tradesDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trades Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -491,9 +491,9 @@ def tradeBreak(symbol=None, token='', version=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -511,9 +511,9 @@ def tradeBreakDF(symbol=None, token='', version=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -544,9 +544,9 @@ def tradingStatus(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trading-status Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: dict: result @@ -577,9 +577,9 @@ def tradingStatusDF(symbol=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trading-status Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version + symbol (str): Ticker to request + token (str): Access token + version (str): API version Returns: DataFrame: result @@ -600,9 +600,9 @@ def hist(date=None, token='', version=''): Args: - date (datetime); Effective date - token (string); Access token - version (string); API version + date (datetime): Effective date + token (str): Access token + version (str): API version Returns: dict: result diff --git a/pyEX/marketdata/sse.py b/pyEX/marketdata/sse.py index e836dbf..3f3aed2 100644 --- a/pyEX/marketdata/sse.py +++ b/pyEX/marketdata/sse.py @@ -40,10 +40,10 @@ def topsSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#tops Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('tops', symbols, on_data, token, version) @@ -56,10 +56,10 @@ def lastSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#last Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('last', symbols, on_data, token, version) @@ -76,10 +76,10 @@ def deepSSE(symbols=None, channels=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' symbols = _strCommaSeparatedString(symbols) @@ -111,10 +111,10 @@ def tradesSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trades Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' symbols = _strCommaSeparatedString(symbols) @@ -130,10 +130,10 @@ def auctionSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-auction Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('auction', symbols, on_data, token, version) @@ -145,10 +145,10 @@ def bookSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-book Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('book', symbols, on_data, token, version) @@ -166,10 +166,10 @@ def opHaltStatusSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-operational-halt-status Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('op-halt-status', symbols, on_data, token, version) @@ -183,10 +183,10 @@ def officialPriceSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-official-price Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('official-price', symbols, on_data, token, version) @@ -198,10 +198,10 @@ def securityEventSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-security-event Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('security-event', symbols, on_data, token, version) @@ -217,10 +217,10 @@ def ssrStatusSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-short-sale-price-test-status Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('ssr-status', symbols, on_data, token, version) @@ -234,10 +234,10 @@ def systemEventSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-system-event Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('system-event', symbols, on_data, token, version) @@ -249,10 +249,10 @@ def tradeBreaksSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trades Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('trade-breaks', symbols, on_data, token, version) @@ -278,10 +278,10 @@ def tradingStatusSSE(symbols=None, on_data=None, token='', version=''): https://iexcloud.io/docs/api/#deep-trading-status Args: - symbols (string); Tickers to request + symbols (str): Tickers to request on_data (function): Callback on data - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version ''' return _runSSE('trading-status', symbols, on_data, token, version) diff --git a/pyEX/options/options.py b/pyEX/options/options.py index b01aedb..a9fb35f 100644 --- a/pyEX/options/options.py +++ b/pyEX/options/options.py @@ -11,10 +11,10 @@ def optionExpirations(symbol, token='', version='', filter=''): 9:30am-5pm ET Mon-Fri Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -30,12 +30,12 @@ def options(symbol, expiration, side='', token='', version='', filter=''): 9:30am-5pm ET Mon-Fri Args: - symbol (string); Ticker to request - expiration (string); Expiration date - side (string); Side (optional) - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + expiration (str): Expiration date + side (str): Side (optional) + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -53,12 +53,12 @@ def optionsDF(symbol, expiration, side='', token='', version='', filter=''): 9:30am-5pm ET Mon-Fri Args: - symbol (string); Ticker to request - expiration (string); Expiration date - side (string); Side (optional) - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + expiration (str): Expiration date + side (str): Side (optional) + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/points/points.py b/pyEX/points/points.py index 311448a..c03883a 100644 --- a/pyEX/points/points.py +++ b/pyEX/points/points.py @@ -12,11 +12,11 @@ def points(symbol='market', key='', token='', version='', filter=''): https://iexcloud.io/docs/api/#data-points Args: - symbol (string); Ticker or market to query - key (string); data point to fetch. If empty or none, will return available data points - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker or market to query + key (str): data point to fetch. If empty or none, will return available data points + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -36,11 +36,11 @@ def pointsDF(symbol='market', key='', token='', version='', filter=''): https://iexcloud.io/docs/api/#data-points Args: - symbol (string); Ticker or market to query - key (string); data point to fetch. If empty or none, will return available data points - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker or market to query + key (str): data point to fetch. If empty or none, will return available data points + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/premium/auditanalytics/__init__.py b/pyEX/premium/auditanalytics/__init__.py index e1a71e3..3fd9f17 100644 --- a/pyEX/premium/auditanalytics/__init__.py +++ b/pyEX/premium/auditanalytics/__init__.py @@ -26,7 +26,7 @@ def directorAndOfficerChanges(symbol='', **kwargs): https://iexcloud.io/docs/api/#audit-analytics-director-and-officer-changes Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_AUDIT_ANALYTICS_DIRECTOR_OFFICER_CHANGES', symbol=symbol, **kwargs) @@ -37,7 +37,7 @@ def directorAndOfficerChangesDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#audit-analytics-director-and-officer-changes Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_AUDIT_ANALYTICS_DIRECTOR_OFFICER_CHANGES', symbol=symbol, **kwargs) @@ -48,7 +48,7 @@ def accountingQualityAndRiskMatrix(symbol='', **kwargs): https://iexcloud.io/docs/api/#audit-analytics-accounting-quality-and-risk-matrix Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_AUDIT_ANALYTICS_ACCOUNTING_QUALITY_RISK_MATRIX', symbol=symbol, **kwargs) @@ -59,6 +59,6 @@ def accountingQualityAndRiskMatrixDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#audit-analytics-accounting-quality-and-risk-matrix Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_AUDIT_ANALYTICS_ACCOUNTING_QUALITY_RISK_MATRIX', symbol=symbol, **kwargs) diff --git a/pyEX/premium/brain/__init__.py b/pyEX/premium/brain/__init__.py index 1babe98..1b44354 100644 --- a/pyEX/premium/brain/__init__.py +++ b/pyEX/premium/brain/__init__.py @@ -26,7 +26,7 @@ def brain30DaySentiment(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-30-day-sentiment-indicator Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_SENTIMENT_30_DAYS', symbol=symbol, **kwargs) @@ -37,7 +37,7 @@ def brain30DaySentimentDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-30-day-sentiment-indicator Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_SENTIMENT_30_DAYS', symbol=symbol, **kwargs) @@ -48,7 +48,7 @@ def brain7DaySentiment(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-7-day-sentiment-indicator Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_SENTIMENT_7_DAYS', symbol=symbol, **kwargs) @@ -59,7 +59,7 @@ def brain7DaySentimentDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-7-day-sentiment-indicator Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_SENTIMENT_7_DAYS', symbol=symbol, **kwargs) @@ -70,7 +70,7 @@ def brain21DayMLReturnRanking(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-21-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_RANKING_21_DAYS', symbol=symbol, **kwargs) @@ -81,7 +81,7 @@ def brain21DayMLReturnRankingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-21-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_RANKING_21_DAYS', symbol=symbol, **kwargs) @@ -92,7 +92,7 @@ def brain10DayMLReturnRanking(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-10-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_RANKING_10_DAYS', symbol=symbol, **kwargs) @@ -103,7 +103,7 @@ def brain10DayMLReturnRankingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-10-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_RANKING_10_DAYS', symbol=symbol, **kwargs) @@ -114,7 +114,7 @@ def brain5DayMLReturnRanking(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-5-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_RANKING_5_DAYS', symbol=symbol, **kwargs) @@ -125,7 +125,7 @@ def brain5DayMLReturnRankingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-5-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_RANKING_5_DAYS', symbol=symbol, **kwargs) @@ -136,7 +136,7 @@ def brain3DayMLReturnRanking(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-3-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_RANKING_3_DAYS', symbol=symbol, **kwargs) @@ -147,7 +147,7 @@ def brain3DayMLReturnRankingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-3-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_RANKING_3_DAYS', symbol=symbol, **kwargs) @@ -158,7 +158,7 @@ def brain2DayMLReturnRanking(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-2-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_RANKING_2_DAYS', symbol=symbol, **kwargs) @@ -169,7 +169,7 @@ def brain2DayMLReturnRankingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-2-day-machine-learning-estimated-return-ranking Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_RANKING_2_DAYS', symbol=symbol, **kwargs) @@ -180,7 +180,7 @@ def brainLanguageMetricsOnCompanyFilingsAll(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-language-metrics-on-company-filings-quarterly-and-annual Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_LANGUAGE_METRICS_ALL', symbol=symbol, **kwargs) @@ -191,7 +191,7 @@ def brainLanguageMetricsOnCompanyFilingsAllDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-language-metrics-on-company-filings-quarterly-and-annual Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_LANGUAGE_METRICS_ALL', symbol=symbol, **kwargs) @@ -202,7 +202,7 @@ def brainLanguageMetricsOnCompanyFilings(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-language-metrics-on-company-filings-annual-only Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_LANGUAGE_METRICS_10K', symbol=symbol, **kwargs) @@ -213,7 +213,7 @@ def brainLanguageMetricsOnCompanyFilingsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-language-metrics-on-company-filings-annual-only Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_LANGUAGE_METRICS_10K', symbol=symbol, **kwargs) @@ -224,7 +224,7 @@ def brainLanguageMetricsOnCompanyFilingsDifferenceAll(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-differences-in-language-metrics-on-company-filings-quarterly-and-annual-from-prior-period Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_LANGUAGE_DIFFERENCES_ALL', symbol=symbol, **kwargs) @@ -235,7 +235,7 @@ def brainLanguageMetricsOnCompanyFilingsDifferenceAllDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-differences-in-language-metrics-on-company-filings-quarterly-and-annual-from-prior-period Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_LANGUAGE_DIFFERENCES_ALL', symbol=symbol, **kwargs) @@ -246,7 +246,7 @@ def brainLanguageMetricsOnCompanyFilingsDifference(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-differences-in-language-metrics-on-company-annual-filings-from-prior-year Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_BRAIN_LANGUAGE_DIFFERENCES_10K', symbol=symbol, **kwargs) @@ -257,6 +257,6 @@ def brainLanguageMetricsOnCompanyFilingsDifferenceDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#brain-companys-differences-in-language-metrics-on-company-annual-filings-from-prior-year Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_BRAIN_LANGUAGE_DIFFERENCES_10K', symbol=symbol, **kwargs) diff --git a/pyEX/premium/extractalpha/__init__.py b/pyEX/premium/extractalpha/__init__.py index 20f5764..ee21f95 100644 --- a/pyEX/premium/extractalpha/__init__.py +++ b/pyEX/premium/extractalpha/__init__.py @@ -29,7 +29,7 @@ def cam1(symbol='', **kwargs): https://iexcloud.io/docs/api/#cross-asset-model-1 Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_EXTRACT_ALPHA_CAM', symbol=symbol, **kwargs) @@ -43,7 +43,7 @@ def cam1DF(symbol='', **kwargs): https://iexcloud.io/docs/api/#cross-asset-model-1 Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_CAM', symbol=symbol, **kwargs) @@ -58,7 +58,7 @@ def esgCFPBComplaints(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-cfpb-complaints Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '1' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -73,7 +73,7 @@ def esgCFPBComplaintsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-cfpb-complaints Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '1' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -88,7 +88,7 @@ def esgCPSCRecalls(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-cpsc-recalls Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '5' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -103,7 +103,7 @@ def esgCPSCRecallsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-cfpb-complaints Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '5' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -119,7 +119,7 @@ def esgDOLVisaApplications(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-dol-visa-applications Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '8' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -135,7 +135,7 @@ def esgDOLVisaApplicationsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-dol-visa-applications Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '8' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -151,7 +151,7 @@ def esgEPAEnforcements(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-epa-enforcements Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '2' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -167,7 +167,7 @@ def esgEPAEnforcementsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-epa-enforcements Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '2' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -180,7 +180,7 @@ def esgEPAMilestones(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-epa-milestones Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '3' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -193,7 +193,7 @@ def esgEPAMilestonesDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-epa-milestones Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '3' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -206,7 +206,7 @@ def esgFECIndividualCampaingContributions(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-fec-individual-campaign-contributions Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '7' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -219,7 +219,7 @@ def esgFECIndividualCampaingContributionsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-fec-individual-campaign-contributions Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '7' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -233,7 +233,7 @@ def esgOSHAInspections(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-osha-inspections Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '4' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -247,7 +247,7 @@ def esgOSHAInspectionsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-osha-inspections Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '4' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -260,7 +260,7 @@ def esgSenateLobbying(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-senate-lobbying Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '6' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -273,7 +273,7 @@ def esgSenateLobbyingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-senate-lobbying Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '6' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -287,7 +287,7 @@ def esgUSASpending(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-usa-spending Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '9' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -301,7 +301,7 @@ def esgUSASpendingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-usa-spending Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '9' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -315,7 +315,7 @@ def esgUSPTOPatentApplications(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-uspto-patent-applications Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '10' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -329,7 +329,7 @@ def esgUSPTOPatentApplicationsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-uspto-patent-applications Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '10' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -344,7 +344,7 @@ def esgUSPTOPatentGrants(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-uspto-patent-grants Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '10' return _base(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -359,7 +359,7 @@ def esgUSPTOPatentGrantsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#esg-uspto-patent-grants Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' kwargs['subkey'] = '10' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_ESG', symbol=symbol, **kwargs) @@ -376,7 +376,7 @@ def tacticalModel1(symbol='', **kwargs): https://iexcloud.io/docs/api/#tactical-model-1 Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_EXTRACT_ALPHA_TM', symbol=symbol, **kwargs) @@ -392,6 +392,6 @@ def tacticalModel1DF(symbol='', **kwargs): https://iexcloud.io/docs/api/#tactical-model-1 Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_EXTRACT_ALPHA_TM', symbol=symbol, **kwargs) diff --git a/pyEX/premium/fraudfactors/__init__.py b/pyEX/premium/fraudfactors/__init__.py index d98eccf..f9d2e5e 100644 --- a/pyEX/premium/fraudfactors/__init__.py +++ b/pyEX/premium/fraudfactors/__init__.py @@ -30,7 +30,7 @@ def similarityIndex(symbol='', **kwargs): https://iexcloud.io/docs/api/#similiarity-index Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_FRAUD_FACTORS_SIMILARITY_INDEX', symbol=symbol, **kwargs) @@ -45,7 +45,7 @@ def similarityIndexDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#similiarity-index Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_FRAUD_FACTORS_SIMILARITY_INDEX', symbol=symbol, **kwargs) @@ -58,7 +58,7 @@ def nonTimelyFilings(symbol='', **kwargs): https://iexcloud.io/docs/api/#non-timely-filings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_FRAUD_FACTORS_NON_TIMELY_FILINGS', symbol=symbol, **kwargs) @@ -71,6 +71,6 @@ def nonTimelyFilingsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#non-timely-filings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_FRAUD_FACTORS_NON_TIMELY_FILINGS', symbol=symbol, **kwargs) diff --git a/pyEX/premium/kavout/__init__.py b/pyEX/premium/kavout/__init__.py index fe6cbf2..3c87732 100644 --- a/pyEX/premium/kavout/__init__.py +++ b/pyEX/premium/kavout/__init__.py @@ -27,7 +27,7 @@ def kScore(symbol='', **kwargs): https://iexcloud.io/docs/api/#k-score-for-us-equities Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_KAVOUT_KSCORE', symbol=symbol, **kwargs) @@ -39,6 +39,6 @@ def kScoreDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#k-score-for-us-equities Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_KAVOUT_KSCORE', symbol=symbol, **kwargs) diff --git a/pyEX/premium/precisionalpha/__init__.py b/pyEX/premium/precisionalpha/__init__.py index ebb9ec2..df3e64e 100644 --- a/pyEX/premium/precisionalpha/__init__.py +++ b/pyEX/premium/precisionalpha/__init__.py @@ -26,7 +26,7 @@ def precisionAlphaPriceDynamics(symbol='', **kwargs): https://iexcloud.io/docs/api/#precision-alpha-price-dynamics Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_PRECISION_ALPHA_PRICE_DYNAMICS', symbol=symbol, **kwargs) @@ -37,6 +37,6 @@ def precisionAlphaPriceDynamicsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#precision-alpha-price-dynamics Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_PRECISION_ALPHA_PRICE_DYNAMICS', symbol=symbol, **kwargs) diff --git a/pyEX/premium/stocktwits/__init__.py b/pyEX/premium/stocktwits/__init__.py new file mode 100644 index 0000000..24a5b20 --- /dev/null +++ b/pyEX/premium/stocktwits/__init__.py @@ -0,0 +1,44 @@ +# -*- coding: utf-8 -*- +import pandas as pd +from functools import wraps +from ...common import _getJson, PyEXception, _toDatetime, _strOrDate, _raiseIfNotStr + + +def socialSentiment(symbol, + type='daily', + date='', + token='', + version='', + filter=''): + '''This endpoint provides social sentiment data from StockTwits. Data can be viewed as a daily value, or by minute for a given date. + + https://iexcloud.io/docs/api/#social-sentiment + + Args: + symbol (str): Symbol to look up + type (Optional[str]): Can only be daily or minute. Default is daily. + date (Optional[str]): Format YYYYMMDD date to fetch sentiment data. Default is today. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results + + Returns: + dict or DataFrame: result + ''' + _raiseIfNotStr(symbol) + + if type not in ('daily', 'minute'): + raise PyEXception('`type` must be in (daily, minute). Got: {}'.format(type)) + base_url = 'stock/{}/sentiment/{}'.format(symbol, type) + + if date: + date = _strOrDate(date) + base_url += '/{}'.format(date) + return _getJson(base_url, token, version, filter) + + +@wraps(socialSentiment) +def socialSentimentDF(*args, **kwargs): + df = pd.io.json.json_normalize(socialSentiment(*args, **kwargs)) + _toDatetime(df) + return df diff --git a/pyEX/premium/valuengine/__init__.py b/pyEX/premium/valuengine/__init__.py index 22c09f5..8ea53df 100644 --- a/pyEX/premium/valuengine/__init__.py +++ b/pyEX/premium/valuengine/__init__.py @@ -8,7 +8,7 @@ def valuEngineStockResearchReport(symbol='', date=None, token='', version=''): https://iexcloud.io/docs/api/#valuengine-stock-research-report Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' if not symbol or not date: raise PyEXception("symbol and date required") diff --git a/pyEX/premium/wallstreethorizon/__init__.py b/pyEX/premium/wallstreethorizon/__init__.py index 7fafd42..0ed999a 100644 --- a/pyEX/premium/wallstreethorizon/__init__.py +++ b/pyEX/premium/wallstreethorizon/__init__.py @@ -27,7 +27,7 @@ def analystDays(symbol='', **kwargs): https://iexcloud.io/docs/api/#analyst-days Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_ANALYST_DAY', symbol=symbol, **kwargs) @@ -39,7 +39,7 @@ def analystDaysDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#analyst-days Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_ANALYST_DAY', symbol=symbol, **kwargs) @@ -50,7 +50,7 @@ def boardOfDirectorsMeeting(symbol='', **kwargs): https://iexcloud.io/docs/api/#analyst-days Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_BOARD_OF_DIRECTORS_MEETING', symbol=symbol, **kwargs) @@ -61,7 +61,7 @@ def boardOfDirectorsMeetingDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#board-of-directors-meeting Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_BOARD_OF_DIRECTORS_MEETING', symbol=symbol, **kwargs) @@ -72,7 +72,7 @@ def businessUpdates(symbol='', **kwargs): https://iexcloud.io/docs/api/#business-updates Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_BUSINESS_UPDATE', symbol=symbol, **kwargs) @@ -83,7 +83,7 @@ def businessUpdatesDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#business-updates Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_BUSINESS_UPDATE', symbol=symbol, **kwargs) @@ -94,7 +94,7 @@ def buybacks(symbol='', **kwargs): https://iexcloud.io/docs/api/#buybacks Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_BUYBACK', symbol=symbol, **kwargs) @@ -105,7 +105,7 @@ def buybacksDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#buybacks Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_BUYBACK', symbol=symbol, **kwargs) @@ -116,7 +116,7 @@ def capitalMarketsDay(symbol='', **kwargs): https://iexcloud.io/docs/api/#capital-markets-day Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_CAPITAL_MARKETS_DAY', symbol=symbol, **kwargs) @@ -127,7 +127,7 @@ def capitalMarketsDayDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#capital-markets-day Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_CAPITAL_MARKETS_DAY', symbol=symbol, **kwargs) @@ -138,7 +138,7 @@ def companyTravel(symbol='', **kwargs): https://iexcloud.io/docs/api/#company-travel Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_COMPANY_TRAVEL', symbol=symbol, **kwargs) @@ -149,7 +149,7 @@ def companyTravelDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#company-travel Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_COMPANY_TRAVEL', symbol=symbol, **kwargs) @@ -160,7 +160,7 @@ def filingDueDates(symbol='', **kwargs): https://iexcloud.io/docs/api/#filing-due-dates Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_FILING_DUE_DATE', symbol=symbol, **kwargs) @@ -171,7 +171,7 @@ def filingDueDatesDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#filing-due-dates Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_FILING_DUE_DATE', symbol=symbol, **kwargs) @@ -182,7 +182,7 @@ def fiscalQuarterEnd(symbol='', **kwargs): https://iexcloud.io/docs/api/#fiscal-quarter-end Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_FISCAL_QUARTER_END_DATE', symbol=symbol, **kwargs) @@ -193,7 +193,7 @@ def fiscalQuarterEndDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#fiscal-quarter-end Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_FISCAL_QUARTER_END_DATE', symbol=symbol, **kwargs) @@ -204,7 +204,7 @@ def forum(symbol='', **kwargs): https://iexcloud.io/docs/api/#forum Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_FORUM', symbol=symbol, **kwargs) @@ -215,7 +215,7 @@ def forumDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#forum Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_FORUM', symbol=symbol, **kwargs) @@ -226,7 +226,7 @@ def generalConference(symbol='', **kwargs): https://iexcloud.io/docs/api/#general-conference Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_GENERAL_CONFERENCE', symbol=symbol, **kwargs) @@ -237,7 +237,7 @@ def generalConferenceDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#general-conference Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_GENERAL_CONFERENCE', symbol=symbol, **kwargs) @@ -248,7 +248,7 @@ def fdaAdvisoryCommitteeMeetings(symbol='', **kwargs): https://iexcloud.io/docs/api/#fda-advisory-committee-meetings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_STOCK_SPECIFIC_FDA_ADVISORY_COMMITTEE_MEETING', symbol=symbol, **kwargs) @@ -259,7 +259,7 @@ def fdaAdvisoryCommitteeMeetingsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#fda-advisory-committee-meetings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_STOCK_SPECIFIC_FDA_ADVISORY_COMMITTEE_MEETING', symbol=symbol, **kwargs) @@ -270,7 +270,7 @@ def holidaysWSH(symbol='', **kwargs): https://iexcloud.io/docs/api/#holidays Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_HOLIDAYS', symbol=symbol, **kwargs) @@ -281,7 +281,7 @@ def holidaysWSHDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#holidays Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_HOLIDAYS', symbol=symbol, **kwargs) @@ -292,7 +292,7 @@ def indexChanges(symbol='', **kwargs): https://iexcloud.io/docs/api/#index-changes Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_INDEX_CHANGE', symbol=symbol, **kwargs) @@ -303,7 +303,7 @@ def indexChangesDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#index-changes Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_INDEX_CHANGE', symbol=symbol, **kwargs) @@ -314,7 +314,7 @@ def iposWSH(symbol='', **kwargs): https://iexcloud.io/docs/api/#ipos Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_INITIAL_PUBLIC_OFFERING', symbol=symbol, **kwargs) @@ -325,7 +325,7 @@ def iposWSHDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#ipos Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_INITIAL_PUBLIC_OFFERING', symbol=symbol, **kwargs) @@ -336,7 +336,7 @@ def legalActions(symbol='', **kwargs): https://iexcloud.io/docs/api/#legal-actions Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_LEGAL_ACTIONS', symbol=symbol, **kwargs) @@ -347,7 +347,7 @@ def legalActionsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#legal-actions Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_LEGAL_ACTIONS', symbol=symbol, **kwargs) @@ -358,7 +358,7 @@ def mergersAndAcquisitions(symbol='', **kwargs): https://iexcloud.io/docs/api/#mergers-acquisitions Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_MERGER_ACQUISITIONS', symbol=symbol, **kwargs) @@ -369,7 +369,7 @@ def mergersAndAcquisitionsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#mergers-acquisitions Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_MERGER_ACQUISITIONS', symbol=symbol, **kwargs) @@ -380,7 +380,7 @@ def productEvents(symbol='', **kwargs): https://iexcloud.io/docs/api/#product-events Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_PRODUCT_EVENTS', symbol=symbol, **kwargs) @@ -391,7 +391,7 @@ def productEventsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#product-events Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_PRODUCT_EVENTS', symbol=symbol, **kwargs) @@ -402,7 +402,7 @@ def researchAndDevelopmentDays(symbol='', **kwargs): https://iexcloud.io/docs/api/#research-and-development-days Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_RD_DAY', symbol=symbol, **kwargs) @@ -413,7 +413,7 @@ def researchAndDevelopmentDaysDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#research-and-development-days Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_RD_DAY', symbol=symbol, **kwargs) @@ -424,7 +424,7 @@ def sameStoreSales(symbol='', **kwargs): https://iexcloud.io/docs/api/#same-store-sales Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_SAME_STORE_SALES', symbol=symbol, **kwargs) @@ -435,7 +435,7 @@ def sameStoreSalesDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#same-store-sales Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_SAME_STORE_SALES', symbol=symbol, **kwargs) @@ -449,7 +449,7 @@ def secondaryOfferings(symbol='', **kwargs): https://iexcloud.io/docs/api/#secondary-offerings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_SECONDARY_OFFERING', symbol=symbol, **kwargs) @@ -463,7 +463,7 @@ def secondaryOfferingsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#secondary-offerings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_SECONDARY_OFFERING', symbol=symbol, **kwargs) @@ -474,7 +474,7 @@ def seminars(symbol='', **kwargs): https://iexcloud.io/docs/api/#seminars Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_SEMINAR', symbol=symbol, **kwargs) @@ -485,7 +485,7 @@ def seminarsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#seminars Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_SEMINAR', symbol=symbol, **kwargs) @@ -496,7 +496,7 @@ def shareholderMeetings(symbol='', **kwargs): https://iexcloud.io/docs/api/#shareholder-meetings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_SHAREHOLDER_MEETING', symbol=symbol, **kwargs) @@ -507,7 +507,7 @@ def shareholderMeetingsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#shareholder-meetings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_SHAREHOLDER_MEETING', symbol=symbol, **kwargs) @@ -518,7 +518,7 @@ def summitMeetings(symbol='', **kwargs): https://iexcloud.io/docs/api/#summit-meetings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_SUMMIT_MEETING', symbol=symbol, **kwargs) @@ -529,7 +529,7 @@ def summitMeetingsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#summit-meetings Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_SUMMIT_MEETING', symbol=symbol, **kwargs) @@ -540,7 +540,7 @@ def tradeShows(symbol='', **kwargs): https://iexcloud.io/docs/api/#trade-shows Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_TRADE_SHOW', symbol=symbol, **kwargs) @@ -551,7 +551,7 @@ def tradeShowsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#trade-shows Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_TRADE_SHOW', symbol=symbol, **kwargs) @@ -562,7 +562,7 @@ def witchingHours(symbol='', **kwargs): https://iexcloud.io/docs/api/#witching-hours Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_WITCHING_HOURS', symbol=symbol, **kwargs) @@ -573,7 +573,7 @@ def witchingHoursDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#witching-hours Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_WITCHING_HOURS', symbol=symbol, **kwargs) @@ -584,7 +584,7 @@ def workshops(symbol='', **kwargs): https://iexcloud.io/docs/api/#workshops Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _base(id='PREMIUM_WALLSTREETHORIZON_WORKSHOP', symbol=symbol, **kwargs) @@ -595,6 +595,6 @@ def workshopsDF(symbol='', **kwargs): https://iexcloud.io/docs/api/#workshops Args: - symbol (str); symbol to use + symbol (str): symbol to use ''' return _baseDF(id='PREMIUM_WALLSTREETHORIZON_WORKSHOP', symbol=symbol, **kwargs) diff --git a/pyEX/refdata/calendar.py b/pyEX/refdata/calendar.py index 8c43f64..ae7d4c5 100644 --- a/pyEX/refdata/calendar.py +++ b/pyEX/refdata/calendar.py @@ -11,13 +11,13 @@ def calendar(type='holiday', direction='next', last=1, startDate=None, token='', 8am, 9am, 12pm, 1pm UTC daily Args: - type (string); "holiday" or "trade" - direction (string); "next" or "last" - last (int); number to move in direction - startDate (date); start date for next or last, YYYYMMDD - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + type (str): "holiday" or "trade" + direction (str): "next" or "last" + last (int): number to move in direction + startDate (date): start date for next or last, YYYYMMDD + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -35,13 +35,13 @@ def calendarDF(type='holiday', direction='next', last=1, startDate=None, token=' 8am, 9am, 12pm, 1pm UTC daily Args: - type (string); "holiday" or "trade" - direction (string); "next" or "last" - last (int); number to move in direction - startDate (date); start date for next or last, YYYYMMDD - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + type (str): "holiday" or "trade" + direction (str): "next" or "last" + last (int): number to move in direction + startDate (date): start date for next or last, YYYYMMDD + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -59,12 +59,12 @@ def holidays(direction='next', last=1, startDate=None, token='', version='', fil 8am, 9am, 12pm, 1pm UTC daily Args: - direction (string); "next" or "last" - last (int); number to move in direction - startDate (date); start date for next or last, YYYYMMDD - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + direction (str): "next" or "last" + last (int): number to move in direction + startDate (date): start date for next or last, YYYYMMDD + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -79,12 +79,12 @@ def holidaysDF(direction='next', last=1, startDate=None, token='', version='', f 8am, 9am, 12pm, 1pm UTC daily Args: - direction (string); "next" or "last" - last (int); number to move in direction - startDate (date); start date for next or last, YYYYMMDD - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + direction (str): "next" or "last" + last (int): number to move in direction + startDate (date): start date for next or last, YYYYMMDD + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result diff --git a/pyEX/refdata/exchanges.py b/pyEX/refdata/exchanges.py index 0d13150..6f44358 100644 --- a/pyEX/refdata/exchanges.py +++ b/pyEX/refdata/exchanges.py @@ -11,9 +11,9 @@ def exchanges(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -28,9 +28,9 @@ def exchangesDF(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -46,9 +46,9 @@ def internationalExchanges(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -63,9 +63,9 @@ def internationalExchangesDF(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/refdata/figi.py b/pyEX/refdata/figi.py index f31b799..a52082a 100644 --- a/pyEX/refdata/figi.py +++ b/pyEX/refdata/figi.py @@ -9,9 +9,9 @@ def figi(figi_=None, token='', version=''): https://iexcloud.io/docs/api/#figi-mapping Args: - figi_ (string); figi to lookup - token (string); Access token - version (string); API version + figi_ (str): figi to lookup + token (str): Access token + version (str): API version Returns: dict: result @@ -26,9 +26,9 @@ def figiDF(figi_=None, token='', version=''): https://iexcloud.io/docs/api/#figi-mapping Args: - figi_ (string); figi to lookup - token (string); Access token - version (string); API version + figi_ (str): figi to lookup + token (str): Access token + version (str): API version Returns: DataFrame: result diff --git a/pyEX/refdata/refdata.py b/pyEX/refdata/refdata.py index 7c34b34..1ec9d07 100644 --- a/pyEX/refdata/refdata.py +++ b/pyEX/refdata/refdata.py @@ -10,9 +10,9 @@ def corporateActions(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -29,9 +29,9 @@ def corporateActionsDF(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -47,9 +47,9 @@ def dividends(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -66,9 +66,9 @@ def dividendsDF(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -84,9 +84,9 @@ def nextDayExtDate(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -103,9 +103,9 @@ def nextDayExtDateDF(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -121,9 +121,9 @@ def directory(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -140,9 +140,9 @@ def directoryDF(date=None, token='', version='', filter=''): Args: date (datetime): Effective date - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result diff --git a/pyEX/refdata/sectors.py b/pyEX/refdata/sectors.py index 53187dc..df3f5bc 100644 --- a/pyEX/refdata/sectors.py +++ b/pyEX/refdata/sectors.py @@ -10,9 +10,9 @@ def sectors(token='', version='', filter=''): https://iexcloud.io/docs/api/#sectors Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -26,9 +26,9 @@ def sectorsDF(token='', version='', filter=''): https://iexcloud.io/docs/api/#sectors Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -43,9 +43,9 @@ def tags(token='', version='', filter=''): https://iexcloud.io/docs/api/#tags Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -59,9 +59,9 @@ def tagsDF(token='', version='', filter=''): https://iexcloud.io/docs/api/#tags Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/refdata/symbols.py b/pyEX/refdata/symbols.py index f294c60..6c3d82e 100644 --- a/pyEX/refdata/symbols.py +++ b/pyEX/refdata/symbols.py @@ -11,9 +11,9 @@ def symbols(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -30,9 +30,9 @@ def iexSymbols(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -48,9 +48,9 @@ def mutualFundSymbols(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -66,9 +66,9 @@ def otcSymbols(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -84,11 +84,11 @@ def internationalSymbols(region='', exchange='', token='', version='', filter='' 8am, 9am, 12pm, 1pm UTC daily Args: - region (string); region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 - exchange (string): Case insensitive string of Exchange using IEX Supported Exchanges list - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + region (str): region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 + exchange (str): Case insensitive string of Exchange using IEX Supported Exchanges list + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -108,8 +108,8 @@ def fxSymbols(token='', version=''): 7am, 9am, UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: dict: result @@ -125,9 +125,9 @@ def optionsSymbols(token='', version='', filter=''): 9:30am ET Tue-Sat Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -142,9 +142,9 @@ def symbolsDF(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dataframe: result @@ -163,9 +163,9 @@ def iexSymbolsDF(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -183,9 +183,9 @@ def mutualFundSymbolsDF(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -203,9 +203,9 @@ def otcSymbolsDF(token='', version='', filter=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -223,11 +223,11 @@ def internationalSymbolsDF(region='', exchange='', token='', version='', filter= 8am, 9am, 12pm, 1pm UTC daily Args: - region (string); region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 - exchange (string): Case insensitive string of Exchange using IEX Supported Exchanges list - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + region (str): region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 + exchange (str): Case insensitive string of Exchange using IEX Supported Exchanges list + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -245,8 +245,8 @@ def fxSymbolsDF(token='', version=''): 7am, 9am, UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: [DataFrame]: results @@ -265,9 +265,9 @@ def optionsSymbolsDF(token='', version='', filter=''): 9:30am ET Tue-Sat Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -285,8 +285,8 @@ def symbolsList(token='', version=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: list: result @@ -302,8 +302,8 @@ def iexSymbolsList(token='', version=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: list: result @@ -318,8 +318,8 @@ def mutualFundSymbolsList(token='', version=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: List: result @@ -334,8 +334,8 @@ def otcSymbolsList(token='', version=''): 8am, 9am, 12pm, 1pm UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: list: result @@ -350,10 +350,10 @@ def internationalSymbolsList(region='', exchange='', token='', version=''): 8am, 9am, 12pm, 1pm UTC daily Args: - region (string); region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 - exchange (string): Case insensitive string of Exchange using IEX Supported Exchanges list - token (string); Access token - version (string); API version + region (str): region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 + exchange (str): Case insensitive string of Exchange using IEX Supported Exchanges list + token (str): Access token + version (str): API version Returns: list: result @@ -368,8 +368,8 @@ def fxSymbolsList(token='', version=''): 7am, 9am, UTC daily Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: list: result @@ -390,8 +390,8 @@ def optionsSymbolsList(token='', version=''): 9:30am ET Tue-Sat Args: - token (string); Access token - version (string); API version + token (str): Access token + version (str): API version Returns: list: result diff --git a/pyEX/rules/__init__.py b/pyEX/rules/__init__.py index 2f68002..4963d0f 100644 --- a/pyEX/rules/__init__.py +++ b/pyEX/rules/__init__.py @@ -10,9 +10,9 @@ def lookup(lookup='', token='', version=''): https://iexcloud.io/docs/api/#rules-schema Args: - lookup (string); If a schema object has “isLookup”: true, pass the value key to /stable/rules/lookup/{value}. This returns all valid values for the rightValue of a condition. - token (string); Access token - version (string); API version + lookup (str): If a schema object has “isLookup”: true, pass the value key to /stable/rules/lookup/{value}. This returns all valid values for the rightValue of a condition. + token (str): Access token + version (str): API version Returns: dict: result diff --git a/pyEX/stats/stats.py b/pyEX/stats/stats.py index ee09582..52d7388 100644 --- a/pyEX/stats/stats.py +++ b/pyEX/stats/stats.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import pandas as pd from datetime import datetime +from functools import wraps from ..common import _expire, _getJson, PyEXception, _strOrDate, _reindex, _toDatetime @@ -8,27 +9,20 @@ def stats(token='', version='', filter=''): '''https://iexcloud.io/docs/api/#stats-intraday Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('stats/intraday', token, version, filter) -def statsDF(token='', version='', filters=''): - '''https://iexcloud.io/docs/api/#stats-intraday +wraps(stats) - Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results - Returns: - DataFrame: result - ''' +def statsDF(token='', version='', filters=''): df = pd.DataFrame(stats(token, version, filter)) _toDatetime(df) return df @@ -38,27 +32,20 @@ def recent(token='', version='', filter=''): '''https://iexcloud.io/docs/api/#stats-recent Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('stats/recent', token, version, filter) -def recentDF(token='', version='', filter=''): - '''https://iexcloud.io/docs/api/#stats-recent +wraps(recent) - Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results - Returns: - DataFrame: result - ''' +def recentDF(token='', version='', filter=''): df = pd.DataFrame(recent(token, version, filter)) _toDatetime(df) _reindex(df, 'date') @@ -69,27 +56,20 @@ def records(token='', version='', filter=''): '''https://iexcloud.io/docs/api/#stats-records Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('stats/records', token, version, filter) -def recordsDF(token='', version='', filter=''): - '''https://iexcloud.io/docs/api/#stats-records +wraps(records) - Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results - Returns: - DataFrame: result - ''' +def recordsDF(token='', version='', filter=''): df = pd.DataFrame(records(token, version, filter)) _toDatetime(df) return df @@ -100,12 +80,13 @@ def summary(date=None, token='', version='', filter=''): '''https://iexcloud.io/docs/api/#stats-historical-summary Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + date (Optional[str]): Format YYYYMMDD date to fetch sentiment data. Default is today. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: if isinstance(date, str): @@ -117,17 +98,10 @@ def summary(date=None, token='', version='', filter=''): return _getJson('stats/historical', token, version, filter) -def summaryDF(date=None, token='', version='', filter=''): - '''https://iexcloud.io/docs/api/#stats-historical-summary +wraps(summary) - Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results - Returns: - DataFrame: result - ''' +def summaryDF(date=None, token='', version='', filter=''): df = pd.DataFrame(summary(date, token, version, filter)) _toDatetime(df) return df @@ -138,12 +112,14 @@ def daily(date=None, last='', token='', version='', filter=''): '''https://iexcloud.io/docs/api/#stats-historical-daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + date (Optional[str]): Format YYYYMMDD date to fetch sentiment data. Default is today. + last (Optional[int]): Optional last number to include + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: date = _strOrDate(date) @@ -153,17 +129,10 @@ def daily(date=None, last='', token='', version='', filter=''): return _getJson('stats/historical/daily', token, version, filter) -def dailyDF(date=None, last='', token='', version='', filter=''): - '''https://iexcloud.io/docs/api/#stats-historical-daily +wraps(daily) - Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results - Returns: - DataFrame: result - ''' +def dailyDF(date=None, last='', token='', version='', filter=''): df = pd.DataFrame(daily(date, last, token, version, filter)) _toDatetime(df) return df diff --git a/pyEX/stocks/batch.py b/pyEX/stocks/batch.py index 1c2dfb9..17adade 100644 --- a/pyEX/stocks/batch.py +++ b/pyEX/stocks/batch.py @@ -31,13 +31,13 @@ def batch(symbols, fields=None, range_='1m', last=10, token='', version='', filt Args: - symbols (list); List of tickers to request - fields (list); List of fields to request - range_ (string); Date range for chart - last (int); - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbols (list): List of tickers to request + fields (list): List of fields to request + range_ (str): Date range for chart + last (int): + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: results in json @@ -71,13 +71,13 @@ def batchDF(symbols, fields=None, range_='1m', last=10, token='', version='', fi Args: - symbols (list); List of tickers to request - fields (list); List of fields to request - range_ (string); Date range for chart - last (int); - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbols (list): List of tickers to request + fields (list): List of fields to request + range_ (str): Date range for chart + last (int): + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: results in json @@ -110,13 +110,13 @@ def bulkBatch(symbols, fields=None, range_='1m', last=10, token='', version='', Args: - symbols (list); List of tickers to request - fields (list); List of fields to request - range_ (string); Date range for chart - last (int); - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbols (list): List of tickers to request + fields (list): List of fields to request + range_ (str): Date range for chart + last (int): + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: results in json @@ -160,13 +160,13 @@ def bulkBatchDF(symbols, fields=None, range_='1m', last=10, token='', version='' Args: - symbols (list); List of tickers to request - fields (list); List of fields to request - range_ (string); Date range for chart - last (int); - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbols (list): List of tickers to request + fields (list): List of fields to request + range_ (str): Date range for chart + last (int): + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: results in json diff --git a/pyEX/stocks/corporateActions.py b/pyEX/stocks/corporateActions.py index 003920d..e6ae681 100644 --- a/pyEX/stocks/corporateActions.py +++ b/pyEX/stocks/corporateActions.py @@ -12,11 +12,11 @@ def bonusIssue(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#bonus-issue Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -42,11 +42,11 @@ def distribution(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#distribution Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -72,11 +72,11 @@ def returnOfCapital(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#return-of-capital Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -102,11 +102,11 @@ def rightsIssue(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#rights-issue Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -132,11 +132,11 @@ def rightToPurchase(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#right-to-purchase Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -162,11 +162,11 @@ def securityReclassification(symbol='', refid='', token='', version='', filter=' https://iexcloud.io/docs/api/#security-reclassification Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -192,11 +192,11 @@ def securitySwap(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#security-swap Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -222,11 +222,11 @@ def spinoff(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#spinoff Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -252,11 +252,11 @@ def splits(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#splits Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result diff --git a/pyEX/stocks/fundamentals.py b/pyEX/stocks/fundamentals.py index cd2091c..96f1e5f 100644 --- a/pyEX/stocks/fundamentals.py +++ b/pyEX/stocks/fundamentals.py @@ -14,12 +14,12 @@ def balanceSheet(symbol, period='quarter', last=1, token='', version='', filter= Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - last (int); Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -47,12 +47,12 @@ def cashFlow(symbol, period='quarter', last=1, token='', version='', filter=''): Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - last (int); Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -80,10 +80,10 @@ def dividends(symbol, timeframe='ytd', token='', version='', filter=''): Updated at 9am UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -117,12 +117,12 @@ def earnings(symbol, period='quarter', last=1, field='', token='', version='', f Updates at 9am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - last (int); Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -160,11 +160,11 @@ def financials(symbol, period='quarter', token='', version='', filter=''): Updates at 8am, 9am UTC daily Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -200,12 +200,12 @@ def incomeStatement(symbol, period='quarter', last=1, token='', version='', filt Updates at 8am, 9am UTC daily Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - last (int); Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -232,10 +232,10 @@ def stockSplits(symbol, timeframe='ytd', token='', version='', filter=''): Updated at 9am UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result diff --git a/pyEX/stocks/marketInfo.py b/pyEX/stocks/marketInfo.py index 0266d82..e74b06e 100644 --- a/pyEX/stocks/marketInfo.py +++ b/pyEX/stocks/marketInfo.py @@ -12,11 +12,11 @@ def collections(tag, collectionName, token='', version='', filter=''): https://iexcloud.io/docs/api/#collections Args: - tag (string); Sector, Tag, or List - collectionName (string); Associated name for tag - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + tag (str): Sector, Tag, or List + collectionName (str): Associated name for tag + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -44,9 +44,9 @@ def earningsToday(token='', version='', filter=''): Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -82,9 +82,9 @@ def ipoToday(token='', version='', filter=''): 10am, 10:30am UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -113,9 +113,9 @@ def ipoUpcoming(token='', version='', filter=''): 10am, 10:30am UTC daily Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -143,10 +143,10 @@ def list(option='mostactive', token='', version='', filter=''): Updated intraday Args: - option (string); Option to query - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + option (str): Option to query + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -171,9 +171,9 @@ def marketVolume(token='', version='', filter=''): 7:45am-5:15pm ET Mon-Fri Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -195,9 +195,9 @@ def marketOhlc(token='', version='', filter=''): 9:30am-5pm ET Mon-Fri Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -226,10 +226,10 @@ def marketYesterday(token='', version='', filter=''): Available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -257,9 +257,9 @@ def sectorPerformance(token='', version='', filter=''): 8am-5pm ET Mon-Fri Args: - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -284,10 +284,10 @@ def marketShortInterest(date=None, token='', version='', filter=''): https://iexcloud.io/docs/api/#listed-short-interest-list-in-dev Args: - date (datetime); Effective Datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + date (datetime): Effective Datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -311,11 +311,11 @@ def upcomingEvents(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#upcoming-events Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -338,11 +338,11 @@ def upcomingEarnings(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#upcoming-events Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -365,11 +365,11 @@ def upcomingDividends(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#upcoming-events Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -392,11 +392,11 @@ def upcomingSplits(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#upcoming-events Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result @@ -419,11 +419,11 @@ def upcomingIPOs(symbol='', refid='', token='', version='', filter=''): https://iexcloud.io/docs/api/#upcoming-events Args: - symbol (string); Symbol to look up - refid (string); Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Symbol to look up + refid (str): Optional. Id that matches the refid field returned in the response object. This allows you to pull a specific event for a symbol. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict or DataFrame: result diff --git a/pyEX/stocks/news.py b/pyEX/stocks/news.py index 0970618..87205f7 100644 --- a/pyEX/stocks/news.py +++ b/pyEX/stocks/news.py @@ -10,11 +10,11 @@ def news(symbol, count=10, token='', version='', filter=''): Continuous Args: - symbol (string); Ticker to request + symbol (str): Ticker to request count (int): limit number of results - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -38,11 +38,11 @@ def newsDF(symbol, count=10, token='', version='', filter=''): Continuous Args: - symbol (string); Ticker to request + symbol (str): Ticker to request count (int): limit number of results - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -60,9 +60,9 @@ def marketNews(count=10, token='', version='', filter=''): Args: count (int): limit number of results - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -78,9 +78,9 @@ def marketNewsDF(count=10, token='', version='', filter=''): Args: count (int): limit number of results - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/stocks/prices.py b/pyEX/stocks/prices.py index 2f558d1..90312a8 100644 --- a/pyEX/stocks/prices.py +++ b/pyEX/stocks/prices.py @@ -10,10 +10,10 @@ def book(symbol, token='', version='', filter=''): realtime during Investors Exchange market hours Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -56,10 +56,10 @@ def bookDF(symbol, token='', version='', filter=''): realtime during Investors Exchange market hours Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -81,12 +81,12 @@ def chart(symbol, timeframe='1m', date=None, token='', version='', filter=''): -Prior trading day available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - timeframe (string); Timeframe to request e.g. 1m + symbol (str): Ticker to request + timeframe (str): Timeframe to request e.g. 1m date (datetime): date, if requesting intraday - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -128,12 +128,12 @@ def chartDF(symbol, timeframe='1m', date=None, token='', version='', filter=''): -Prior trading day available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - timeframe (string); Timeframe to request e.g. 1m + symbol (str): Ticker to request + timeframe (str): Timeframe to request e.g. 1m date (datetime): date, if requesting intraday - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -160,10 +160,10 @@ def delayedQuote(symbol, token='', version='', filter=''): 4:30am - 8pm ET M-F when market is open Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -180,10 +180,10 @@ def delayedQuoteDF(symbol, token='', version='', filter=''): 4:30am - 8pm ET M-F when market is open Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -203,11 +203,11 @@ def intraday(symbol, date='', token='', version='', filter=''): Args: - symbol (string); Ticker to request - date (string): Formatted as YYYYMMDD. This can be used for batch calls when range is 1d or date. Currently supporting trailing 30 calendar days of minute bar data. - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + date (str): Formatted as YYYYMMDD. This can be used for batch calls when range is 1d or date. Currently supporting trailing 30 calendar days of minute bar data. + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -228,10 +228,10 @@ def intradayDF(symbol, date='', token='', version='', filter=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -250,10 +250,10 @@ def largestTrades(symbol, token='', version='', filter=''): 9:30-4pm ET M-F during regular market hours Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -269,10 +269,10 @@ def largestTradesDF(symbol, token='', version='', filter=''): 9:30-4pm ET M-F during regular market hours Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -290,10 +290,10 @@ def ohlc(symbol, token='', version='', filter=''): 9:30am-5pm ET Mon-Fri Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -309,10 +309,10 @@ def ohlcDF(symbol, token='', version='', filter=''): 9:30am-5pm ET Mon-Fri Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -334,10 +334,10 @@ def yesterday(symbol, token='', version='', filter=''): Available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -353,10 +353,10 @@ def yesterdayDF(symbol, token='', version='', filter=''): Available after 4am ET Tue-Sat Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -378,10 +378,10 @@ def price(symbol, token='', version='', filter=''): 4:30am-8pm ET Mon-Fri Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -397,10 +397,10 @@ def priceDF(symbol, token='', version='', filter=''): 4:30am-8pm ET Mon-Fri Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -418,10 +418,10 @@ def quote(symbol, token='', version='', filter=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -438,10 +438,10 @@ def quoteDF(symbol, token='', version='', filter=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -474,10 +474,10 @@ def spread(symbol, token='', version='', filter=''): 8am ET M-F Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -503,10 +503,10 @@ def spreadDF(symbol, token='', version='', filter=''): 8am ET M-F Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -526,10 +526,10 @@ def volumeByVenue(symbol, token='', version='', filter=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -547,10 +547,10 @@ def volumeByVenueDF(symbol, token='', version='', filter=''): Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/stocks/profiles.py b/pyEX/stocks/profiles.py index 1b9e542..5185045 100644 --- a/pyEX/stocks/profiles.py +++ b/pyEX/stocks/profiles.py @@ -15,10 +15,10 @@ def company(symbol, token='', version='', filter=''): Updates at 4am and 5am UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -42,10 +42,10 @@ def companyDF(symbol, token='', version='', filter=''): Updates at 4am and 5am UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -63,10 +63,10 @@ def insiderRoster(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -82,10 +82,10 @@ def insiderRosterDF(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -104,10 +104,10 @@ def insiderSummary(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -123,10 +123,10 @@ def insiderSummaryDF(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -145,10 +145,10 @@ def insiderTransactions(symbol, token='', version='', filter=''): Updates at UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -164,10 +164,10 @@ def insiderTransactionsDF(symbol, token='', version='', filter=''): Updates at UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -186,10 +186,10 @@ def logo(symbol, token='', version='', filter=''): 8am UTC daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -206,10 +206,10 @@ def logoPNG(symbol, token='', version='', filter=''): 8am UTC daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: image: result as png @@ -227,10 +227,10 @@ def logoNotebook(symbol, token='', version='', filter=''): 8am UTC daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: image: result @@ -248,10 +248,10 @@ def peers(symbol, token='', version='', filter=''): 8am UTC daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -276,10 +276,10 @@ def peersDF(symbol, token='', version='', filter=''): 8am UTC daily Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -295,10 +295,10 @@ def relevant(symbol, token='', version='', filter=''): https://iexcloud.io/docs/api/#relevant Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -312,10 +312,10 @@ def relevantDF(symbol, token='', version='', filter=''): https://iexcloud.io/docs/api/#relevant Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/stocks/research.py b/pyEX/stocks/research.py index 73f49ff..ca2d9fc 100644 --- a/pyEX/stocks/research.py +++ b/pyEX/stocks/research.py @@ -12,10 +12,10 @@ def advancedStats(symbol, token='', version='', filter=''): 4am, 5am ET Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -31,10 +31,10 @@ def advancedStatsDF(symbol, token='', version='', filter=''): 4am, 5am ET Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -53,10 +53,10 @@ def analystRecommendations(symbol, token='', version='', filter=''): Updates at 9am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -72,10 +72,10 @@ def analystRecommendationsDF(symbol, token='', version='', filter=''): Updates at 9am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -93,12 +93,12 @@ def estimates(symbol, period='quarter', last=1, token='', version='', filter='') Updates at 9am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - last (int); Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -126,12 +126,12 @@ def estimatesDF(symbol, period='quarter', last=1, token='', version='', filter=' Updates at 9am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - period (string); Period, either 'annual' or 'quarter' - last (int); Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + period (str): Period, either 'annual' or 'quarter' + last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -150,10 +150,10 @@ def fundOwnership(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -170,10 +170,10 @@ def fundOwnershipDF(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: @@ -193,10 +193,10 @@ def institutionalOwnership(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -212,10 +212,10 @@ def institutionalOwnershipDF(symbol, token='', version='', filter=''): Updates at 5am, 6am ET every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -234,8 +234,8 @@ def keyStats(symbol, stat='', token='', version='', filter=''): 8am, 9am ET Args: - symbol (string); Ticker to request - stat (Optiona[str]); specific stat to request, in: + symbol (str): Ticker to request + stat (Optiona[str]): specific stat to request, in: companyName marketcap week52high @@ -266,9 +266,9 @@ def keyStats(symbol, stat='', token='', version='', filter=''): month1ChangePercent day30ChangePercent day5ChangePercent - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -299,8 +299,8 @@ def keyStatsDF(symbol, stat='', token='', version='', filter=''): 8am, 9am ET Args: - symbol (string); Ticker to request - stat (Optiona[str]); specific stat to request, in: + symbol (str): Ticker to request + stat (Optiona[str]): specific stat to request, in: companyName marketcap week52high @@ -331,9 +331,9 @@ def keyStatsDF(symbol, stat='', token='', version='', filter=''): month1ChangePercent day30ChangePercent day5ChangePercent - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -350,10 +350,10 @@ def priceTarget(symbol, token='', version='', filter=''): Updates at 10am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -369,10 +369,10 @@ def priceTargetDF(symbol, token='', version='', filter=''): Updates at 10am, 11am, 12pm UTC every day Args: - symbol (string); Ticker to request - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -393,8 +393,8 @@ def technicals(symbol, indicator, range='1m', input1=None, input2=None, input3=N Data Timing: On Demand Args: - symbol (string); Ticker to request - indicator (string); Technical indicator to request, in: + symbol (str): Ticker to request + indicator (str): Technical indicator to request, in: Indicator Description Inputs Defaults Outputs ------------------------------------------------------------------------------------------------------------- abs Vector Absolute Value abs @@ -502,14 +502,14 @@ def technicals(symbol, indicator, range='1m', input1=None, input2=None, input3=N wma Weighted Moving Average period 5 wma zlema Zero-Lag Exponential Moving Average period 5 zlema - range (string); Timeframe to request e.g. 1m - input1 (string); input1 to technicals (see docs) - input2 (string); input2 to technicals (see docs) - input3 (string); input3 to technicals (see docs) - input4 (string); input4 to technicals (see docs) - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + range (str): Timeframe to request e.g. 1m + input1 (str): input1 to technicals (see docs) + input2 (str): input2 to technicals (see docs) + input3 (str): input3 to technicals (see docs) + input4 (str): input4 to technicals (see docs) + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -579,8 +579,8 @@ def technicalsDF(symbol, indicator, range='1m', input1=None, input2=None, input3 Data Timing: On Demand Args: - symbol (string); Ticker to request - indicator (string); Technical indicator to request, in: + symbol (str): Ticker to request + indicator (str): Technical indicator to request, in: Indicator Description Inputs Defaults Outputs ------------------------------------------------------------------------------------------------------------- abs Vector Absolute Value abs @@ -688,14 +688,14 @@ def technicalsDF(symbol, indicator, range='1m', input1=None, input2=None, input3 wma Weighted Moving Average period 5 wma zlema Zero-Lag Exponential Moving Average period 5 zlema - range (string); Timeframe to request e.g. 1m - input1 (string); input1 to technicals (see docs) - input2 (string); input2 to technicals (see docs) - input3 (string); input3 to technicals (see docs) - input4 (string); input4 to technicals (see docs) - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + range (str): Timeframe to request e.g. 1m + input1 (str): input1 to technicals (see docs) + input2 (str): input2 to technicals (see docs) + input3 (str): input3 to technicals (see docs) + input4 (str): input4 to technicals (see docs) + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result diff --git a/pyEX/stocks/stocks.py b/pyEX/stocks/stocks.py index df13fb6..557b602 100644 --- a/pyEX/stocks/stocks.py +++ b/pyEX/stocks/stocks.py @@ -10,10 +10,10 @@ def threshold(date=None, token='', version='', filter=''): https://iexcloud.io/docs/api/#listed-regulation-sho-threshold-securities-list-in-dev Args: - date (datetime); Effective Datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + date (datetime): Effective Datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -31,10 +31,10 @@ def thresholdDF(date=None, token='', version='', filter=''): https://iexcloud.io/docs/api/#listed-regulation-sho-threshold-securities-list-in-dev Args: - date (datetime); Effective Datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + date (datetime): Effective Datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result @@ -53,11 +53,11 @@ def shortInterest(symbol, date=None, token='', version='', filter=''): https://iexcloud.io/docs/api/#listed-short-interest-list-in-dev Args: - symbol (string); Ticker to request - date (datetime); Effective Datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + date (datetime): Effective Datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result @@ -77,11 +77,11 @@ def shortInterestDF(symbol, date=None, token='', version='', filter=''): https://iexcloud.io/docs/api/#listed-short-interest-list-in-dev Args: - symbol (string); Ticker to request - date (datetime); Effective Datetime - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + symbol (str): Ticker to request + date (datetime): Effective Datetime + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: DataFrame: result diff --git a/pyEX/stocks/timeseries.py b/pyEX/stocks/timeseries.py index 04d809d..44f7f84 100644 --- a/pyEX/stocks/timeseries.py +++ b/pyEX/stocks/timeseries.py @@ -61,9 +61,9 @@ def timeSeries(id='', on (str or datetime): Returns data on the given date. Format YYYY-MM-DD last (int): Returns the latest n number of records in the series first (int): Returns the first n number of records in the series - token (string); Access token - version (string); API version - filter (string); filters: https://iexcloud.io/docs/api/#filter-results + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: dict: result From e6b7758d405d0c1ee31d97bdc4858be7e5db37c4 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 23 Oct 2020 21:20:14 -0400 Subject: [PATCH 2/6] update wraps --- pyEX/stocks/news.py | 34 +---- pyEX/stocks/profiles.py | 101 ++----------- pyEX/stocks/research.py | 289 +++----------------------------------- pyEX/stocks/stocks.py | 37 +---- pyEX/stocks/timeseries.py | 3 +- 5 files changed, 41 insertions(+), 423 deletions(-) diff --git a/pyEX/stocks/news.py b/pyEX/stocks/news.py index 87205f7..4045a0a 100644 --- a/pyEX/stocks/news.py +++ b/pyEX/stocks/news.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _getJson, _raiseIfNotStr, _reindex, _toDatetime @@ -17,6 +18,7 @@ def news(symbol, count=10, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: + dict or DataFrame: result dict: result ''' _raiseIfNotStr(symbol) @@ -31,22 +33,8 @@ def _newsToDF(n): return df +@wraps(news) def newsDF(symbol, count=10, token='', version='', filter=''): - '''News about company - - https://iexcloud.io/docs/api/#news - Continuous - - Args: - symbol (str): Ticker to request - count (int): limit number of results - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' n = news(symbol, count, token, version, filter) df = _newsToDF(n) return df @@ -65,26 +53,14 @@ def marketNews(count=10, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: + dict or DataFrame: result dict: result ''' return _getJson('stock/market/news/last/' + str(count), token, version, filter) +@wraps(marketNews) def marketNewsDF(count=10, token='', version='', filter=''): - '''News about market - - https://iexcloud.io/docs/api/#news - Continuous - - Args: - count (int): limit number of results - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(marketNews(count, token, version, filter)) _toDatetime(df) _reindex(df, 'datetime') diff --git a/pyEX/stocks/profiles.py b/pyEX/stocks/profiles.py index 5185045..0398bc5 100644 --- a/pyEX/stocks/profiles.py +++ b/pyEX/stocks/profiles.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import requests import pandas as pd +from functools import wraps from IPython.display import Image as ImageI from io import BytesIO from PIL import Image as ImageP @@ -21,7 +22,7 @@ def company(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/company', token, version, filter) @@ -35,21 +36,8 @@ def _companyToDF(c, token='', version='', filter=''): return df +@wraps(company) def companyDF(symbol, token='', version='', filter=''): - '''Company reference data - - https://iexcloud.io/docs/api/#company - Updates at 4am and 5am UTC every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' c = company(symbol, token, version, filter) df = _companyToDF(c) return df @@ -69,27 +57,14 @@ def insiderRoster(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/insider-roster', token, version, filter) +@wraps(insiderRoster) def insiderRosterDF(symbol, token='', version='', filter=''): - '''Returns the top 10 insiders, with the most recent information. - - https://iexcloud.io/docs/api/#insider-roster - Updates at 5am, 6am ET every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = insiderRoster(symbol, token, version, filter) df = pd.DataFrame(val) _toDatetime(df, cols=[], tcols=['reportDate']) @@ -110,27 +85,14 @@ def insiderSummary(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/insider-summary', token, version, filter) +@wraps(insiderSummary) def insiderSummaryDF(symbol, token='', version='', filter=''): - '''Returns aggregated insiders summary data for the last 6 months. - - https://iexcloud.io/docs/api/#insider-summary - Updates at 5am, 6am ET every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = insiderSummary(symbol, token, version, filter) df = pd.DataFrame(val) _toDatetime(df) @@ -151,27 +113,14 @@ def insiderTransactions(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/insider-transactions', token, version, filter) +@wraps(insiderTransactions) def insiderTransactionsDF(symbol, token='', version='', filter=''): - '''Returns insider transactions. - - https://iexcloud.io/docs/api/#insider-transactions - Updates at UTC every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = insiderTransactions(symbol, token, version, filter) df = pd.DataFrame(val) _toDatetime(df) @@ -254,7 +203,7 @@ def peers(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/peers', token, version, filter) @@ -269,21 +218,8 @@ def _peersToDF(p): return df +@wraps(peers) def peersDF(symbol, token='', version='', filter=''): - '''Peers of ticker - - https://iexcloud.io/docs/api/#peers - 8am UTC daily - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' p = peers(symbol, token, version, filter) df = _peersToDF(p) return df @@ -301,25 +237,14 @@ def relevant(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/relevant', token, version, filter) +@wraps(relevant) def relevantDF(symbol, token='', version='', filter=''): - '''Same as peers - - https://iexcloud.io/docs/api/#relevant - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(relevant(symbol, token, version, filter)) _toDatetime(df) return df diff --git a/pyEX/stocks/research.py b/pyEX/stocks/research.py index ca2d9fc..90445d8 100644 --- a/pyEX/stocks/research.py +++ b/pyEX/stocks/research.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from .prices import _chartToDF from ..common import _expire, _getJson, _raiseIfNotStr, _reindex, _toDatetime, _EST, _UTC, _KEY_STATS, PyEXception, _checkPeriodLast, _INDICATORS, _TIMEFRAME_CHART, _INDICATOR_RETURNS @@ -18,27 +19,14 @@ def advancedStats(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/advanced-stats', token, version, filter) +@wraps(advancedStats) def advancedStatsDF(symbol, token='', version='', filter=''): - '''Returns everything in key stats plus additional advanced stats such as EBITDA, ratios, key financial data, and more. - - https://iexcloud.io/docs/api/#advanced-stats - 4am, 5am ET - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = advancedStats(symbol, token, version, filter) df = pd.io.json.json_normalize(val) _toDatetime(df) @@ -59,27 +47,14 @@ def analystRecommendations(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/recommendation-trends', token, version, filter) +@wraps(analystRecommendations) def analystRecommendationsDF(symbol, token='', version='', filter=''): - '''Pulls data from the last four months. - - https://iexcloud.io/docs/api/#analyst-recommendations - Updates at 9am, 11am, 12pm UTC every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = analystRecommendations(symbol, token, version, filter) df = pd.io.json.json_normalize(val) _toDatetime(df) @@ -101,7 +76,7 @@ def estimates(symbol, period='quarter', last=1, token='', version='', filter='') filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) _checkPeriodLast(period, last) @@ -119,23 +94,8 @@ def _estimatesToDF(f): return df +@wraps(estimates) def estimatesDF(symbol, period='quarter', last=1, token='', version='', filter=''): - '''Provides the latest consensus estimate for the next fiscal period - - https://iexcloud.io/docs/api/#estimates - Updates at 9am, 11am, 12pm UTC every day - - Args: - symbol (str): Ticker to request - period (str): Period, either 'annual' or 'quarter' - last (int): Number of records to fetch, up to 12 for 'quarter' and 4 for 'annual' - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - dict: result - ''' f = estimates(symbol, period, last, token, version, filter) df = _estimatesToDF(f) return df @@ -156,29 +116,14 @@ def fundOwnership(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/fund-ownership', token, version, filter) +@wraps(fundOwnership) def fundOwnershipDF(symbol, token='', version='', filter=''): - '''Returns the top 10 fund holders, meaning any firm not defined as buy-side or sell-side such as mutual funds, - pension funds, endowments, investment firms, and other large entities that manage funds on behalf of others. - - https://iexcloud.io/docs/api/#fund-ownership - Updates at 5am, 6am ET every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - - DataFrame: result - ''' val = fundOwnership(symbol, token, version, filter) df = pd.DataFrame(val) _toDatetime(df) @@ -199,27 +144,14 @@ def institutionalOwnership(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/institutional-ownership', token, version, filter) +@wraps(institutionalOwnership) def institutionalOwnershipDF(symbol, token='', version='', filter=''): - '''Returns the top 10 institutional holders, defined as buy-side or sell-side firms. - - https://iexcloud.io/docs/api/#institutional-ownership - Updates at 5am, 6am ET every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = institutionalOwnership(symbol, token, version, filter) df = pd.DataFrame(val) _toDatetime(df, cols=[], tcols=['reportDate']) @@ -271,7 +203,7 @@ def keyStats(symbol, stat='', token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if stat: @@ -292,52 +224,8 @@ def _statsToDF(s): return df +@wraps(keyStats) def keyStatsDF(symbol, stat='', token='', version='', filter=''): - '''Key Stats about company - - https://iexcloud.io/docs/api/#key-stats - 8am, 9am ET - - Args: - symbol (str): Ticker to request - stat (Optiona[str]): specific stat to request, in: - companyName - marketcap - week52high - week52low - week52change - sharesOutstanding - float - avg10Volume - avg30Volume - day200MovingAvg - day50MovingAvg - employees - ttmEPS - ttmDividendRate - dividendYield - nextDividendDate - exDividendDate - nextEarningsDate - peRatio - beta - maxChangePercent - year5ChangePercent - year2ChangePercent - year1ChangePercent - ytdChangePercent - month6ChangePercent - month3ChangePercent - month1ChangePercent - day30ChangePercent - day5ChangePercent - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' s = keyStats(symbol, stat, token, version, filter) df = _statsToDF(s) return df @@ -356,27 +244,14 @@ def priceTarget(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/price-target', token, version, filter) +@wraps(priceTarget) def priceTargetDF(symbol, token='', version='', filter=''): - '''Provides the latest avg, high, and low analyst price target for a symbol. - - https://iexcloud.io/docs/api/#price-target - Updates at 10am, 11am, 12pm UTC every day - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.io.json.json_normalize(priceTarget(symbol, token, version, filter)) _toDatetime(df) return df @@ -512,7 +387,7 @@ def technicals(symbol, indicator, range='1m', input1=None, input2=None, input3=N filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if indicator not in _INDICATORS: @@ -568,138 +443,8 @@ def technicals(symbol, indicator, range='1m', input1=None, input2=None, input3=N return _getJson(base_url, token, version, filter) -@_expire(second=0) +@wraps(technicals) def technicalsDF(symbol, indicator, range='1m', input1=None, input2=None, input3=None, input4=None, token='', version='', filter=''): - '''Technical indicators are available for any historical or intraday range. - This endpoint calls the historical or intraday price endpoints for the given range, and the associated indicator for the price range. - - See https://github.com/timkpaine/pyEX-studies for local calculations using TA-lib - - https://iexcloud.io/docs/api/#technical-indicators - Data Timing: On Demand - - Args: - symbol (str): Ticker to request - indicator (str): Technical indicator to request, in: - Indicator Description Inputs Defaults Outputs - ------------------------------------------------------------------------------------------------------------- - abs Vector Absolute Value abs - acos Vector Arccosine acos - ad Accumulation/Distribution Line ad - add Vector Addition add - adosc Accumulation/Distribution Oscillator short period,long period 2,5 adosc - adx Average Directional Movement Index period 5 dx - adxr Average Directional Movement Rating period 5 dx - ao Awesome Oscillator ao - apo Absolute Price Oscillator short period,long period 2,5 apo - aroon Aroon period 5 aroon_down,aroon_up - aroonosc Aroon Oscillator period 5 aroonosc - asin Vector Arcsine asin - atan Vector Arctangent atan - atr Average True Range period 5 atr - avgprice Average Price avgprice - bbands Bollinger Bands period,stddev 20,2 bbands_lower,bbands_middle,bbands_upper - bop Balance of Power - cci Commodity Channel Index period 5 cci - ceil Vector Ceiling ceil - cmo Chande Momentum Oscillator period 5 cmo - cos Vector Cosine cos - cosh Vector Hyperbolic Cosine cosh - crossany Crossany crossany - crossover Crossover crossover - cvi Chaikins Volatility period 5 cvi - decay Linear Decay period 5 decay - dema Double Exponential Moving Average period 5 dema - di Directional Indicator period 5 plus_di,minus_di - div Vector Division div - dm Directional Movement period 5 plus_dm,minus_dm - dpo Detrended Price Oscillator period 5 dpo - dx Directional Movement Index period 5 dx - edecay Exponential Decay period 5 edecay - ema Exponential Moving Average period 5 ema - emv Ease of Movement emv - exp Vector Exponential exp - fisher Fisher Transform period 5 fisher,fisher_signal - floor Vector Floor floor - fosc Forecast Oscillator period 5 fosc - hma Hull Moving Average period 5 hma - kama Kaufman Adaptive Moving Average period 5 kama - kvo Klinger Volume Oscillator short period,long period 2,5 kvo - lag Lag period 5 lag - linreg Linear Regression period 5 linreg - linregintercept Linear Regression Intercept period 5 linregintercept - linregslope Linear Regression Slope period 5 linregslope - ln Vector Natural Log ln - log10 Vector Base-10 Log log10 - macd Moving Average Conv/Div short per,long per,signal per 12,26,9 macd,macd_signal,macd_histogram - marketfi Market Facilitation Index marketfi - mass Mass Index period 5 mass - max Maximum In Period period 5 max - md Mean Deviation Over Period period 5 md - medprice Median Price medprice - mfi Money Flow Index period 5 mfi - min Minimum In Period period 5 min - mom Momentum period 5 mom - msw Mesa Sine Wave period 5 msw_sine,msw_lead - mul Vector Multiplication mul - natr Normalized Average True Range period 5 natr - nvi Negative Volume Index nvi - obv On Balance Volume obv - ppo Percentage Price Oscillator short period,long period 2,5 ppo - psar Parabolic SAR accelfactor step,accel factor max .2,2 psar - pvi Positive Volume Index pvi - qstick Qstick period 5 qstick - roc Rate of Change period 5 roc - rocr Rate of Change Ratio period 5 rocr - round Vector Round round - rsi Relative Strength Index period 5 rsi - sin Vector Sine sin - sinh Vector Hyperbolic Sine sinh - sma Simple Moving Average period 5 sma - sqrt Vector Square Root sqrt - stddev Standard Deviation Over Period period 5 stddev - stderr Standard Error Over Period period 5 stderr - stoch Stochastic Oscillator k per,k slowing per,d per 5,3,3 stoch_k,stoch_d - stochrsi Stochastic RSI period 5 stochrsi - sub Vector Subtraction sub - sum Sum Over Period period 5 sum - tan Vector Tangent tan - tanh Vector Hyperbolic Tangent tanh - tema Triple Exponential Moving Average period 5 tema - todeg Vector Degree Conversion degrees - torad Vector Radian Conversion radians - tr True Range tr - trima Triangular Moving Average period 5 trima - trix Trix period 5 trix - trunc Vector Truncate trunc - tsf Time Series Forecast period 5 tsf - typprice Typical Price typprice - ultosc Ultimate Oscillator short per,med per,long per 2,3,5 ultosc - var Variance Over Period period 5 var - vhf Vertical Horizontal Filter period 5 vhf - vidya Variable Index Dynamic Average short period,long period,alpha 2,5,.2 vidya - volatility Annualized Historical Volatility period 5 volatility - vosc Volume Oscillator short period,long period 2,5 vosc - vwma Volume Weighted Moving Average period 5 vwma - wad Williams Accumulation/Distribution wad - wcprice Weighted Close Price wcprice - wilders Wilders Smoothing period 5 wilders - willr Williams %R period - wma Weighted Moving Average period 5 wma - zlema Zero-Lag Exponential Moving Average period 5 zlema - - range (str): Timeframe to request e.g. 1m - input1 (str): input1 to technicals (see docs) - input2 (str): input2 to technicals (see docs) - input3 (str): input3 to technicals (see docs) - input4 (str): input4 to technicals (see docs) - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - dict: result - ''' json = technicals(symbol, indicator, range, input1, input2, input3, input4, token, version, filter) chart = json['chart'] seriess = json['indicator'] diff --git a/pyEX/stocks/stocks.py b/pyEX/stocks/stocks.py index 557b602..9c637cc 100644 --- a/pyEX/stocks/stocks.py +++ b/pyEX/stocks/stocks.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _getJson, _raiseIfNotStr, _strOrDate, _toDatetime, _EST @@ -16,7 +17,7 @@ def threshold(date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: date = _strOrDate(date) @@ -24,21 +25,8 @@ def threshold(date=None, token='', version='', filter=''): return _getJson('stock/market/threshold-securities', token, version, filter) +@wraps(threshold) def thresholdDF(date=None, token='', version='', filter=''): - '''The following are IEX-listed securities that have an aggregate fail to deliver position for five consecutive settlement days at a registered clearing agency, totaling 10,000 shares or more and equal to at least 0.5% of the issuer’s total shares outstanding (i.e., “threshold securities”). - The report data will be published to the IEX website daily at 8:30 p.m. ET with data for that trading day. - - https://iexcloud.io/docs/api/#listed-regulation-sho-threshold-securities-list-in-dev - - Args: - date (datetime): Effective Datetime - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(threshold(date, token, version, filter)) _toDatetime(df) return df @@ -60,7 +48,7 @@ def shortInterest(symbol, date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if date: @@ -69,23 +57,8 @@ def shortInterest(symbol, date=None, token='', version='', filter=''): return _getJson('stock/' + symbol + '/short-interest', token, version, filter) +@wraps(shortInterest) def shortInterestDF(symbol, date=None, token='', version='', filter=''): - '''The consolidated market short interest positions in all IEX-listed securities are included in the IEX Short Interest Report. - - The report data will be published daily at 4:00pm ET. - - https://iexcloud.io/docs/api/#listed-short-interest-list-in-dev - - Args: - symbol (str): Ticker to request - date (datetime): Effective Datetime - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(shortInterest(symbol, date, token, version, filter)) _toDatetime(df) return df diff --git a/pyEX/stocks/timeseries.py b/pyEX/stocks/timeseries.py index 44f7f84..01f3718 100644 --- a/pyEX/stocks/timeseries.py +++ b/pyEX/stocks/timeseries.py @@ -66,8 +66,7 @@ def timeSeries(id='', filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result - + dict or DataFrame: result Date Ranges: today Returns data for today From 9b780f74e0a958476638191e2ed6e835c771f422 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 23 Oct 2020 21:22:35 -0400 Subject: [PATCH 3/6] update wraps --- pyEX/stocks/prices.py | 211 +++++------------------------------------- 1 file changed, 23 insertions(+), 188 deletions(-) diff --git a/pyEX/stocks/prices.py b/pyEX/stocks/prices.py index 90312a8..45effae 100644 --- a/pyEX/stocks/prices.py +++ b/pyEX/stocks/prices.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _TIMEFRAME_CHART, _getJson, _raiseIfNotStr, PyEXception, _strOrDate, _reindex, _toDatetime, _EST @@ -16,7 +17,7 @@ def book(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/book', token, version, filter) @@ -49,21 +50,8 @@ def _bookToDF(b): return df +@wraps(book) def bookDF(symbol, token='', version='', filter=''): - '''Book data - - https://iextrading.com/developer/docs/#book - realtime during Investors Exchange market hours - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' x = book(symbol, token, version, filter) df = _bookToDF(x) return df @@ -89,7 +77,7 @@ def chart(symbol, timeframe='1m', date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if timeframe is not None and timeframe != '1d': @@ -116,28 +104,8 @@ def _chartToDF(c): return df -@_expire(second=0) +@wraps(chart) def chartDF(symbol, timeframe='1m', date=None, token='', version='', filter=''): - '''Historical price/volume data, daily and intraday - - https://iexcloud.io/docs/api/#historical-prices - Data Schedule - 1d: -9:30-4pm ET Mon-Fri on regular market trading days - -9:30-1pm ET on early close trading days - All others: - -Prior trading day available after 4am ET Tue-Sat - - Args: - symbol (str): Ticker to request - timeframe (str): Timeframe to request e.g. 1m - date (datetime): date, if requesting intraday - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' c = chart(symbol, timeframe, date, token, version, filter) df = pd.DataFrame(c) _toDatetime(df) @@ -166,28 +134,14 @@ def delayedQuote(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/delayed-quote', token, version, filter) +@wraps(delayedQuote) def delayedQuoteDF(symbol, token='', version='', filter=''): - '''This returns the 15 minute delayed market quote. - - https://iexcloud.io/docs/api/#delayed-quote - 15min delayed - 4:30am - 8pm ET M-F when market is open - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.io.json.json_normalize(delayedQuote(symbol, token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') @@ -210,7 +164,7 @@ def intraday(symbol, date='', token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if date: @@ -219,23 +173,8 @@ def intraday(symbol, date='', token='', version='', filter=''): return _getJson('stock/{}/intraday-prices'.format(symbol), token, version, filter) +@wraps(intraday) def intradayDF(symbol, date='', token='', version='', filter=''): - '''This endpoint will return aggregated intraday prices in one minute buckets - - https://iexcloud.io/docs/api/#intraday-prices - 9:30-4pm ET Mon-Fri on regular market trading days - 9:30-1pm ET on early close trading days - - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' val = intraday(symbol, date, token, version, filter) df = pd.DataFrame(val) _toDatetime(df) @@ -256,27 +195,14 @@ def largestTrades(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/largest-trades', token, version, filter) +@wraps(largestTrades) def largestTradesDF(symbol, token='', version='', filter=''): - '''This returns 15 minute delayed, last sale eligible trades. - - https://iexcloud.io/docs/api/#largest-trades - 9:30-4pm ET M-F during regular market hours - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(largestTrades(symbol, token, version, filter)) _toDatetime(df) _reindex(df, 'time') @@ -296,27 +222,14 @@ def ohlc(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/ohlc', token, version, filter) +@wraps(ohlc) def ohlcDF(symbol, token='', version='', filter=''): - '''Returns the official open and close for a give symbol. - - https://iexcloud.io/docs/api/#news - 9:30am-5pm ET Mon-Fri - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' o = ohlc(symbol, token, version, filter) if o: df = pd.io.json.json_normalize(o) @@ -340,27 +253,14 @@ def yesterday(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/previous', token, version, filter) +@wraps(yesterday) def yesterdayDF(symbol, token='', version='', filter=''): - '''This returns previous day adjusted price data for one or more stocks - - https://iexcloud.io/docs/api/#previous-day-prices - Available after 4am ET Tue-Sat - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' y = yesterday(symbol, token, version, filter) if y: df = pd.io.json.json_normalize(y) @@ -384,27 +284,14 @@ def price(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/price', token, version, filter) +@wraps(price) def priceDF(symbol, token='', version='', filter=''): - '''Price of ticker - - https://iexcloud.io/docs/api/#price - 4:30am-8pm ET Mon-Fri - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.io.json.json_normalize({'price': price(symbol, token, version, filter)}) _toDatetime(df) return df @@ -424,28 +311,14 @@ def quote(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/quote', token, version, filter) +@wraps(quote) def quoteDF(symbol, token='', version='', filter=''): - '''Get quote for ticker - - https://iexcloud.io/docs/api/#quote - 4:30am-8pm ET Mon-Fri - - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' q = quote(symbol, token, version, filter) if q: df = pd.io.json.json_normalize(q) @@ -480,37 +353,14 @@ def spread(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/effective-spread', token, version, filter) +@wraps(spread) def spreadDF(symbol, token='', version='', filter=''): - '''This returns an array of effective spread, eligible volume, and price improvement of a stock, by market. - Unlike volume-by-venue, this will only return a venue if effective spread is not ‘N/A’. Values are sorted in descending order by effectiveSpread. - Lower effectiveSpread and higher priceImprovement values are generally considered optimal. - - Effective spread is designed to measure marketable orders executed in relation to the market center’s - quoted spread and takes into account hidden and midpoint liquidity available at each market center. - Effective Spread is calculated by using eligible trade prices recorded to the consolidated tape and - comparing those trade prices to the National Best Bid and Offer (“NBBO”) at the time of the execution. - - View the data disclaimer at the bottom of the stocks app for more information about how these values are calculated. - - - https://iexcloud.io/docs/api/#earnings-today - 8am ET M-F - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(spread(symbol, token, version, filter)) _toDatetime(df) _reindex(df, 'venue') @@ -532,29 +382,14 @@ def volumeByVenue(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/volume-by-venue', token, version, filter) +@wraps(volumeByVenue) def volumeByVenueDF(symbol, token='', version='', filter=''): - '''This returns 15 minute delayed and 30 day average consolidated volume percentage of a stock, by market. - This call will always return 13 values, and will be sorted in ascending order by current day trading volume percentage. - - https://iexcloud.io/docs/api/#volume-by-venue - Updated during regular market hours 9:30am-4pm ET - - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(volumeByVenue(symbol, token, version, filter)) _toDatetime(df) _reindex(df, 'venue') From bde35a561a97e3883347baf86e9516473beae710 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 23 Oct 2020 23:22:12 -0400 Subject: [PATCH 4/6] add async functionality, implement newsSSE, sentimentSSE, and stock*SSE endpoints, add stocktwits, update a few random other things --- README.md | 124 +++++++++--- pyEX/__init__.py | 46 ++++- pyEX/account/__init__.py | 30 +-- pyEX/alternative/alternative.py | 52 +---- pyEX/client.py | 73 +++++-- pyEX/common.py | 152 ++++++++++---- pyEX/cryptocurrency/cryptocurrency.py | 52 +---- pyEX/marketdata/cryptocurrency.py | 47 ++++- pyEX/marketdata/fx.py | 19 +- pyEX/marketdata/http.py | 281 +++++++++++--------------- pyEX/marketdata/news.py | 31 +++ pyEX/marketdata/sentiment.py | 31 +++ pyEX/marketdata/sse.py | 274 ++++++++++++++++++++++++- pyEX/marketdata/stock.py | 98 +++++++++ pyEX/marketdata/ws.py | 142 +++++++++++++ pyEX/options/options.py | 22 +- pyEX/points/points.py | 21 +- pyEX/refdata/calendar.py | 40 +--- pyEX/refdata/exchanges.py | 33 +-- pyEX/refdata/figi.py | 16 +- pyEX/refdata/refdata.py | 57 +----- pyEX/refdata/sectors.py | 31 +-- pyEX/refdata/symbols.py | 209 ++----------------- pyEX/stats/stats.py | 20 +- setup.py | 10 +- 25 files changed, 1148 insertions(+), 763 deletions(-) create mode 100644 pyEX/marketdata/news.py create mode 100644 pyEX/marketdata/sentiment.py create mode 100644 pyEX/marketdata/stock.py create mode 100644 pyEX/marketdata/ws.py diff --git a/README.md b/README.md index 3d6b290..43d75c1 100644 --- a/README.md +++ b/README.md @@ -142,6 +142,19 @@ c.deleteRule("") We also provide helper classes in python for constructing rules such that they abide by the rules schema (dictated in the `schema()` helper function) ## Data +`pyEX` provides wrappers around both static and SSE streaming data. For most static data endpoints, we provide both JSON and DataFrame return functions. For market data endpoints, we provide async wrappers as well using `aiohttp` (to install the dependencies, `pip install pyEX[async]`). + +DataFrame functions will have the suffix `DF`, and async functions will have the suffix `Async`. + +SSE streaming data can either be used with callbacks: + +`newsSSE('AAPL', on_data=my_function_todo_on_data)` + +or via async generators (after installing `pyEX[async]`): + +`async for data in newsSSE('AAPL'):` + + ### Full API Please see the [readthedocs](https://pyEX.readthedocs.io) for a full API spec @@ -348,38 +361,45 @@ Currently, the following methods are implemented: - volumeByVenue - volumeByVenueDF -### SSE Streaming -- topsSSE -- lastSSE -- deepSSE -- tradesSSE - ### TOPS - tops +- topsAsync - topsDF - last +- lastAsync - lastDF - deep +- deepAsync - deepDF - auction +- auctionAsync - auctionDF - bookDeep +- bookDeepAsync - bookDeepDF - officialPrice +- officialPriceAsync - officialPriceDF - opHaltStatus +- opHaltStatusAsync - opHaltStatusDF - securityEvent +- securityEventAsync - securityEventDF - ssrStatus +- ssrStatusAsync - ssrStatusDF - systemEvent +- systemEventAsync - systemEventDF - trades +- tradesAsync - tradesDF - tradeBreak +- tradeBreakAsync - tradeBreakDF - tradingStatus +- tradingStatusAsync - tradingStatusDF ### Alternative @@ -402,9 +422,6 @@ Currently, the following methods are implemented: - historicalFX - historicalFXDF -### FXSSE -- fxSSE - ### Crypto - cryptoBook - cryptoBookDF @@ -413,11 +430,6 @@ Currently, the following methods are implemented: - cryptoPrice - cryptoPriceDF -### CryptoSSE -- cryptoBookSSE -- cryptoEventsSSE -- cryptoQuotesSSE - ### Rates - thirtyYear - twentyYear @@ -461,8 +473,70 @@ Currently, the following methods are implemented: - institutionalMoney - retailMoney -### Premium -#### Wall Street Horizon +## Streaming Data + +### SSE Streaming +- topsSSE +- topsSSEAsync +- lastSSE +- lastSSEASync +- deepSSE +- deepSSEAsync +- tradesSSE +- tradesSSEAsync +- auctionSSE +- auctionSSEAsync +- bookSSE +- bookSSEAsync +- opHaltStatusSSE +- opHaltStatusSSEAsync +- officialPriceSSE +- officialPriceSSEAsync +- securityEventSSE +- securityEventSSEAsync +- ssrStatusSSE +- ssrStatusSSEAsync +- systemEventSSE +- systemEventSSEAsync +- tradeBreaksSSE +- tradeBreaksSSEAsync +- tradingStatusSSE +- tradingStatusSSEAsync + +### Stocks +- stocksUSNoUTPSSE +- stocksUSNoUTPSSEsync +- stocksUSSSE +- stocksUSSSEsync +- stocksUS1SecondSSE +- stocksUS1SecondSSEsync +- stocksUS5SecondSSE +- stocksUS5SecondSSEsync +- stocksUS1MinuteSSE +- stocksUS1MinuteSSEAsync + +### News +- newsSSE +- newsSSEAsync + +### Sentiment +- sentimentSSE +- sentimentSSEAsync + +### FX +- fxSSE +- fxSSEAsync + +### Crypto +- cryptoBookSSE +- cryptoBookSSEAsync +- cryptoEventsSSE +- cryptoEventsSSEAsync +- cryptoQuotesSSE +- cryptoQuotesSSEAsync + +## Premium Data +### Wall Street Horizon - analystDays - analystDaysDF - boardOfDirectorsMeeting @@ -516,13 +590,13 @@ Currently, the following methods are implemented: - workshops - workshopsDF -#### Fraud Factors +### Fraud Factors - nonTimelyFilings - nonTimelyFilingsDF - similarityIndex - similarityIndexDF -#### Extract Alpha +### Extract Alpha - cam1 - cam1DF - esgCFPBComplaints @@ -550,11 +624,11 @@ Currently, the following methods are implemented: - tacticalModel1 - tacticalModel1DF -#### Precision Alpha +### Precision Alpha - precisionAlphaPriceDynamics - precisionAlphaPriceDynamicsDF -#### BRAIN Company +### BRAIN Company - brain30DaySentiment - brain30DaySentimentDF - brain7DaySentiment @@ -578,19 +652,23 @@ Currently, the following methods are implemented: - brainLanguageMetricsOnCompanyFilingsDifference - brainLanguageMetricsOnCompanyFilingsDifferenceDF -#### Kavout +### Kavout - kScore - kScoreDF -#### Audit Analytics +### Audit Analytics - accountingQualityAndRiskMatrix - accountingQualityAndRiskMatrixDF - directorAndOfficerChanges - directorAndOfficerChangesDF -#### ValuEngine +### ValuEngine - valuEngineStockResearchReport +### StockTwits Sentiment +- socialSentiment +- socialSentimentDF + ## Attribution diff --git a/pyEX/__init__.py b/pyEX/__init__.py index cd28778..d16074b 100644 --- a/pyEX/__init__.py +++ b/pyEX/__init__.py @@ -10,16 +10,44 @@ from .economic import EconomicPoints # noqa: F401 from .fx import latestFX, latestFXDF, convertFX, convertFXDF, historicalFX, historicalFXDF # noqa: F401 from .markets import markets, marketsDF # noqa: F401 -from .marketdata.cryptocurrency import cryptoBookSSE, cryptoEventsSSE, cryptoQuotesSSE # noqa: F401 +from .marketdata.cryptocurrency import (cryptoBookSSE, cryptoBookSSEAsync, # noqa: F401 + cryptoEventsSSE, cryptoEventsSSEAsync, # noqa: F401 + cryptoQuotesSSE, cryptoQuotesSSEAsync) # noqa: F401 from .marketdata.fx import fxSSE # noqa: F401 -from .marketdata.sse import topsSSE, lastSSE, deepSSE, tradesSSE # noqa: F401 -from .marketdata.http import (tops, topsDF, last, lastDF, deep, deepDF, # noqa: F401 - trades, tradesDF, auction, auctionDF, # noqa: F401 - book as deepBook, bookDF as deepBookDF, # noqa: F401 - opHaltStatus, opHaltStatusDF, officialPrice, officialPriceDF, # noqa: F401 - securityEvent, securityEventDF, ssrStatus, ssrStatusDF, # noqa: F401 - systemEvent, systemEventDF, tradeBreak, tradeBreakDF, # noqa: F401 - tradingStatus, tradingStatusDF, hist, histDF) # noqa: F401 +from .marketdata.news import newsSSE, newsSSEAsync # noqa: F401 +from .marketdata.sentiment import sentimentSSE, sentimentSSEAsync # noqa: F401 +from .marketdata.sse import (topsSSE, topsSSEAsync, # noqa: F401 + lastSSE, lastSSEASync, # noqa: F401 + deepSSE, deepSSEAsync, # noqa: F401 + tradesSSE, tradesSSEAsync, # noqa: F401 + auctionSSE, auctionSSEAsync, # noqa: F401 + bookSSE, bookSSEAsync, # noqa: F401 + opHaltStatusSSE, opHaltStatusSSEAsync, # noqa: F401 + officialPriceSSE, officialPriceSSEAsync, # noqa: F401 + securityEventSSE, securityEventSSEAsync, # noqa: F401 + ssrStatusSSE, ssrStatusSSEAsync, # noqa: F401 + systemEventSSE, systemEventSSEAsync, # noqa: F401 + tradeBreaksSSE, tradeBreaksSSEAsync, # noqa: F401 + tradingStatusSSE, tradingStatusSSEAsync) # noqa: F401 +from .marketdata.stock import (stocksUSNoUTPSSE, stocksUSNoUTPSSEAsync, # noqa: F401 + stocksUSSSE, stocksUSSSEAsync, # noqa: F401 + stocksUS1SecondSSE, stocksUS1SecondSSEAsync, # noqa: F401 + stocksUS5SecondSSE, stocksUS5SecondSSEAsync, # noqa: F401 + stocksUS1MinuteSSE, stocksUS1MinuteSSEAsync) # noqa: F401 +from .marketdata.http import (tops, topsAsync, topsDF, # noqa: F401 + last, lastAsync, lastDF, # noqa: F401 + deep, deepAsync, deepDF, # noqa: F401 + trades, tradesAsync, tradesDF, # noqa: F401 + auction, auctionAsync, auctionDF, # noqa: F401 + book as deepBook, bookAsync as deepBookAsync, bookDF as deepBookDF, # noqa: F401 + opHaltStatus, opHaltStatusAsync, opHaltStatusDF, # noqa: F401 + officialPrice, officialPriceAsync, officialPriceDF, # noqa: F401 + securityEvent, securityEventAsync, securityEventDF, # noqa: F401 + ssrStatus, ssrStatusAsync, ssrStatusDF, # noqa: F401 + systemEvent, systemEventAsync, systemEventDF, # noqa: F401 + tradeBreak, tradeBreakAsync, tradeBreakDF, # noqa: F401 + tradingStatus, tradingStatusAsync, tradingStatusDF) # noqa: F401 +from .marketdata.ws import * # noqa: F401,F403 from .points import points, pointsDF # noqa: F401 from .rates import RatesPoints # noqa: F401 from .refdata import (symbols, iexSymbols, mutualFundSymbols, otcSymbols, internationalSymbols, fxSymbols, optionsSymbols, # noqa: F401 diff --git a/pyEX/account/__init__.py b/pyEX/account/__init__.py index 1159e58..d151a78 100644 --- a/pyEX/account/__init__.py +++ b/pyEX/account/__init__.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _requireSecret, _getJson, _postJson, PyEXception, _USAGE_TYPES @@ -29,24 +30,14 @@ def metadata(token='', version=''): version (str): API version Returns: - dict: result + dict or DataFrame: result ''' _requireSecret(token) return _getJson('account/metadata', token, version, None) +@wraps(metadata) def metadataDF(token='', version=''): - '''Used to retrieve account details such as current tier, payment status, message quote usage, etc. - - https://iexcloud.io/docs/api/#metadata - - Args: - token (str): Access token - version (str): API version - - Returns: - DataFrame: result - ''' return pd.DataFrame([metadata(token, version)]) @@ -77,7 +68,7 @@ def usage(type=None, token='', version=''): version (str): API version Returns: - dict: result + dict or DataFrame: result ''' _requireSecret(token) if type is not None and type and type not in _USAGE_TYPES: @@ -87,17 +78,6 @@ def usage(type=None, token='', version=''): return _getJson('account/usage', token, version, None) +@wraps(usage) def usageDF(type=None, token='', version=''): - '''Used to retrieve current month usage for your account. - - https://iexcloud.io/docs/api/#usage - - Args: - type (Optional[string]): Used to specify which quota to return. Ex: messages, rules, rule-records, alerts, alert-records - token (str): Access token - version (str): API version - - Returns: - DataFrame: result - ''' return pd.io.json.json_normalize(usage(type, token, version)) diff --git a/pyEX/alternative/alternative.py b/pyEX/alternative/alternative.py index 46989f0..193045e 100644 --- a/pyEX/alternative/alternative.py +++ b/pyEX/alternative/alternative.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _getJson, _raiseIfNotStr, _strOrDate, _reindex, _toDatetime @@ -14,24 +15,13 @@ def crypto(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('stock/market/crypto/', token, version, filter) +@wraps(crypto) def cryptoDF(token='', version='', filter=''): - '''This will return an array of quotes for all Cryptocurrencies supported by the IEX API. Each element is a standard quote object with four additional keys. - - https://iexcloud.io/docs/api/#crypto - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(crypto(token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') @@ -53,7 +43,7 @@ def sentiment(symbol, type='daily', date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if date: @@ -62,23 +52,8 @@ def sentiment(symbol, type='daily', date=None, token='', version='', filter=''): return _getJson('stock/{symbol}/sentiment/{type}/'.format(symbol=symbol, type=type), token, version, filter) +@wraps(sentiment) def sentimentDF(symbol, type='daily', date=None, token='', version='', filter=''): - '''This endpoint provides social sentiment data from StockTwits. Data can be viewed as a daily value, or by minute for a given date. - - https://iexcloud.io/docs/api/#social-sentiment - Continuous - - Args: - symbol (str): Ticker to request - type (str): 'daily' or 'minute' - date (str): date in YYYYMMDD or datetime - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' ret = sentiment(symbol, type, date, token, version, filter) if type == 'daily': ret = [ret] @@ -101,27 +76,14 @@ def ceoCompensation(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/{symbol}/ceo-compensation'.format(symbol=symbol), token, version, filter) +@wraps(ceoCompensation) def ceoCompensationDF(symbol, token='', version='', filter=''): - '''This endpoint provides CEO compensation for a company by symbol. - - https://iexcloud.io/docs/api/#ceo-compensation - 1am daily - - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' ret = ceoCompensation(symbol, token, version, filter) df = pd.io.json.json_normalize(ret) _toDatetime(df) diff --git a/pyEX/client.py b/pyEX/client.py index cb38b5e..6038c22 100644 --- a/pyEX/client.py +++ b/pyEX/client.py @@ -12,22 +12,31 @@ from .economic import EconomicPoints from .fx import latestFX, latestFXDF, convertFX, convertFXDF, historicalFX, historicalFXDF from .markets import markets, marketsDF -from .marketdata.cryptocurrency import cryptoBookSSE, cryptoEventsSSE, cryptoQuotesSSE -from .marketdata.fx import fxSSE +from .marketdata.cryptocurrency import cryptoBookSSE, cryptoBookSSEAsync, \ + cryptoEventsSSE, cryptoEventsSSEAsync, \ + cryptoQuotesSSE, cryptoQuotesSSEAsync +from .marketdata.fx import fxSSE, fxSSEAsync +from .marketdata.news import newsSSE, newsSSEAsync +from .marketdata.sentiment import sentimentSSE, sentimentSSEAsync from .marketdata.sse import topsSSE, lastSSE, deepSSE, tradesSSE -from .marketdata.http import tops, topsDF, \ - last, lastDF, \ - deep, deepDF, \ - trades, tradesDF, \ - auction, auctionDF, \ - book as deepBook, bookDF as deepBookDF, \ - opHaltStatus, opHaltStatusDF, \ - officialPrice, officialPriceDF, \ - securityEvent, securityEventDF, \ - ssrStatus, ssrStatusDF, \ - systemEvent, systemEventDF, \ - tradeBreak, tradeBreakDF, \ - tradingStatus, tradingStatusDF +from .marketdata.stock import stocksUSNoUTPSSE, stocksUSNoUTPSSEAsync, \ + stocksUSSSE, stocksUSSSEAsync, \ + stocksUS1SecondSSE, stocksUS1SecondSSEAsync, \ + stocksUS5SecondSSE, stocksUS5SecondSSEAsync, \ + stocksUS1MinuteSSE, stocksUS1MinuteSSEAsync +from .marketdata.http import tops, topsAsync, topsDF, \ + last, lastAsync, lastDF, \ + deep, deepAsync, deepDF, \ + trades, tradesAsync, tradesDF, \ + auction, auctionAsync, auctionDF, \ + book as deepBook, bookAsync as deepBookAsync, bookDF as deepBookDF, \ + opHaltStatus, opHaltStatusAsync, opHaltStatusDF, \ + officialPrice, officialPriceAsync, officialPriceDF, \ + securityEvent, securityEventAsync, securityEventDF, \ + ssrStatus, ssrStatusAsync, ssrStatusDF, \ + systemEvent, systemEventAsync, systemEventDF, \ + tradeBreak, tradeBreakAsync, tradeBreakDF, \ + tradingStatus, tradingStatusAsync, tradingStatusDF from .points import points, pointsDF from .premium import (accountingQualityAndRiskMatrix, accountingQualityAndRiskMatrixDF, analystDays, analystDaysDF, @@ -400,32 +409,56 @@ ('lastSSE', lastSSE), ('deepSSE', deepSSE), ('tradesSSE', tradesSSE), + # Stock SSE + ('stocksUSNoUTPSSE,', stocksUSNoUTPSSE), + ('stocksUSNoUTPSSEAsync,', stocksUSNoUTPSSEAsync), + ('stocksUSSSE,', stocksUSSSE), + ('stocksUSSSEAsync,', stocksUSSSEAsync), + ('stocksUS1SecondSSE,', stocksUS1SecondSSE), + ('stocksUS1SecondSSEAsync,', stocksUS1SecondSSEAsync), + ('stocksUS5SecondSSE,', stocksUS5SecondSSE), + ('stocksUS5SecondSSEAsync,', stocksUS5SecondSSEAsync), + ('stocksUS1MinuteSSE,', stocksUS1MinuteSSE), + ('stocksUS1MinuteSSEAsync,', stocksUS1MinuteSSEAsync), # TOPS ('tops', tops), + ('topsAsync', topsAsync), ('topsDF', topsDF), ('last', last), + ('lastAsync', lastAsync), ('lastDF', lastDF), ('deep', deep), + ('deepAsync', deepAsync), ('deepDF', deepDF), ('auction', auction), + ('auctionAsync', auctionAsync), ('auctionDF', auctionDF), ('bookDeep', deepBook), + ('bookDeepAsync', deepBookAsync), ('bookDeepDF', deepBookDF), ('officialPrice', officialPrice), + ('officialPriceAsync', officialPriceAsync), ('officialPriceDF', officialPriceDF), ('opHaltStatus', opHaltStatus), + ('opHaltStatusAsync', opHaltStatusAsync), ('opHaltStatusDF', opHaltStatusDF), ('securityEvent', securityEvent), + ('securityEventAsync', securityEventAsync), ('securityEventDF', securityEventDF), ('ssrStatus', ssrStatus), + ('ssrStatusAsync', ssrStatusAsync), ('ssrStatusDF', ssrStatusDF), ('systemEvent', systemEvent), + ('systemEventAsync', systemEventAsync), ('systemEventDF', systemEventDF), ('trades', trades), + ('tradesAsync', tradesAsync), ('tradesDF', tradesDF), ('tradeBreak', tradeBreak), + ('tradeBreakAsync', tradeBreakAsync), ('tradeBreakDF', tradeBreakDF), ('tradingStatus', tradingStatus), + ('tradingStatusAsync', tradingStatusAsync), ('tradingStatusDF', tradingStatusDF), # Account ('messageBudget', messageBudget), @@ -452,6 +485,13 @@ ('historicalFXDF', historicalFXDF), # FXSSE ('fxSSE', fxSSE), + ('fxSSEAsync', fxSSEAsync), + # NewsSSE + ('newsSSE', newsSSE), + ('newsSSEAsync', newsSSEAsync), + # SentimentSSE + ('sentimentSSE', sentimentSSE), + ('sentimentSSEAsync', sentimentSSEAsync), # Crypto ('cryptoBook', cryptoBook), ('cryptoBookDF', cryptoBookDF), @@ -461,8 +501,11 @@ ('cryptoPriceDF', cryptoPriceDF), # CryptoSSE ('cryptoBookSSE', cryptoBookSSE), + ('cryptoBookSSEAsync', cryptoBookSSEAsync), ('cryptoEventsSSE', cryptoEventsSSE), + ('cryptoEventsSSEAsync', cryptoEventsSSEAsync), ('cryptoQuotesSSE', cryptoQuotesSSE), + ('cryptoQuotesSSEAsync', cryptoQuotesSSEAsync), # Premium # Wall Street Horizon ('analystDays', analystDays), diff --git a/pyEX/common.py b/pyEX/common.py index 469c500..bb86993 100644 --- a/pyEX/common.py +++ b/pyEX/common.py @@ -6,10 +6,7 @@ import pytz import requests import tempfile -try: - import ujson as json -except ImportError: - import json +import json from datetime import datetime from six import string_types from socketIO_client_nexus import SocketIO, BaseNamespace @@ -386,6 +383,16 @@ def _getJson(url, token='', version='', filter=''): return _getJsonOrig(url) +async def _getJsonAsync(url, token='', version='', filter=''): + '''for backwards compat, accepting token and version but ignoring''' + token = token or os.environ.get('IEX_TOKEN') + if token: + if version == 'sandbox': + return await _getJsonIEXCloudSandboxAsync(url, token, version, filter) + return await _getJsonIEXCloudAsync(url, token, version, filter) + return _getJsonOrig(url) + + def _postJson(url, data=None, json=None, token='', version='', token_in_params=True): token = token or os.environ.get('IEX_TOKEN') if version == 'sandbox': @@ -404,9 +411,9 @@ def _getJsonOrig(url): raise PyEXception('Old IEX API is deprecated. For a free API token, sign up at https://iexcloud.io') -def _getJsonIEXCloud(url, token='', version='v1', filter=''): +def _getJsonIEXCloudBase(base_url, url, token='', version='v1', filter=''): '''for iex cloud''' - url = _URL_PREFIX2.format(version=version) + url + url = base_url.format(version=version) + url params = {'token': token} if filter: params.update({'filter': filter}) @@ -416,9 +423,33 @@ def _getJsonIEXCloud(url, token='', version='v1', filter=''): raise PyEXception('Response %d - ' % resp.status_code, resp.text) -def _postJsonIEXCloud(url, data=None, json=None, token='', version='v1', token_in_params=True): +def _getJsonIEXCloud(url, token='', version='v1', filter=''): + '''for iex cloud''' + return _getJsonIEXCloud(_URL_PREFIX2, url, token, version, filter) + + +async def _getJsonIEXCloudAsyncBase(base_url, url, token='', version='v1', filter=''): '''for iex cloud''' + import aiohttp url = _URL_PREFIX2.format(version=version) + url + params = {'token': token} + if filter: + params.update({'filter': filter}) + async with aiohttp.ClientSession() as session: + async with session.get(urlparse(url).geturl(), proxy=_PYEX_PROXIES, params=params) as resp: + if resp.status == 200: + return await resp.json() + raise PyEXception('Response %d - ' % resp.status, await resp.text()) + + +async def _getJsonIEXCloudAsync(url, token='', version='v1', filter=''): + '''for iex cloud''' + return await _getJsonIEXCloudAsyncBase(_URL_PREFIX2, url, token, version, filter) + + +def _postJsonIEXCloudBase(base_url, url, data=None, json=None, token='', version='v1', token_in_params=True): + '''for iex cloud''' + url = base_url.format(version=version) + url if token_in_params: params = {'token': token} else: @@ -429,9 +460,35 @@ def _postJsonIEXCloud(url, data=None, json=None, token='', version='v1', token_i raise PyEXception('Response %d - ' % resp.status_code, resp.text) -def _deleteJsonIEXCloud(url, token='', version='v1'): +def _postJsonIEXCloud(url, data=None, json=None, token='', version='v1', token_in_params=True): '''for iex cloud''' - url = _URL_PREFIX2.format(version=version) + url + return _postJsonIEXCloudBase(_URL_PREFIX2, data, json, token, version, token_in_params) + + +async def _postJsonIEXCloudAsyncBase(base_url, url, data=None, json=None, token='', version='v1', filter='', token_in_params=True): + '''for iex cloud''' + import aiohttp + url = base_url.format(version=version) + url + if token_in_params: + params = {'token': token} + else: + params = {} + + async with aiohttp.ClientSession() as session: + async with session.post(urlparse(url).geturl(), data=data, json=json, proxy=_PYEX_PROXIES, params=params) as resp: + if resp.status == 200: + return await resp.json() + raise PyEXception('Response %d - ' % resp.status, await resp.text()) + + +async def _postJsonIEXCloudAsync(url, data=None, json=None, token='', version='v1', filter='', token_in_params=True): + '''for iex cloud''' + return await _postJsonIEXCloudAsyncBase(_URL_PREFIX2, url, data, json, token, version, filter, token_in_params) + + +def _deleteJsonIEXCloudBase(base_url, url, token='', version='v1'): + '''for iex cloud''' + url = base_url.format(version=version) + url params = {'token': token} resp = requests.delete(urlparse(url).geturl(), proxies=_PYEX_PROXIES, params=params) if resp.status_code == 200: @@ -439,39 +496,47 @@ def _deleteJsonIEXCloud(url, token='', version='v1'): raise PyEXception('Response %d - ' % resp.status_code, resp.text) -def _getJsonIEXCloudSandbox(url, token='', version='v1', filter=''): +def _deleteJsonIEXCloud(url, token='', version='v1'): + '''for iex cloud''' + return _deleteJsonIEXCloud(_URL_PREFIX2, url, token, version) + + +async def _deleteJsonIEXCloudAsyncBase(url, token='', version='v1'): '''for iex cloud''' - url = _URL_PREFIX2_SANDBOX.format(version='v1') + url + import aiohttp + url = _URL_PREFIX2.format(version=version) + url params = {'token': token} - if filter: - params.update({'filter': filter}) - resp = requests.get(urlparse(url).geturl(), proxies=_PYEX_PROXIES, params=params) - if resp.status_code == 200: - return resp.json() - raise PyEXception('Response %d - ' % resp.status_code, resp.text) + + async with aiohttp.ClientSession() as session: + async with session.delete(urlparse(url).geturl(), proxy=_PYEX_PROXIES, params=params) as resp: + if resp.status == 200: + return await resp.json() + raise PyEXception('Response %d - ' % resp.status, await resp.text()) + + +async def _deleteJsonIEXCloudAsync(url, token='', version='v1'): + '''for iex cloud''' + return await _deleteJsonIEXCloudAsyncBase(_URL_PREFIX2, url, token, version) + + +def _getJsonIEXCloudSandbox(url, token='', version='v1', filter=''): + '''for iex cloud''' + return _getJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, token, version, filter) + + +async def _getJsonIEXCloudSandboxAsync(url, token='', version='v1', filter=''): + '''for iex cloud''' + return await _getJsonIEXCloudAsyncBase(_URL_PREFIX2_SANDBOX, url, token, version, filter) def _postJsonIEXCloudSandbox(url, data=None, json=None, token='', version='v1', token_in_params=True): '''for iex cloud''' - url = _URL_PREFIX2_SANDBOX.format(version='v1') + url - if token_in_params: - params = {'token': token} - else: - params = {} - resp = requests.post(urlparse(url).geturl(), data=data, json=json, proxies=_PYEX_PROXIES, params=params) - if resp.status_code == 200: - return resp.json() - raise PyEXception('Response %d - ' % resp.status_code, resp.text) + return _postJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, data, json, token, version, token_in_params) def _deleteJsonIEXCloudSandbox(url, token='', version='v1'): '''for iex cloud''' - url = _URL_PREFIX2_SANDBOX.format(version='v1') + url - params = {'token': token} - resp = requests.delete(urlparse(url).geturl(), proxies=_PYEX_PROXIES, params=params) - if resp.status_code == 200: - return resp.json() - raise PyEXception('Response %d - ' % resp.status_code, resp.text) + return _deleteJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, token, version) def _wsURL(url): @@ -594,11 +659,30 @@ def _streamSSE(url, on_data=print, accrue=False): except (json.JSONDecodeError, KeyboardInterrupt): raise except Exception: - # continue listening - pass + raise return ret +async def _streamSSEAsync(url, accrue=False): + '''internal''' + from aiohttp_sse_client import client as sse_client + + async with sse_client.EventSource(url) as event_source: + try: + async for event in event_source: + yield json.loads(event.data) + + except (json.JSONDecodeError, KeyboardInterrupt): + raise + except ConnectionError: + raise PyEXception("Could not connect to SSE Stream") + except PyEXStopSSE: + return + except Exception: + raise + return + + def _reindex(df, col): '''internal''' if isinstance(col, list): diff --git a/pyEX/cryptocurrency/cryptocurrency.py b/pyEX/cryptocurrency/cryptocurrency.py index ff8dc28..a9d82b9 100644 --- a/pyEX/cryptocurrency/cryptocurrency.py +++ b/pyEX/cryptocurrency/cryptocurrency.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _getJson @@ -16,26 +17,13 @@ def cryptoBook(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('/crypto/{symbol}/book'.format(symbol=symbol), token, version, filter) +@wraps(cryptoBook) def cryptoBookDF(symbol, token='', version='', filter=''): - '''This returns a current snapshot of the book for a specified cryptocurrency. For REST, you will receive a current snapshot of the current book for the specific cryptocurrency. For SSE Streaming, you will get a full representation of the book updated as often as the book changes. Examples of each are below: - - https://iexcloud.io/docs/api/#cryptocurrency-book - continuous - - Args: - symbol (str): cryptocurrency ticker - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(cryptoBook(symbol, token, version, filter)) @@ -52,26 +40,13 @@ def cryptoPrice(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('/crypto/{symbol}/price'.format(symbol=symbol), token, version, filter) +@wraps(cryptoPrice) def cryptoPriceDF(symbol, token='', version='', filter=''): - '''This returns the price for a specified cryptocurrency. - - https://iexcloud.io/docs/api/#cryptocurrency-price - continuous - - Args: - symbol (str): cryptocurrency ticker - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(cryptoPrice(symbol, token, version, filter)) @@ -89,24 +64,11 @@ def cryptoQuote(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('/crypto/{symbol}/price'.format(symbol=symbol), token, version, filter) +@wraps(cryptoQuote) def cryptoQuoteDF(symbol, token='', version='', filter=''): - '''This returns the quote for a specified cryptocurrency. Quotes are available via REST and SSE Streaming. - - https://iexcloud.io/docs/api/#cryptocurrency-quote - continuous - - Args: - symbol (str): cryptocurrency ticker - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(cryptoQuote(symbol, token, version, filter)) diff --git a/pyEX/marketdata/cryptocurrency.py b/pyEX/marketdata/cryptocurrency.py index de8f8d0..2fc244e 100644 --- a/pyEX/marketdata/cryptocurrency.py +++ b/pyEX/marketdata/cryptocurrency.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from enum import Enum -from .sse import _runSSE +from .sse import _runSSE, _runSSEAsync class CryptoSSE(Enum): @@ -13,9 +13,6 @@ def options(): return list(map(lambda c: c.value, CryptoSSE)) -# def _runSSE(method='', symbols=None, on_data=None, token='', version=''): - - def cryptoBookSSE(symbols=None, on_data=None, token='', version=''): '''This returns a current snapshot of the book for a specified cryptocurrency. For REST, you will receive a current snapshot of the current book for the specific cryptocurrency. For SSE Streaming, you will get a full representation of the book updated as often as the book changes. Examples of each are below: @@ -31,6 +28,20 @@ def cryptoBookSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('cryptoBook', symbols, on_data, token, version) +async def cryptoBookSSEAsync(symbols=None, token='', version=''): + '''This returns a current snapshot of the book for a specified cryptocurrency. For REST, you will receive a current snapshot of the current book for the specific cryptocurrency. For SSE Streaming, you will get a full representation of the book updated as often as the book changes. Examples of each are below: + + https://iexcloud.io/docs/api/#cryptocurrency-book + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('cryptoBook', symbols, token, version): + yield item + + def cryptoEventsSSE(symbols=None, on_data=None, token='', version=''): '''This returns a streaming list of event updates such as new and canceled orders. @@ -46,6 +57,20 @@ def cryptoEventsSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('cryptoEvents', symbols, on_data, token, version) +async def cryptoEventsSSEAsync(symbols=None, token='', version=''): + '''This returns a streaming list of event updates such as new and canceled orders. + + https://iexcloud.io/docs/api/#cryptocurrency-events + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('cryptoEvents', symbols, token, version): + yield item + + def cryptoQuotesSSE(symbols=None, on_data=None, token='', version=''): '''This returns the quote for a specified cryptocurrency. Quotes are available via REST and SSE Streaming. @@ -59,3 +84,17 @@ def cryptoQuotesSSE(symbols=None, on_data=None, token='', version=''): ''' return _runSSE('cryptoQuotes', symbols, on_data, token, version) + + +async def cryptoQuotesSSEAsync(symbols=None, token='', version=''): + '''This returns the quote for a specified cryptocurrency. Quotes are available via REST and SSE Streaming. + + https://iexcloud.io/docs/api/#cryptocurrency-quote + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('cryptoQuotes', symbols, token, version): + yield item diff --git a/pyEX/marketdata/fx.py b/pyEX/marketdata/fx.py index 0104abf..8d99b66 100644 --- a/pyEX/marketdata/fx.py +++ b/pyEX/marketdata/fx.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from enum import Enum -from .sse import _runSSE +from .sse import _runSSE, _runSSEAsync class FXSSE(Enum): @@ -11,9 +11,6 @@ def options(): return list(map(lambda c: c.value, FXSSE)) -# def _runSSE(method='', symbols=None, on_data=None, token='', version=''): - - def fxSSE(symbols=None, on_data=None, token='', version=''): '''This endpoint streams real-time foreign currency exchange rates. @@ -27,3 +24,17 @@ def fxSSE(symbols=None, on_data=None, token='', version=''): ''' return _runSSE('forex', symbols, on_data, token, version) + + +async def fxSSEAsync(symbols=None, token='', version=''): + '''This endpoint streams real-time foreign currency exchange rates. + + https://iexcloud.io/docs/api/#forex-currencies + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('forex', symbols, token, version): + yield item diff --git a/pyEX/marketdata/http.py b/pyEX/marketdata/http.py index 72116b4..6f8041f 100644 --- a/pyEX/marketdata/http.py +++ b/pyEX/marketdata/http.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import pandas as pd -from ..common import _getJson, _strToList, _raiseIfNotStr, _strOrDate, _reindex, _toDatetime +from functools import wraps +from ..common import _getJson, _getJsonAsync, _strToList, _raiseIfNotStr, _strOrDate, _reindex, _toDatetime def tops(symbols=None, token='', version=''): @@ -23,20 +24,16 @@ def tops(symbols=None, token='', version=''): return _getJson('tops', token, version) -def topsDF(symbols=None, token='', version=''): - '''TOPS provides IEX’s aggregated best quoted bid and offer position in near real time for all securities on IEX’s displayed limit order book. - TOPS is ideal for developers needing both quote and trade data. - - https://iexcloud.io/docs/api/#tops +@wraps(tops) +async def topsAsync(symbols=None, token='', version=''): + symbols = _strToList(symbols) + if symbols: + return await _getJsonAsync('tops?symbols=' + ','.join(symbols) + '%2b', token, version) + return await _getJsonAsync('tops', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(tops) +def topsDF(symbols=None, token='', version=''): df = pd.io.json.json_normalize(tops(symbols, token, version)) _toDatetime(df) _reindex(df, 'symbol') @@ -63,20 +60,16 @@ def last(symbols=None, token='', version=''): return _getJson('tops/last', token, version) -def lastDF(symbols=None, token='', version=''): - '''Last provides trade data for executions on IEX. It is a near real time, intraday API that provides IEX last sale price, size and time. - Last is ideal for developers that need a lightweight stock quote. - - https://iexcloud.io/docs/api/#last +@wraps(last) +async def lastAsync(symbols=None, token='', version=''): + symbols = _strToList(symbols) + if symbols: + return await _getJsonAsync('tops/last?symbols=' + ','.join(symbols) + '%2b', token, version) + return await _getJsonAsync('tops/last', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(last) +def lastDF(symbols=None, token='', version=''): df = pd.io.json.json_normalize(last(symbols, token, version)) _toDatetime(df) _reindex(df, 'symbol') @@ -107,24 +100,16 @@ def deep(symbol=None, token='', version=''): return _getJson('deep', token, version) -def deepDF(symbol=None, token='', version=''): - '''DEEP is used to receive real-time depth of book quotations direct from IEX. - The depth of book quotations received via DEEP provide an aggregated size of resting displayed orders at a price and side, - and do not indicate the size or number of individual orders at any price level. - Non-displayed orders and non-displayed portions of reserve orders are not represented in DEEP. - - DEEP also provides last trade price and size information. Trades resulting from either displayed or non-displayed orders matching on IEX will be reported. Routed executions will not be reported. - - https://iexcloud.io/docs/api/#deep +@wraps(deep) +async def deepAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep?symbols=' + symbol, token, version) + return await _getJsonAsync('deep', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(deep) +def deepDF(symbol=None, token='', version=''): df = pd.io.json.json_normalize(deep(symbol, token, version)) _toDatetime(df) return df @@ -150,20 +135,16 @@ def auction(symbol=None, token='', version=''): return _getJson('deep/auction', token, version) -def auctionDF(symbol=None, token='', version=''): - '''DEEP broadcasts an Auction Information Message every one second between the Lock-in Time and the auction match for Opening and Closing Auctions, - and during the Display Only Period for IPO, Halt, and Volatility Auctions. Only IEX listed securities are eligible for IEX Auctions. - - https://iexcloud.io/docs/api/#deep-auction +@wraps(auction) +async def auctionAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/auction?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/auction', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(auction) +def auctionDF(symbol=None, token='', version=''): df = pd.io.json.json_normalize(auction(symbol, token, version)) _toDatetime(df) return df @@ -188,19 +169,16 @@ def book(symbol=None, token='', version=''): return _getJson('deep/book', token, version) -def bookDF(symbol=None, token='', version=''): - '''Book shows IEX’s bids and asks for given symbols. - - https://iexcloud.io/docs/api/#deep-book +@wraps(book) +async def bookAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/book?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/book', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(book) +def bookDF(symbol=None, token='', version=''): x = book(symbol, token, version) data = [] for key in x: @@ -237,25 +215,16 @@ def opHaltStatus(symbol=None, token='', version=''): return _getJson('deep/op-halt-status', token, version) -def opHaltStatusDF(symbol=None, token='', version=''): - '''The Exchange may suspend trading of one or more securities on IEX for operational reasons and indicates such operational halt using the Operational halt status message. - - IEX disseminates a full pre-market spin of Operational halt status messages indicating the operational halt status of all securities. - In the spin, IEX will send out an Operational Halt Message with “N” (Not operationally halted on IEX) for all securities that are eligible for trading at the start of the Pre-Market Session. - If a security is absent from the dissemination, firms should assume that the security is being treated as operationally halted in the IEX Trading System at the start of the Pre-Market Session. - - After the pre-market spin, IEX will use the Operational halt status message to relay changes in operational halt status for an individual security. - - https://iexcloud.io/docs/api/#deep-operational-halt-status +@wraps(opHaltStatus) +async def opHaltStatusAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/op-halt-status?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/op-halt-status', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(opHaltStatus) +def opHaltStatusDF(symbol=None, token='', version=''): x = opHaltStatus(symbol, token, version) data = [] for key in x: @@ -288,21 +257,16 @@ def officialPrice(symbol=None, token='', version=''): return _getJson('deep/official-price', token, version) -def officialPriceDF(symbol=None, token='', version=''): - '''The Official Price message is used to disseminate the IEX Official Opening and Closing Prices. - - These messages will be provided only for IEX Listed Securities. - - https://iexcloud.io/docs/api/#deep-official-price +@wraps(officialPrice) +async def officialPriceAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/official-price?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/official-price', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(officialPrice) +def officialPriceDF(symbol=None, token='', version=''): df = pd.io.json.json_normalize(officialPrice(symbol, token, version)) _toDatetime(df) return df @@ -327,19 +291,16 @@ def securityEvent(symbol=None, token='', version=''): return _getJson('deep/security-event', token, version) -def securityEventDF(symbol=None, token='', version=''): - '''The Security event message is used to indicate events that apply to a security. A Security event message will be sent whenever such event occurs - - https://iexcloud.io/docs/api/#deep-security-event +@wraps(securityEvent) +async def securityEventAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/security-event?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/security-event', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(securityEvent) +def securityEventDF(symbol=None, token='', version=''): x = securityEvent(symbol, token, version) data = [] for key in x: @@ -375,6 +336,15 @@ def ssrStatus(symbol=None, token='', version=''): return _getJson('deep/ssr-status', token, version) +@wraps(ssrStatus) +async def ssrStatusAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/ssr-status?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/ssr-status', token, version) + + +@wraps(ssrStatus) def ssrStatusDF(symbol=None, token='', version=''): '''In association with Rule 201 of Regulation SHO, the Short Sale Price Test Message is used to indicate when a short sale price test restriction is in effect for a security. @@ -421,20 +391,13 @@ def systemEvent(token='', version=''): return _getJson('deep/system-event', token, version) -def systemEventDF(token='', version=''): - '''The System event message is used to indicate events that apply to the market or the data feed. +@wraps(systemEvent) +async def systemEventAsync(token='', version=''): + return await _getJsonAsync('deep/system-event', token, version) - There will be a single message disseminated per channel for each System Event type within a given trading session. - https://iexcloud.io/docs/api/#deep-system-event - - Args: - token (str): Access token - version (str): API version - - Returns: - DataFrame: result - ''' +@wraps(systemEvent) +def systemEventDF(token='', version=''): df = pd.io.json.json_normalize(systemEvent(token, version)) _toDatetime(df) return df @@ -459,19 +422,16 @@ def trades(symbol=None, token='', version=''): return _getJson('deep/trades', token, version) -def tradesDF(symbol=None, token='', version=''): - '''Trade report messages are sent when an order on the IEX Order Book is executed in whole or in part. DEEP sends a Trade report message for every individual fill. +@wraps(trades) +async def tradesAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/trades?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/trades', token, version) - https://iexcloud.io/docs/api/#deep-trades - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - - Returns: - DataFrame: result - ''' +@wraps(trades) +def tradesDF(symbol=None, token='', version=''): x = trades(symbol, token, version) data = [] for key in x: @@ -504,20 +464,16 @@ def tradeBreak(symbol=None, token='', version=''): return _getJson('deep/trade-breaks', token, version) -def tradeBreakDF(symbol=None, token='', version=''): - '''Trade break messages are sent when an execution on IEX is broken on that same trading day. Trade breaks are rare and only affect applications that rely upon IEX execution based data. - - https://iexcloud.io/docs/api/#deep-trade-break - +@wraps(tradeBreak) +async def tradeBreakAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/trade-breaks?symbols=' + symbol, token, version) + return await _getJsonAsync('deep/trade-breaks', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(tradeBreak) +def tradeBreakDF(symbol=None, token='', version=''): df = pd.io.json.json_normalize(tradeBreak(symbol, token, version)) _toDatetime(df) return df @@ -557,33 +513,16 @@ def tradingStatus(symbol=None, token='', version=''): return _getJson('deep/trading-status', token, version) -def tradingStatusDF(symbol=None, token='', version=''): - '''The Trading status message is used to indicate the current trading status of a security. - For IEX-listed securities, IEX acts as the primary market and has the authority to institute a trading halt or trading pause in a security due to news dissemination or regulatory reasons. - For non-IEX-listed securities, IEX abides by any regulatory trading halts and trading pauses instituted by the primary or listing market, as applicable. - - IEX disseminates a full pre-market spin of Trading status messages indicating the trading status of all securities. - In the spin, IEX will send out a Trading status message with “T” (Trading) for all securities that are eligible for trading at the start of the Pre-Market Session. - If a security is absent from the dissemination, firms should assume that the security is being treated as operationally halted in the IEX Trading System. - - After the pre-market spin, IEX will use the Trading status message to relay changes in trading status for an individual security. Messages will be sent when a security is: - - Halted - Paused* - Released into an Order Acceptance Period* - Released for trading - *The paused and released into an Order Acceptance Period status will be disseminated for IEX-listed securities only. Trading pauses on non-IEX-listed securities will be treated simply as a halt. - - https://iexcloud.io/docs/api/#deep-trading-status +@wraps(tradingStatus) +async def tradingStatusAsync(symbol=None, token='', version=''): + _raiseIfNotStr(symbol) + if symbol: + return await _getJsonAsync('deep/trading-status?symbols=' + symbol, token, version) + return await _getJson('deep/trading-status', token, version) - Args: - symbol (str): Ticker to request - token (str): Access token - version (str): API version - Returns: - DataFrame: result - ''' +@wraps(tradingStatus) +def tradingStatusDF(symbol=None, token='', version=''): x = tradingStatus(symbol, token, version) data = [] for key in x: @@ -597,8 +536,6 @@ def tradingStatusDF(symbol=None, token='', version=''): def hist(date=None, token='', version=''): ''' - - Args: date (datetime): Effective date token (str): Access token @@ -615,6 +552,16 @@ def hist(date=None, token='', version=''): return _getJson('hist?date=' + date, token, version) +@wraps(hist) +async def histAsync(date=None, token='', version=''): + if date is None: + return await _getJson('hist', token, version) + else: + date = _strOrDate(date) + return await _getJsonAsync('hist?date=' + date, token, version) + + +@wraps(hist) def histDF(date=None, token='', version=''): '''https://iextrading.com/developer/docs/#hist''' x = hist(date, token, version) diff --git a/pyEX/marketdata/news.py b/pyEX/marketdata/news.py new file mode 100644 index 0000000..1ecc6be --- /dev/null +++ b/pyEX/marketdata/news.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from .sse import _runSSE, _runSSEAsync + + +def newsSSE(symbols=None, on_data=None, token='', version=''): + '''Stream news + + https://iexcloud.io/docs/api/#sse-streaming + + Args: + symbols (str): Tickers to request + on_data (function): Callback on data + token (str): Access token + version (str): API version + ''' + return _runSSE('news-stream', symbols, on_data, token, version) + + +async def newsSSEAsync(symbols=None, token='', version=''): + '''Stream news + + https://iexcloud.io/docs/api/#sse-streaming + + Args: + symbols (str): Tickers to request + on_data (function): Callback on data + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('news-stream', symbols, token, version): + yield item diff --git a/pyEX/marketdata/sentiment.py b/pyEX/marketdata/sentiment.py new file mode 100644 index 0000000..1eff3b3 --- /dev/null +++ b/pyEX/marketdata/sentiment.py @@ -0,0 +1,31 @@ +# -*- coding: utf-8 -*- +from .sse import _runSSE, _runSSEAsync + + +def sentimentSSE(symbols=None, on_data=None, token='', version=''): + '''Stream social sentiment + + https://iexcloud.io/docs/api/#sse-streaming + + Args: + symbols (str): Tickers to request + on_data (function): Callback on data + token (str): Access token + version (str): API version + ''' + return _runSSE('sentiment', symbols, on_data, token, version) + + +async def sentimentSSEAsync(symbols=None, token='', version=''): + '''Stream social sentiment + + https://iexcloud.io/docs/api/#sse-streaming + + Args: + symbols (str): Tickers to request + on_data (function): Callback on data + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('sentiment', symbols, token, version): + yield item diff --git a/pyEX/marketdata/sse.py b/pyEX/marketdata/sse.py index 3f3aed2..3434f95 100644 --- a/pyEX/marketdata/sse.py +++ b/pyEX/marketdata/sse.py @@ -1,6 +1,6 @@ # -*- coding: utf-8 -*- from enum import Enum -from ..common import _strCommaSeparatedString, _streamSSE, _SSE_URL_PREFIX, _SSE_URL_PREFIX_ALL, _SSE_DEEP_URL_PREFIX, _SSE_URL_PREFIX_SANDBOX, _SSE_URL_PREFIX_ALL_SANDBOX, _SSE_DEEP_URL_PREFIX_SANDBOX, PyEXception +from ..common import _strCommaSeparatedString, _streamSSE, _streamSSEAsync, _SSE_URL_PREFIX, _SSE_URL_PREFIX_ALL, _SSE_DEEP_URL_PREFIX, _SSE_URL_PREFIX_SANDBOX, _SSE_URL_PREFIX_ALL_SANDBOX, _SSE_DEEP_URL_PREFIX_SANDBOX, PyEXception class DeepChannelsSSE(Enum): @@ -33,6 +33,26 @@ def _runSSE(method='', symbols=None, on_data=None, token='', version=''): return _streamSSE(_SSE_URL_PREFIX_ALL.format(channel=method, symbols=symbols, token=token, version=version), on_data=on_data) +async def _runSSEAsync(method='', symbols=None, token='', version=''): + if method == '': + raise PyEXception('method cannot be blank!') + if symbols: + symbols = _strCommaSeparatedString(symbols) + if version == 'sandbox': + async for item in _streamSSEAsync(_SSE_URL_PREFIX_SANDBOX.format(channel=method, symbols=symbols, token=token, version=version)): + yield item + return + async for item in _streamSSEAsync(_SSE_URL_PREFIX.format(channel=method, symbols=symbols, token=token, version=version)): + yield item + return + if version == 'sandbox': + async for item in _streamSSEAsync(_SSE_URL_PREFIX_ALL_SANDBOX.format(channel=method, symbols=symbols, token=token, version=version)): + yield item + return + async for item in _streamSSEAsync(_SSE_URL_PREFIX_ALL.format(channel=method, symbols=symbols, token=token, version=version)): + yield item + + def topsSSE(symbols=None, on_data=None, token='', version=''): '''TOPS provides IEX’s aggregated best quoted bid and offer position in near real time for all securities on IEX’s displayed limit order book. TOPS is ideal for developers needing both quote and trade data. @@ -44,11 +64,25 @@ def topsSSE(symbols=None, on_data=None, token='', version=''): on_data (function): Callback on data token (str): Access token version (str): API version - ''' return _runSSE('tops', symbols, on_data, token, version) +async def topsSSEAsync(symbols=None, token='', version=''): + '''TOPS provides IEX’s aggregated best quoted bid and offer position in near real time for all securities on IEX’s displayed limit order book. + TOPS is ideal for developers needing both quote and trade data. + + https://iexcloud.io/docs/api/#tops + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('tops', symbols, token, version): + yield item + + def lastSSE(symbols=None, on_data=None, token='', version=''): '''Last provides trade data for executions on IEX. It is a near real time, intraday API that provides IEX last sale price, size and time. Last is ideal for developers that need a lightweight stock quote. @@ -65,6 +99,22 @@ def lastSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('last', symbols, on_data, token, version) +async def lastSSEASync(symbols=None, token='', version=''): + '''Last provides trade data for executions on IEX. It is a near real time, intraday API that provides IEX last sale price, size and time. + Last is ideal for developers that need a lightweight stock quote. + + https://iexcloud.io/docs/api/#last + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + + ''' + async for item in _runSSEAsync('last', symbols, token, version): + yield item + + def deepSSE(symbols=None, channels=None, on_data=None, token='', version=''): '''DEEP is used to receive real-time depth of book quotations direct from IEX. The depth of book quotations received via DEEP provide an aggregated size of resting displayed orders at a price and side, @@ -105,6 +155,48 @@ def deepSSE(symbols=None, channels=None, on_data=None, token='', version=''): return _streamSSE(_SSE_DEEP_URL_PREFIX.format(symbols=symbols, channels=channels, token=token, version=version), on_data) +async def deepSSEAsync(symbols=None, channels=None, token='', version=''): + '''DEEP is used to receive real-time depth of book quotations direct from IEX. + The depth of book quotations received via DEEP provide an aggregated size of resting displayed orders at a price and side, + and do not indicate the size or number of individual orders at any price level. + Non-displayed orders and non-displayed portions of reserve orders are not represented in DEEP. + + DEEP also provides last trade price and size information. Trades resulting from either displayed or non-displayed orders matching on IEX will be reported. Routed executions will not be reported. + + https://iexcloud.io/docs/api/#deep + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + + ''' + symbols = _strCommaSeparatedString(symbols) + + channels = channels or [] + if isinstance(channels, str): + if channels not in DeepChannelsSSE.options(): + raise PyEXception('Channel not recognized: %s', type(channels)) + channels = [channels] + elif isinstance(channels, DeepChannelsSSE): + channels = [channels.value] + elif isinstance(channels, list): + for i, c in enumerate(channels): + if isinstance(c, DeepChannelsSSE): + channels[i] = c.value + elif not isinstance(c, str) or isinstance(c, str) and c not in DeepChannelsSSE.options(): + raise PyEXception('Channel not recognized: %s', c) + + channels = _strCommaSeparatedString(channels) + + if version == 'sandbox': + async for item in _streamSSEAsync(_SSE_DEEP_URL_PREFIX_SANDBOX.format(symbols=symbols, channels=channels, token=token, version=version)): + yield item + else: + async for item in _streamSSEAsync(_SSE_DEEP_URL_PREFIX.format(symbols=symbols, channels=channels, token=token, version=version)): + yield item + + def tradesSSE(symbols=None, on_data=None, token='', version=''): '''Trade report messages are sent when an order on the IEX Order Book is executed in whole or in part. DEEP sends a Trade report message for every individual fill. @@ -123,6 +215,26 @@ def tradesSSE(symbols=None, on_data=None, token='', version=''): return _streamSSE(_SSE_DEEP_URL_PREFIX.format(symbols=symbols, channels='trades', token=token, version=version), on_data) +async def tradesSSEAsync(symbols=None, token='', version=''): + '''Trade report messages are sent when an order on the IEX Order Book is executed in whole or in part. DEEP sends a Trade report message for every individual fill. + + https://iexcloud.io/docs/api/#deep-trades + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + + ''' + symbols = _strCommaSeparatedString(symbols) + if version == 'sandbox': + async for item in _streamSSEAsync(_SSE_DEEP_URL_PREFIX_SANDBOX.format(symbols=symbols, channels='trades', token=token, version=version)): + yield item + else: + async for item in _streamSSEAsync(_SSE_DEEP_URL_PREFIX.format(symbols=symbols, channels='trades', token=token, version=version)): + yield item + + def auctionSSE(symbols=None, on_data=None, token='', version=''): '''DEEP broadcasts an Auction Information Message every one second between the Lock-in Time and the auction match for Opening and Closing Auctions, and during the Display Only Period for IPO, Halt, and Volatility Auctions. Only IEX listed securities are eligible for IEX Auctions. @@ -139,6 +251,22 @@ def auctionSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('auction', symbols, on_data, token, version) +async def auctionSSEAsync(symbols=None, token='', version=''): + '''DEEP broadcasts an Auction Information Message every one second between the Lock-in Time and the auction match for Opening and Closing Auctions, + and during the Display Only Period for IPO, Halt, and Volatility Auctions. Only IEX listed securities are eligible for IEX Auctions. + + https://iexcloud.io/docs/api/#deep-auction + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + + ''' + async for item in _runSSEAsync('auction', symbols, token, version): + yield item + + def bookSSE(symbols=None, on_data=None, token='', version=''): '''Book shows IEX’s bids and asks for given symbols. @@ -154,6 +282,21 @@ def bookSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('book', symbols, on_data, token, version) +async def bookSSEAsync(symbols=None, token='', version=''): + '''Book shows IEX’s bids and asks for given symbols. + + https://iexcloud.io/docs/api/#deep-book + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + + ''' + async for item in _runSSEAsync('book', symbols, token, version): + yield item + + def opHaltStatusSSE(symbols=None, on_data=None, token='', version=''): '''The Exchange may suspend trading of one or more securities on IEX for operational reasons and indicates such operational halt using the Operational halt status message. @@ -175,6 +318,27 @@ def opHaltStatusSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('op-halt-status', symbols, on_data, token, version) +async def opHaltStatusSSEAsync(symbols=None, token='', version=''): + '''The Exchange may suspend trading of one or more securities on IEX for operational reasons and indicates such operational halt using the Operational halt status message. + + IEX disseminates a full pre-market spin of Operational halt status messages indicating the operational halt status of all securities. + In the spin, IEX will send out an Operational Halt Message with “N” (Not operationally halted on IEX) for all securities that are eligible for trading at the start of the Pre-Market Session. + If a security is absent from the dissemination, firms should assume that the security is being treated as operationally halted in the IEX Trading System at the start of the Pre-Market Session. + + After the pre-market spin, IEX will use the Operational halt status message to relay changes in operational halt status for an individual security. + + https://iexcloud.io/docs/api/#deep-operational-halt-status + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + + ''' + async for item in _runSSEAsync('op-halt-status', symbols, token, version): + yield item + + def officialPriceSSE(symbols=None, on_data=None, token='', version=''): '''The Official Price message is used to disseminate the IEX Official Opening and Closing Prices. @@ -192,6 +356,22 @@ def officialPriceSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('official-price', symbols, on_data, token, version) +async def officialPriceSSEAsync(symbols=None, token='', version=''): + '''The Official Price message is used to disseminate the IEX Official Opening and Closing Prices. + + These messages will be provided only for IEX Listed Securities. + + https://iexcloud.io/docs/api/#deep-official-price + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('official-price', symbols, token, version): + yield item + + def securityEventSSE(symbols=None, on_data=None, token='', version=''): '''The Security event message is used to indicate events that apply to a security. A Security event message will be sent whenever such event occurs @@ -207,6 +387,20 @@ def securityEventSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('security-event', symbols, on_data, token, version) +async def securityEventSSEAsync(symbols=None, token='', version=''): + '''The Security event message is used to indicate events that apply to a security. A Security event message will be sent whenever such event occurs + + https://iexcloud.io/docs/api/#deep-security-event + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('security-event', symbols, token, version): + yield item + + def ssrStatusSSE(symbols=None, on_data=None, token='', version=''): '''In association with Rule 201 of Regulation SHO, the Short Sale Price Test Message is used to indicate when a short sale price test restriction is in effect for a security. @@ -226,6 +420,24 @@ def ssrStatusSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('ssr-status', symbols, on_data, token, version) +async def ssrStatusSSEAsync(symbols=None, token='', version=''): + '''In association with Rule 201 of Regulation SHO, the Short Sale Price Test Message is used to indicate when a short sale price test restriction is in effect for a security. + + IEX disseminates a full pre-market spin of Short sale price test status messages indicating the Rule 201 status of all securities. After the pre-market spin, IEX will use the Short sale price test status message in the event of an intraday status change. + + The IEX Trading System will process orders based on the latest short sale price test restriction status. + + https://iexcloud.io/docs/api/#deep-short-sale-price-test-status + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('ssr-status', symbols, token, version): + yield item + + def systemEventSSE(symbols=None, on_data=None, token='', version=''): '''The System event message is used to indicate events that apply to the market or the data feed. @@ -243,6 +455,22 @@ def systemEventSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('system-event', symbols, on_data, token, version) +async def systemEventSSEAsync(symbols=None, token='', version=''): + '''The System event message is used to indicate events that apply to the market or the data feed. + + There will be a single message disseminated per channel for each System Event type within a given trading session. + + https://iexcloud.io/docs/api/#deep-system-event + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('system-event', symbols, token, version): + yield item + + def tradeBreaksSSE(symbols=None, on_data=None, token='', version=''): '''Trade report messages are sent when an order on the IEX Order Book is executed in whole or in part. DEEP sends a Trade report message for every individual fill. @@ -258,6 +486,20 @@ def tradeBreaksSSE(symbols=None, on_data=None, token='', version=''): return _runSSE('trade-breaks', symbols, on_data, token, version) +async def tradeBreaksSSEAsync(symbols=None, token='', version=''): + '''Trade report messages are sent when an order on the IEX Order Book is executed in whole or in part. DEEP sends a Trade report message for every individual fill. + + https://iexcloud.io/docs/api/#deep-trades + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('trade-breaks', symbols, token, version): + yield item + + def tradingStatusSSE(symbols=None, on_data=None, token='', version=''): '''The Trading status message is used to indicate the current trading status of a security. For IEX-listed securities, IEX acts as the primary market and has the authority to institute a trading halt or trading pause in a security due to news dissemination or regulatory reasons. @@ -285,3 +527,31 @@ def tradingStatusSSE(symbols=None, on_data=None, token='', version=''): ''' return _runSSE('trading-status', symbols, on_data, token, version) + + +async def tradingStatusSSEAsync(symbols=None, token='', version=''): + '''The Trading status message is used to indicate the current trading status of a security. + For IEX-listed securities, IEX acts as the primary market and has the authority to institute a trading halt or trading pause in a security due to news dissemination or regulatory reasons. + For non-IEX-listed securities, IEX abides by any regulatory trading halts and trading pauses instituted by the primary or listing market, as applicable. + + IEX disseminates a full pre-market spin of Trading status messages indicating the trading status of all securities. + In the spin, IEX will send out a Trading status message with “T” (Trading) for all securities that are eligible for trading at the start of the Pre-Market Session. + If a security is absent from the dissemination, firms should assume that the security is being treated as operationally halted in the IEX Trading System. + + After the pre-market spin, IEX will use the Trading status message to relay changes in trading status for an individual security. Messages will be sent when a security is: + + Halted + Paused* + Released into an Order Acceptance Period* + Released for trading + *The paused and released into an Order Acceptance Period status will be disseminated for IEX-listed securities only. Trading pauses on non-IEX-listed securities will be treated simply as a halt. + + https://iexcloud.io/docs/api/#deep-trading-status + + Args: + symbols (str): Tickers to request + token (str): Access token + version (str): API version + ''' + async for item in _runSSEAsync('trading-status', symbols, token, version): + yield item diff --git a/pyEX/marketdata/stock.py b/pyEX/marketdata/stock.py new file mode 100644 index 0000000..22c1706 --- /dev/null +++ b/pyEX/marketdata/stock.py @@ -0,0 +1,98 @@ +# -*- coding: utf-8 -*- +from enum import Enum +from functools import wraps +from .sse import _runSSE, _runSSEAsync + + +class StockSSE(Enum): + STOCKSUSNOUTP = 'stocksUSNoUTP' + STOCKSUS = 'stocksUS' + STOCKSUS1SECOND = 'stocksUS1Second' + STOCKSUS5SECOND = 'stocksUS5Second' + STOCKSUS1MINUTE = 'stocksUS1Minute' + + @staticmethod + def options(): + return list(map(lambda c: c.value, StockSSE)) + + +def _baseSSE(symbols=None, on_data=None, token='', version='', name=''): + '''https://iexcloud.io/docs/api/#sse-streaming + + Args: + symbols (str): Tickers to request + on_data (function): Callback on data + token (str): Access token + version (str): API version + + ''' + return _runSSE(name, symbols, on_data, token, version) + + +async def _baseSSEAsync(symbols=None, on_data=None, token='', version='', name=''): + '''https://iexcloud.io/docs/api/#sse-streaming + + Args: + symbols (str): Tickers to request + on_data (function): Callback on data + token (str): Access token + version (str): API version + + ''' + for item in _runSSEAsync(name, symbols, on_data, token, version): + yield item + + +@wraps(_baseSSE) +def stocksUSNoUTPSSE(symbols=None, on_data=None, token='', version=''): + return _baseSSE(symbols, on_data, token, version, 'stocksUSNoUTP') + + +@wraps(_baseSSEAsync) +def stocksUSNoUTPSSEAsync(symbols=None, token='', version=''): + for item in _baseSSEAsync(symbols, token, version, 'stocksUSNoUTP'): + yield item + + +@wraps(_baseSSE) +def stocksUSSSE(symbols=None, on_data=None, token='', version=''): + return _baseSSE(symbols, on_data, token, version, 'stocksUS') + + +@wraps(_baseSSEAsync) +def stocksUSSSEAsync(symbols=None, token='', version=''): + for item in _baseSSEAsync(symbols, token, version, 'stocksUS'): + yield item + + +@wraps(_baseSSE) +def stocksUS1SecondSSE(symbols=None, on_data=None, token='', version=''): + return _baseSSE(symbols, on_data, token, version, 'stocksUS1Second') + + +@wraps(_baseSSEAsync) +def stocksUS1SecondSSEAsync(symbols=None, token='', version=''): + for item in _baseSSEAsync(symbols, token, version, 'stocksUS1Second'): + yield item + + +@wraps(_baseSSE) +def stocksUS5SecondSSE(symbols=None, on_data=None, token='', version=''): + return _baseSSE(symbols, on_data, token, version, 'stocksUS5Second') + + +@wraps(_baseSSEAsync) +def stocksUS5SecondSSEAsync(symbols=None, token='', version=''): + for item in _baseSSEAsync(symbols, token, version, 'stocksUS5Second'): + yield item + + +@wraps(_baseSSE) +def stocksUS1MinuteSSE(symbols=None, on_data=None, token='', version=''): + return _baseSSE(symbols, on_data, token, version, 'stocksUS1Minute') + + +@wraps(_baseSSEAsync) +def stocksUS1MinuteSSEAsync(symbols=None, token='', version=''): + for item in _baseSSEAsync(symbols, token, version, 'stocksUS1Minute'): + yield item diff --git a/pyEX/marketdata/ws.py b/pyEX/marketdata/ws.py new file mode 100644 index 0000000..a23576c --- /dev/null +++ b/pyEX/marketdata/ws.py @@ -0,0 +1,142 @@ +from deprecation import deprecated +from enum import Enum +from ..common import _strToList, _stream, _wsURL, PyEXception + + +class DeepChannels(Enum): + TRADINGSTATUS = 'tradingstatus' + AUCTION = 'auction' + OPHALTSTATUS = 'ophaltstatus' + SSR = 'ssr' + SECURITYEVENT = 'securityevent' + TRADEBREAK = 'tradebreak' + TRADES = 'trades' + BOOK = 'book' + SYSTEMEVENT = 'systemevent' + ALL = 'deep' + + @staticmethod + def options(): + return list(map(lambda c: c.value, DeepChannels)) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def topsWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#tops''' + symbols = _strToList(symbols) + if symbols: + sendinit = ('subscribe', ','.join(symbols)) + return _stream(_wsURL('tops'), sendinit, on_data) + return _stream(_wsURL('tops'), on_data=on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def lastWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#last''' + symbols = _strToList(symbols) + if symbols: + sendinit = ('subscribe', ','.join(symbols)) + return _stream(_wsURL('last'), sendinit, on_data) + return _stream(_wsURL('last'), on_data=on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def deepWS(symbols=None, channels=None, on_data=None): + '''https://iextrading.com/developer/docs/#deep''' + symbols = _strToList(symbols) + + channels = channels or [] + if isinstance(channels, str): + if channels not in DeepChannels.options(): + raise PyEXception('Channel not recognized: %s', type(channels)) + channels = [channels] + elif isinstance(channels, DeepChannels): + channels = [channels.value] + elif isinstance(channels, list): + for i, c in enumerate(channels): + if isinstance(c, DeepChannels): + channels[i] = c.value + elif not isinstance(c, str) or isinstance(c, str) and c not in DeepChannels.options(): + raise PyEXception('Channel not recognized: %s', c) + + sendinit = ({'symbols': symbols, 'channels': channels},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def bookWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#book51''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['book']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def tradesWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#trades''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['trades']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def systemEventWS(on_data=None): + '''https://iextrading.com/developer/docs/#system-event''' + sendinit = ({'channels': ['systemevent']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def tradingStatusWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#trading-status''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['tradingstatus']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def opHaltStatusWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#operational-halt-status''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['ophaltstatus']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def ssrStatusWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#short-sale-price-test-status''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['ssr']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def securityEventWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#security-event''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['securityevent']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def tradeBreakWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#trade-break''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['tradebreaks']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def auctionWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#auction''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['auction']},) + return _stream(_wsURL('deep'), sendinit, on_data) + + +@deprecated(details='Deprecated: Use SSE for IEX Cloud') +def officialPriceWS(symbols=None, on_data=None): + '''https://iextrading.com/developer/docs/#official-price''' + symbols = _strToList(symbols) + sendinit = ({'symbols': symbols, 'channels': ['official-price']},) + return _stream(_wsURL('deep'), sendinit, on_data) diff --git a/pyEX/options/options.py b/pyEX/options/options.py index a9fb35f..88f753b 100644 --- a/pyEX/options/options.py +++ b/pyEX/options/options.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _getJson, _raiseIfNotStr, _toDatetime @@ -17,7 +18,7 @@ def optionExpirations(symbol, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) return _getJson('stock/' + symbol + '/options', token, version, filter) @@ -38,7 +39,7 @@ def options(symbol, expiration, side='', token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if side: @@ -46,23 +47,8 @@ def options(symbol, expiration, side='', token='', version='', filter=''): return _getJson('stock/{symbol}/options/{expiration}/'.format(symbol=symbol, expiration=expiration), token, version, filter) +@wraps(options) def optionsDF(symbol, expiration, side='', token='', version='', filter=''): - '''Returns end of day options data - - https://iexcloud.io/docs/api/#options - 9:30am-5pm ET Mon-Fri - - Args: - symbol (str): Ticker to request - expiration (str): Expiration date - side (str): Side (optional) - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' p = options(symbol, expiration, side, token, version, filter) df = pd.DataFrame(p) _toDatetime(df) diff --git a/pyEX/points/points.py b/pyEX/points/points.py index c03883a..29a9313 100644 --- a/pyEX/points/points.py +++ b/pyEX/points/points.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _getJson, _raiseIfNotStr, _toDatetime @@ -19,7 +20,7 @@ def points(symbol='market', key='', token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(symbol) if key: @@ -27,24 +28,8 @@ def points(symbol='market', key='', token='', version='', filter=''): return _getJson('data-points/{symbol}'.format(symbol=symbol), token, version, filter) +@wraps(points) def pointsDF(symbol='market', key='', token='', version='', filter=''): - '''Data points are available per symbol and return individual plain text values. - Retrieving individual data points is useful for Excel and Google Sheet users, and applications where a single, lightweight value is needed. - We also provide update times for some endpoints which allow you to call an endpoint only once it has new data. - - - https://iexcloud.io/docs/api/#data-points - - Args: - symbol (str): Ticker or market to query - key (str): data point to fetch. If empty or none, will return available data points - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' _raiseIfNotStr(symbol) if key: val = points(symbol, key, token, version, filter) diff --git a/pyEX/refdata/calendar.py b/pyEX/refdata/calendar.py index ae7d4c5..38c998d 100644 --- a/pyEX/refdata/calendar.py +++ b/pyEX/refdata/calendar.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _getJson, _strOrDate, _toDatetime @@ -20,7 +21,7 @@ def calendar(type='holiday', direction='next', last=1, startDate=None, token='', filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if startDate: startDate = _strOrDate(startDate) @@ -28,24 +29,8 @@ def calendar(type='holiday', direction='next', last=1, startDate=None, token='', return _getJson('ref-data/us/dates/' + type + '/' + direction + '/' + str(last), token, version, filter) +@wraps(calendar) def calendarDF(type='holiday', direction='next', last=1, startDate=None, token='', version='', filter=''): - '''This call allows you to fetch a number of trade dates or holidays from a given date. For example, if you want the next trading day, you would call /ref-data/us/dates/trade/next/1. - - https://iexcloud.io/docs/api/#u-s-exchanges - 8am, 9am, 12pm, 1pm UTC daily - - Args: - type (str): "holiday" or "trade" - direction (str): "next" or "last" - last (int): number to move in direction - startDate (date): start date for next or last, YYYYMMDD - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - dict: result - ''' dat = pd.DataFrame(calendar(type, direction, last, startDate, token, version, filter)) _toDatetime(dat) return dat @@ -67,26 +52,11 @@ def holidays(direction='next', last=1, startDate=None, token='', version='', fil filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return calendar('holiday', direction, last, startDate, token, version, filter) +@wraps(holidays) def holidaysDF(direction='next', last=1, startDate=None, token='', version='', filter=''): - '''This call allows you to fetch a number of trade dates or holidays from a given date. For example, if you want the next trading day, you would call /ref-data/us/dates/trade/next/1. - - https://iexcloud.io/docs/api/#u-s-exchanges - 8am, 9am, 12pm, 1pm UTC daily - - Args: - direction (str): "next" or "last" - last (int): number to move in direction - startDate (date): start date for next or last, YYYYMMDD - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - dict: result - ''' return calendarDF('holiday', direction, last, startDate, token, version, filter) diff --git a/pyEX/refdata/exchanges.py b/pyEX/refdata/exchanges.py index 6f44358..484f419 100644 --- a/pyEX/refdata/exchanges.py +++ b/pyEX/refdata/exchanges.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _getJson @@ -16,25 +17,13 @@ def exchanges(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('ref-data/market/us/exchanges', token, version, filter) +@wraps(exchanges) def exchangesDF(token='', version='', filter=''): - '''Returns an array of U.S. exchanges. - - https://iexcloud.io/docs/api/#u-s-exchanges - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(exchanges(token, version, filter)) @@ -51,23 +40,11 @@ def internationalExchanges(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('ref-data/exchanges', token, version, filter) +@wraps(internationalExchanges) def internationalExchangesDF(token='', version='', filter=''): - '''Returns an array of U.S. exchanges. - - https://iexcloud.io/docs/api/#international-exchanges - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(internationalExchanges(token, version, filter)) diff --git a/pyEX/refdata/figi.py b/pyEX/refdata/figi.py index a52082a..8e4d88f 100644 --- a/pyEX/refdata/figi.py +++ b/pyEX/refdata/figi.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _getJson, _raiseIfNotStr @@ -14,23 +15,12 @@ def figi(figi_=None, token='', version=''): version (str): API version Returns: - dict: result + dict or DataFrame: result ''' _raiseIfNotStr(figi_) return _getJson('ref-data/figi?figi={}'.format(figi_), token, version, None) +@wraps(figi) def figiDF(figi_=None, token='', version=''): - '''Helper call to convert FIGI to IEX Cloud symbols. Note that due to licensing restrictions we are unable to return the FIGI. - - https://iexcloud.io/docs/api/#figi-mapping - - Args: - figi_ (str): figi to lookup - token (str): Access token - version (str): API version - - Returns: - DataFrame: result - ''' return pd.DataFrame(figi(figi_, token, version)) diff --git a/pyEX/refdata/refdata.py b/pyEX/refdata/refdata.py index 1ec9d07..fd578e6 100644 --- a/pyEX/refdata/refdata.py +++ b/pyEX/refdata/refdata.py @@ -1,6 +1,7 @@ # -*- coding: utf-8 -*- import pandas as pd from deprecation import deprecated +from functools import wraps from ..common import _getJson, _strOrDate, _toDatetime @@ -15,7 +16,7 @@ def corporateActions(date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: date = _strOrDate(date) @@ -23,19 +24,9 @@ def corporateActions(date=None, token='', version='', filter=''): return _getJson('ref-data/daily-list/corporate-actions', token, version, filter) +@wraps(corporateActions) @deprecated(details='Deprecated: IEX Cloud status unkown') def corporateActionsDF(date=None, token='', version='', filter=''): - ''' - - Args: - date (datetime): Effective date - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(corporateActions(date, token, version, filter)) _toDatetime(df) return df @@ -52,7 +43,7 @@ def dividends(date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: date = _strOrDate(date) @@ -60,19 +51,9 @@ def dividends(date=None, token='', version='', filter=''): return _getJson('ref-data/daily-list/dividends', token, version, filter) +@wraps(dividends) @deprecated(details='Deprecated: IEX Cloud status unkown') def dividendsDF(date=None, token='', version='', filter=''): - ''' - - Args: - date (datetime): Effective date - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(dividends(date, token, version, filter)) _toDatetime(df) return df @@ -89,7 +70,7 @@ def nextDayExtDate(date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: date = _strOrDate(date) @@ -97,19 +78,9 @@ def nextDayExtDate(date=None, token='', version='', filter=''): return _getJson('ref-data/daily-list/next-day-ex-date', token, version, filter) +@wraps(nextDayExtDate) @deprecated(details='Deprecated: IEX Cloud status unkown') def nextDayExtDateDF(date=None, token='', version='', filter=''): - ''' - - Args: - date (datetime): Effective date - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(nextDayExtDate(date, token, version, filter)) _toDatetime(df) return df @@ -126,7 +97,7 @@ def directory(date=None, token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' if date: date = _strOrDate(date) @@ -134,19 +105,9 @@ def directory(date=None, token='', version='', filter=''): return _getJson('ref-data/daily-list/symbol-directory', token, version, filter) +@wraps(directory) @deprecated(details='Deprecated: IEX Cloud status unkown') def directoryDF(date=None, token='', version='', filter=''): - ''' - - Args: - date (datetime): Effective date - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - dict: result - ''' df = pd.DataFrame(directory(date, token, version, filter)) _toDatetime(df) return df diff --git a/pyEX/refdata/sectors.py b/pyEX/refdata/sectors.py index df3f5bc..a6f6518 100644 --- a/pyEX/refdata/sectors.py +++ b/pyEX/refdata/sectors.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _getJson @@ -15,24 +16,13 @@ def sectors(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('ref-data/sectors', token, version, filter) +@wraps(sectors) def sectorsDF(token='', version='', filter=''): - '''Returns an array of sectors. - - https://iexcloud.io/docs/api/#sectors - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(sectors(token, version, filter)) @@ -48,22 +38,11 @@ def tags(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame: result ''' return _getJson('ref-data/tags', token, version, filter) +@wraps(tags) def tagsDF(token='', version='', filter=''): - '''Returns an array of tags. - - https://iexcloud.io/docs/api/#tags - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' return pd.DataFrame(tags(token, version, filter)) diff --git a/pyEX/refdata/symbols.py b/pyEX/refdata/symbols.py index 6c3d82e..dd2efe3 100644 --- a/pyEX/refdata/symbols.py +++ b/pyEX/refdata/symbols.py @@ -1,5 +1,6 @@ # -*- coding: utf-8 -*- import pandas as pd +from functools import wraps from ..common import _expire, _getJson, _reindex, _toDatetime, _UTC @@ -16,7 +17,7 @@ def symbols(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame or list: result ''' return _getJson('ref-data/symbols', token, version, filter) @@ -35,7 +36,7 @@ def iexSymbols(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame or list: result ''' return _getJson('ref-data/iex/symbols', token, version, filter) @@ -53,7 +54,7 @@ def mutualFundSymbols(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame or list: result ''' return _getJson('ref-data/mutual-funds/symbols', token, version, filter) @@ -71,7 +72,7 @@ def otcSymbols(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame or list: result ''' return _getJson('ref-data/otc/symbols', token, version, filter) @@ -91,7 +92,7 @@ def internationalSymbols(region='', exchange='', token='', version='', filter='' filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame or list: result ''' if region: return _getJson('ref-data/region/{region}/symbols'.format(region=region), token, version, filter) @@ -112,7 +113,7 @@ def fxSymbols(token='', version=''): version (str): API version Returns: - dict: result + dict or DataFrame or list: result ''' return _getJson('ref-data/fx/symbols', token, version) @@ -130,127 +131,53 @@ def optionsSymbols(token='', version='', filter=''): filter (str): filters: https://iexcloud.io/docs/api/#filter-results Returns: - dict: result + dict or DataFrame or list: result ''' return _getJson('ref-data/options/symbols', token, version, filter) +@wraps(symbols) def symbolsDF(token='', version='', filter=''): - '''This call returns an array of symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - dataframe: result - ''' df = pd.DataFrame(symbols(token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') return df +@wraps(iexSymbols) def iexSymbolsDF(token='', version='', filter=''): - '''This call returns an array of symbols the Investors Exchange supports for trading. - This list is updated daily as of 7:45 a.m. ET. Symbols may be added or removed by the Investors Exchange after the list was produced. - - https://iexcloud.io/docs/api/#iex-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(iexSymbols(token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') return df +@wraps(mutualFundSymbols) def mutualFundSymbolsDF(token='', version='', filter=''): - '''This call returns an array of mutual fund symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#mutual-fund-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(mutualFundSymbols(token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') return df +@wraps(otcSymbols) def otcSymbolsDF(token='', version='', filter=''): - '''This call returns an array of OTC symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#otc-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(otcSymbols(token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') return df +@wraps(internationalSymbols) def internationalSymbolsDF(region='', exchange='', token='', version='', filter=''): - '''This call returns an array of international symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#international-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - region (str): region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 - exchange (str): Case insensitive string of Exchange using IEX Supported Exchanges list - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.DataFrame(internationalSymbols(region, exchange, token, version, filter)) _toDatetime(df) _reindex(df, 'symbol') return df +@wraps(fxSymbols) def fxSymbolsDF(token='', version=''): - '''This call returns a list of supported currencies and currency pairs. - - https://iexcloud.io/docs/api/#fx-symbols - 7am, 9am, UTC daily - - Args: - token (str): Access token - version (str): API version - - Returns: - [DataFrame]: results - ''' fx = fxSymbols(token, version) df1 = pd.DataFrame(fx['currencies']) df2 = pd.DataFrame(fx['pairs']) @@ -258,122 +185,41 @@ def fxSymbolsDF(token='', version=''): return [df1, df2] +@wraps(optionsSymbols) def optionsSymbolsDF(token='', version='', filter=''): - '''This call returns an object keyed by symbol with the value of each symbol being an array of available contract dates. - - https://iexcloud.io/docs/api/#options-symbols - 9:30am ET Tue-Sat - - Args: - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - - Returns: - DataFrame: result - ''' df = pd.io.json.json_normalize(optionsSymbols(token, version, filter)) df = df.T df.columns = ['expirations'] return df +@wraps(symbols) def symbolsList(token='', version=''): - '''This call returns an array of symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - - Returns: - list: result - ''' return [x['symbol'] for x in symbols(token, version, filter='symbol')] +@wraps(iexSymbols) def iexSymbolsList(token='', version=''): - '''This call returns an array of symbols the Investors Exchange supports for trading. - This list is updated daily as of 7:45 a.m. ET. Symbols may be added or removed by the Investors Exchange after the list was produced. - - https://iexcloud.io/docs/api/#iex-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - - Returns: - list: result - ''' return [x['symbol'] for x in iexSymbols(token, version, filter='symbol')] +@wraps(mutualFundSymbols) def mutualFundSymbolsList(token='', version=''): - '''This call returns an array of mutual fund symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#mutual-fund-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - - Returns: - List: result - ''' return [x['symbol'] for x in mutualFundSymbols(token, version, filter='symbol')] +@wraps(otcSymbols) def otcSymbolsList(token='', version=''): - '''This call returns an array of OTC symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#otc-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - token (str): Access token - version (str): API version - - Returns: - list: result - ''' return [x['symbol'] for x in otcSymbols(token, version, filter='symbol')] +@wraps(internationalSymbols) def internationalSymbolsList(region='', exchange='', token='', version=''): - '''This call returns an array of international symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#international-symbols - 8am, 9am, 12pm, 1pm UTC daily - - Args: - region (str): region, 2 letter case insensitive string of country codes using ISO 3166-1 alpha-2 - exchange (str): Case insensitive string of Exchange using IEX Supported Exchanges list - token (str): Access token - version (str): API version - - Returns: - list: result - ''' return [x['symbol'] for x in internationalSymbols(region, exchange, token, version, filter='symbol')] +@wraps(fxSymbols) def fxSymbolsList(token='', version=''): - '''This call returns a list of supported currencies and currency pairs. - - https://iexcloud.io/docs/api/#fx-symbols - 7am, 9am, UTC daily - - Args: - token (str): Access token - version (str): API version - - Returns: - list: result - ''' fx = fxSymbols(token, version) ret = [[], []] for c in fx['currencies']: @@ -383,17 +229,6 @@ def fxSymbolsList(token='', version=''): return ret +@wraps(optionsSymbols) def optionsSymbolsList(token='', version=''): - '''This call returns an object keyed by symbol with the value of each symbol being an array of available contract dates. - - https://iexcloud.io/docs/api/#options-symbols - 9:30am ET Tue-Sat - - Args: - token (str): Access token - version (str): API version - - Returns: - list: result - ''' return [x['symbol'] for x in optionsSymbols(token, version, filter='symbol')] diff --git a/pyEX/stats/stats.py b/pyEX/stats/stats.py index 52d7388..4cf4b17 100644 --- a/pyEX/stats/stats.py +++ b/pyEX/stats/stats.py @@ -19,9 +19,7 @@ def stats(token='', version='', filter=''): return _getJson('stats/intraday', token, version, filter) -wraps(stats) - - +@wraps(stats) def statsDF(token='', version='', filters=''): df = pd.DataFrame(stats(token, version, filter)) _toDatetime(df) @@ -42,9 +40,7 @@ def recent(token='', version='', filter=''): return _getJson('stats/recent', token, version, filter) -wraps(recent) - - +@wraps(recent) def recentDF(token='', version='', filter=''): df = pd.DataFrame(recent(token, version, filter)) _toDatetime(df) @@ -66,9 +62,7 @@ def records(token='', version='', filter=''): return _getJson('stats/records', token, version, filter) -wraps(records) - - +@wraps(records) def recordsDF(token='', version='', filter=''): df = pd.DataFrame(records(token, version, filter)) _toDatetime(df) @@ -98,9 +92,7 @@ def summary(date=None, token='', version='', filter=''): return _getJson('stats/historical', token, version, filter) -wraps(summary) - - +@wraps(summary) def summaryDF(date=None, token='', version='', filter=''): df = pd.DataFrame(summary(date, token, version, filter)) _toDatetime(df) @@ -129,9 +121,7 @@ def daily(date=None, last='', token='', version='', filter=''): return _getJson('stats/historical/daily', token, version, filter) -wraps(daily) - - +@wraps(daily) def dailyDF(date=None, last='', token='', version='', filter=''): df = pd.DataFrame(daily(date, last, token, version, filter)) _toDatetime(df) diff --git a/setup.py b/setup.py index 5c0e879..e60293c 100644 --- a/setup.py +++ b/setup.py @@ -34,7 +34,12 @@ def get_version(file, name='__version__'): 'temporal-cache>=0.1.1', ] -requires_dev = [ +requires_async = requires + [ + 'aiohttp>=3.2', + 'aiohttp-sse-client>=0.2.0', +] + +requires_dev = requires_async + [ 'autopep8>=1.4.1', 'bump2version>=1.0.0', 'flake8>=3.7.8', @@ -43,7 +48,7 @@ def get_version(file, name='__version__'): 'pytest-cov>=2.6.1', 'Sphinx>=1.8.4', 'sphinx-markdown-builder>=0.5.2', -] + requires +] setup( name=name, @@ -70,5 +75,6 @@ def get_version(file, name='__version__'): install_requires=requires, extras_require={ 'dev': requires_dev, + 'async': requires_async, }, ) From 121a26061da5c1267a338b6e04c353d0f834c2a3 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 23 Oct 2020 23:24:49 -0400 Subject: [PATCH 5/6] fix typo --- pyEX/common.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyEX/common.py b/pyEX/common.py index bb86993..98b74d9 100644 --- a/pyEX/common.py +++ b/pyEX/common.py @@ -425,7 +425,7 @@ def _getJsonIEXCloudBase(base_url, url, token='', version='v1', filter=''): def _getJsonIEXCloud(url, token='', version='v1', filter=''): '''for iex cloud''' - return _getJsonIEXCloud(_URL_PREFIX2, url, token, version, filter) + return _getJsonIEXCloudBase(_URL_PREFIX2, url, token, version, filter) async def _getJsonIEXCloudAsyncBase(base_url, url, token='', version='v1', filter=''): From 78f41f1575ff2e7ff8c9b1c12852515684873f00 Mon Sep 17 00:00:00 2001 From: Tim Paine Date: Fri, 23 Oct 2020 23:40:44 -0400 Subject: [PATCH 6/6] fix version mismatch on sandbox --- pyEX/__init__.py | 1 + pyEX/client.py | 4 ++++ pyEX/common.py | 40 ++++++++++++++++++++-------------------- 3 files changed, 25 insertions(+), 20 deletions(-) diff --git a/pyEX/__init__.py b/pyEX/__init__.py index d16074b..5ef2ca5 100644 --- a/pyEX/__init__.py +++ b/pyEX/__init__.py @@ -37,6 +37,7 @@ from .marketdata.http import (tops, topsAsync, topsDF, # noqa: F401 last, lastAsync, lastDF, # noqa: F401 deep, deepAsync, deepDF, # noqa: F401 + hist, histAsync, histDF, # noqa: F401 trades, tradesAsync, tradesDF, # noqa: F401 auction, auctionAsync, auctionDF, # noqa: F401 book as deepBook, bookAsync as deepBookAsync, bookDF as deepBookDF, # noqa: F401 diff --git a/pyEX/client.py b/pyEX/client.py index 6038c22..9bde04c 100644 --- a/pyEX/client.py +++ b/pyEX/client.py @@ -27,6 +27,7 @@ from .marketdata.http import tops, topsAsync, topsDF, \ last, lastAsync, lastDF, \ deep, deepAsync, deepDF, \ + hist, histAsync, histDF, \ trades, tradesAsync, tradesDF, \ auction, auctionAsync, auctionDF, \ book as deepBook, bookAsync as deepBookAsync, bookDF as deepBookDF, \ @@ -430,6 +431,9 @@ ('deep', deep), ('deepAsync', deepAsync), ('deepDF', deepDF), + ('hist', hist), + ('histAsync', histAsync), + ('histDF', histDF), ('auction', auction), ('auctionAsync', auctionAsync), ('auctionDF', auctionDF), diff --git a/pyEX/common.py b/pyEX/common.py index 98b74d9..9579565 100644 --- a/pyEX/common.py +++ b/pyEX/common.py @@ -411,7 +411,7 @@ def _getJsonOrig(url): raise PyEXception('Old IEX API is deprecated. For a free API token, sign up at https://iexcloud.io') -def _getJsonIEXCloudBase(base_url, url, token='', version='v1', filter=''): +def _getJsonIEXCloudBase(base_url, url, token='', version='stable', filter=''): '''for iex cloud''' url = base_url.format(version=version) + url params = {'token': token} @@ -423,12 +423,12 @@ def _getJsonIEXCloudBase(base_url, url, token='', version='v1', filter=''): raise PyEXception('Response %d - ' % resp.status_code, resp.text) -def _getJsonIEXCloud(url, token='', version='v1', filter=''): +def _getJsonIEXCloud(url, token='', version='stable', filter=''): '''for iex cloud''' return _getJsonIEXCloudBase(_URL_PREFIX2, url, token, version, filter) -async def _getJsonIEXCloudAsyncBase(base_url, url, token='', version='v1', filter=''): +async def _getJsonIEXCloudAsyncBase(base_url, url, token='', version='stable', filter=''): '''for iex cloud''' import aiohttp url = _URL_PREFIX2.format(version=version) + url @@ -442,12 +442,12 @@ async def _getJsonIEXCloudAsyncBase(base_url, url, token='', version='v1', filte raise PyEXception('Response %d - ' % resp.status, await resp.text()) -async def _getJsonIEXCloudAsync(url, token='', version='v1', filter=''): +async def _getJsonIEXCloudAsync(url, token='', version='stable', filter=''): '''for iex cloud''' return await _getJsonIEXCloudAsyncBase(_URL_PREFIX2, url, token, version, filter) -def _postJsonIEXCloudBase(base_url, url, data=None, json=None, token='', version='v1', token_in_params=True): +def _postJsonIEXCloudBase(base_url, url, data=None, json=None, token='', version='stable', token_in_params=True): '''for iex cloud''' url = base_url.format(version=version) + url if token_in_params: @@ -460,12 +460,12 @@ def _postJsonIEXCloudBase(base_url, url, data=None, json=None, token='', version raise PyEXception('Response %d - ' % resp.status_code, resp.text) -def _postJsonIEXCloud(url, data=None, json=None, token='', version='v1', token_in_params=True): +def _postJsonIEXCloud(url, data=None, json=None, token='', version='stable', token_in_params=True): '''for iex cloud''' return _postJsonIEXCloudBase(_URL_PREFIX2, data, json, token, version, token_in_params) -async def _postJsonIEXCloudAsyncBase(base_url, url, data=None, json=None, token='', version='v1', filter='', token_in_params=True): +async def _postJsonIEXCloudAsyncBase(base_url, url, data=None, json=None, token='', version='stable', filter='', token_in_params=True): '''for iex cloud''' import aiohttp url = base_url.format(version=version) + url @@ -481,12 +481,12 @@ async def _postJsonIEXCloudAsyncBase(base_url, url, data=None, json=None, token= raise PyEXception('Response %d - ' % resp.status, await resp.text()) -async def _postJsonIEXCloudAsync(url, data=None, json=None, token='', version='v1', filter='', token_in_params=True): +async def _postJsonIEXCloudAsync(url, data=None, json=None, token='', version='stable', filter='', token_in_params=True): '''for iex cloud''' return await _postJsonIEXCloudAsyncBase(_URL_PREFIX2, url, data, json, token, version, filter, token_in_params) -def _deleteJsonIEXCloudBase(base_url, url, token='', version='v1'): +def _deleteJsonIEXCloudBase(base_url, url, token='', version='stable'): '''for iex cloud''' url = base_url.format(version=version) + url params = {'token': token} @@ -496,12 +496,12 @@ def _deleteJsonIEXCloudBase(base_url, url, token='', version='v1'): raise PyEXception('Response %d - ' % resp.status_code, resp.text) -def _deleteJsonIEXCloud(url, token='', version='v1'): +def _deleteJsonIEXCloud(url, token='', version='stable'): '''for iex cloud''' return _deleteJsonIEXCloud(_URL_PREFIX2, url, token, version) -async def _deleteJsonIEXCloudAsyncBase(url, token='', version='v1'): +async def _deleteJsonIEXCloudAsyncBase(url, token='', version='stable'): '''for iex cloud''' import aiohttp url = _URL_PREFIX2.format(version=version) + url @@ -514,29 +514,29 @@ async def _deleteJsonIEXCloudAsyncBase(url, token='', version='v1'): raise PyEXception('Response %d - ' % resp.status, await resp.text()) -async def _deleteJsonIEXCloudAsync(url, token='', version='v1'): +async def _deleteJsonIEXCloudAsync(url, token='', version='stable'): '''for iex cloud''' return await _deleteJsonIEXCloudAsyncBase(_URL_PREFIX2, url, token, version) -def _getJsonIEXCloudSandbox(url, token='', version='v1', filter=''): +def _getJsonIEXCloudSandbox(url, token='', version='stable', filter=''): '''for iex cloud''' - return _getJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, token, version, filter) + return _getJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, token, 'stable', filter) -async def _getJsonIEXCloudSandboxAsync(url, token='', version='v1', filter=''): +async def _getJsonIEXCloudSandboxAsync(url, token='', version='stable', filter=''): '''for iex cloud''' - return await _getJsonIEXCloudAsyncBase(_URL_PREFIX2_SANDBOX, url, token, version, filter) + return await _getJsonIEXCloudAsyncBase(_URL_PREFIX2_SANDBOX, url, token, 'stable', filter) -def _postJsonIEXCloudSandbox(url, data=None, json=None, token='', version='v1', token_in_params=True): +def _postJsonIEXCloudSandbox(url, data=None, json=None, token='', version='stable', token_in_params=True): '''for iex cloud''' - return _postJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, data, json, token, version, token_in_params) + return _postJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, data, json, token, 'stable', token_in_params) -def _deleteJsonIEXCloudSandbox(url, token='', version='v1'): +def _deleteJsonIEXCloudSandbox(url, token='', version='stable'): '''for iex cloud''' - return _deleteJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, token, version) + return _deleteJsonIEXCloudBase(_URL_PREFIX2_SANDBOX, url, token, 'stable') def _wsURL(url):