From 5d5c426fd774a44113ea519e245aa915507fd55d Mon Sep 17 00:00:00 2001 From: timkpaine Date: Thu, 22 Apr 2021 23:58:49 -0400 Subject: [PATCH] fixes #243 --- pyEX/client.py | 4 ++++ pyEX/refdata/__init__.py | 5 +++-- pyEX/refdata/isin.py | 42 +++++++++++++++++++++++++++++++++++ pyEX/refdata/ric.py | 42 +++++++++++++++++++++++++++++++++++ pyEX/refdata/symbols.py | 30 ------------------------- pyEX/tests/test_api.py | 2 ++ pyEX/tests/test_api_client.py | 2 ++ 7 files changed, 95 insertions(+), 32 deletions(-) create mode 100644 pyEX/refdata/isin.py create mode 100644 pyEX/refdata/ric.py diff --git a/pyEX/client.py b/pyEX/client.py index b33a0d8..888cb25 100644 --- a/pyEX/client.py +++ b/pyEX/client.py @@ -201,6 +201,8 @@ otcSymbolsList, refDividends, refDividendsDF, + ricLookup, + ricLookupDF, search, searchDF, sectors, @@ -841,6 +843,8 @@ ("cryptoSymbolsList", cryptoSymbolsList), ("isinLookup", isinLookup), ("isinLookupDF", isinLookupDF), + ("ricLookup", ricLookup), + ("ricLookupDF", ricLookupDF), ("corporateActions", corporateActions), ("corporateActionsDF", corporateActionsDF), ("refDividends", refDividends), diff --git a/pyEX/refdata/__init__.py b/pyEX/refdata/__init__.py index 780e0c0..6cad34d 100644 --- a/pyEX/refdata/__init__.py +++ b/pyEX/refdata/__init__.py @@ -13,10 +13,13 @@ internationalExchangesDF, ) from .figi import figi, figiDF +from .isin import isinLookup, isinLookupDF from .refdata import corporateActions, corporateActionsDF, directory, directoryDF from .refdata import dividends as refDividends from .refdata import dividendsDF as refDividendsDF from .refdata import nextDayExtDate, nextDayExtDateDF +from .ric import ricLookup, ricLookupDF + from .search import search, searchDF from .sectors import sectors, sectorsDF, tags, tagsDF from .symbols import ( @@ -32,8 +35,6 @@ internationalSymbols, internationalSymbolsDF, internationalSymbolsList, - isinLookup, - isinLookupDF, mutualFundSymbols, mutualFundSymbolsDF, mutualFundSymbolsList, diff --git a/pyEX/refdata/isin.py b/pyEX/refdata/isin.py new file mode 100644 index 0000000..3736e34 --- /dev/null +++ b/pyEX/refdata/isin.py @@ -0,0 +1,42 @@ +# ***************************************************************************** +# +# Copyright (c) 2021, the pyEX authors. +# +# This file is part of the pyEX library, distributed under the terms of +# the Apache License 2.0. The full license can be found in the LICENSE file. +# +from functools import wraps + +import pandas as pd + +from ..common import _get + + +def isinLookup(isin, token="", version="stable", filter="", format="json"): + """This call converts an ISIN to an iex symbol + + https://iexcloud.io/docs/api/#isin-mapping + 8am, 9am, 12pm, 1pm UTC daily + + Args: + isin (str): isin to lookup + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results + format (str): return format, defaults to json + + Returns: + dict or DataFrame or list: result + """ + return _get( + "ref-data/isin?isin={}".format(isin), + token=token, + version=version, + filter=filter, + format=format, + ) + + +@wraps(isinLookup) +def isinLookupDF(*args, **kwargs): + return pd.DataFrame(isinLookup(*args, **kwargs)) diff --git a/pyEX/refdata/ric.py b/pyEX/refdata/ric.py new file mode 100644 index 0000000..6e4ab19 --- /dev/null +++ b/pyEX/refdata/ric.py @@ -0,0 +1,42 @@ +# ***************************************************************************** +# +# Copyright (c) 2021, the pyEX authors. +# +# This file is part of the pyEX library, distributed under the terms of +# the Apache License 2.0. The full license can be found in the LICENSE file. +# +from functools import wraps + +import pandas as pd + +from ..common import _get + + +def ricLookup(ric, token="", version="stable", filter="", format="json"): + """This call converts a RIC to an iex symbol + + https://iexcloud.io/docs/api/#ric-mapping + 8am, 9am, 12pm, 1pm UTC daily + + Args: + ric (str): ric to lookup + token (str): Access token + version (str): API version + filter (str): filters: https://iexcloud.io/docs/api/#filter-results + format (str): return format, defaults to json + + Returns: + dict or DataFrame or list: result + """ + return _get( + "ref-data/ric?ric={}".format(ric), + token=token, + version=version, + filter=filter, + format=format, + ) + + +@wraps(ricLookup) +def ricLookupDF(*args, **kwargs): + return pd.DataFrame(ricLookup(*args, **kwargs)) diff --git a/pyEX/refdata/symbols.py b/pyEX/refdata/symbols.py index 277f687..b40e190 100644 --- a/pyEX/refdata/symbols.py +++ b/pyEX/refdata/symbols.py @@ -358,33 +358,3 @@ def optionsSymbolsList(*args, **kwargs): def cryptoSymbolsList(*args, **kwargs): kwargs["filter"] = "symbol" return sorted([x["symbol"] for x in cryptoSymbols(*args, **kwargs)]) - - -def isinLookup(isin, token="", version="stable", filter="", format="json"): - """This call returns an array of symbols that IEX Cloud supports for API calls. - - https://iexcloud.io/docs/api/#isin-mapping - 8am, 9am, 12pm, 1pm UTC daily - - Args: - isin (str): isin to lookup - token (str): Access token - version (str): API version - filter (str): filters: https://iexcloud.io/docs/api/#filter-results - format (str): return format, defaults to json - - Returns: - dict or DataFrame or list: result - """ - return _get( - "ref-data/isin?isin={}".format(isin), - token=token, - version=version, - filter=filter, - format=format, - ) - - -@wraps(isinLookup) -def isinLookupDF(*args, **kwargs): - return pd.DataFrame(isinLookup(*args, **kwargs)) diff --git a/pyEX/tests/test_api.py b/pyEX/tests/test_api.py index f3a8459..a561b20 100644 --- a/pyEX/tests/test_api.py +++ b/pyEX/tests/test_api.py @@ -548,6 +548,8 @@ def test_all(self): "returnOfCapital", "returnOfCapitalDF", "returns", + "ricLookup", + "ricLookupDF", "rightToPurchase", "rightToPurchaseDF", "rightsIssue", diff --git a/pyEX/tests/test_api_client.py b/pyEX/tests/test_api_client.py index 3a3985b..22aa106 100644 --- a/pyEX/tests/test_api_client.py +++ b/pyEX/tests/test_api_client.py @@ -57,6 +57,8 @@ def test_all_refdata(self): "cryptoSymbolsList", "isinLookup", "isinLookupDF", + "ricLookup", + "ricLookupDF", "corporateActions", "corporateActionsDF", "refDividends",