diff --git a/README.md b/README.md index a817ef12..0aafd65a 100644 --- a/README.md +++ b/README.md @@ -112,7 +112,7 @@ $ pip install pandas_ta Latest Version -------------- -Best choice! Version: *0.3.13b* +Best choice! Version: *0.3.14b* * Includes all fixes and updates between **pypi** and what is covered in this README. ```sh $ pip install -U git+https://github.com/twopirllc/pandas-ta diff --git a/pandas_ta/custom.py b/pandas_ta/custom.py index 18542491..4af5cc5f 100644 --- a/pandas_ta/custom.py +++ b/pandas_ta/custom.py @@ -2,11 +2,12 @@ import importlib import os import sys +import types + from os.path import abspath, join, exists, basename, splitext from glob import glob -import types + import pandas_ta -import pandas as pd from pandas_ta import AnalysisIndicators @@ -86,7 +87,7 @@ def import_dir(path, verbose=True): return # list the contents of the directory - dirs = glob(abspath(join(path, '*'))) + dirs = glob(abspath(join(path, "*"))) # traverse full directory, importing all modules found there for d in dirs: @@ -99,7 +100,7 @@ def import_dir(path, verbose=True): continue # for each module found in that category (directory)... - for module in glob(abspath(join(path, dirname, '*.py'))): + for module in glob(abspath(join(path, dirname, "*.py"))): module_name = splitext(basename(module))[0] # ensure that the supplied path is included in our python path @@ -111,13 +112,13 @@ def import_dir(path, verbose=True): # figure out which of the modules functions to bind to pandas_ta fcn_callable = module_functions.get(module_name, None) - fcn_method_callable = module_functions.get(module_name + "_method", None) + fcn_method_callable = module_functions.get(f"{module_name}_method", None) if fcn_callable == None: print(f"[X] Unable to find a function named '{module_name}' in the module '{module_name}.py'.") continue if fcn_method_callable == None: - missing_method = module_name + "_method" + missing_method = f"{module_name}_method" print(f"[X] Unable to find a method function named '{missing_method}' in the module '{module_name}.py'.") continue @@ -145,7 +146,7 @@ def import_dir(path, verbose=True): If you at some late point would like to push them into the pandas_ta library you can do so very easily by following the step by step instruction here -https://github.com/twopirllc/pandas-ta/issues/264. +https://github.com/twopirllc/pandas-ta/issues/355. A brief example of usage: @@ -160,8 +161,8 @@ def import_dir(path, verbose=True): >>> import os >>> from os.path import abspath, join, expanduser >>> from pandas_ta.custom import create_dir, import_dir ->>> my_dir = abspath(join(expanduser("~"), "my_indicators")) ->>> create_dir(my_dir) +>>> ta_dir = abspath(join(expanduser("~"), "my_indicators")) +>>> create_dir(ta_dir) 3. You can now create your own custom indicator e.g. by copying existing ones from pandas_ta core module and modifying them. @@ -194,14 +195,14 @@ def import_dir(path, verbose=True): 4. We can now dynamically load all our custom indicators located in our designated indicators directory like this: ->>> import_dir(my_dir) +>>> import_dir(ta_dir) If your custom indicator(s) loaded succesfully then it should behave exactly like all other native indicators in pandas_ta, including help functions. """ -def load_indicator_module(module_name): +def load_indicator_module(name): """ Helper function to (re)load an indicator module. @@ -215,9 +216,9 @@ def load_indicator_module(module_name): """ # load module try: - module = importlib.import_module(module_name) + module = importlib.import_module(name) except Exception as ex: - print(f"[X] An error occurred when attempting to load module {module_name}: {ex}") + print(f"[X] An error occurred when attempting to load module {name}: {ex}") sys.exit(1) # reload to refresh previously loaded module diff --git a/pandas_ta/utils/_core.py b/pandas_ta/utils/_core.py index d4a78835..bcb269c9 100644 --- a/pandas_ta/utils/_core.py +++ b/pandas_ta/utils/_core.py @@ -5,8 +5,8 @@ from numpy import argmax, argmin from pandas import DataFrame, Series -from pandas_ta import Imports from pandas.api.types import is_datetime64_any_dtype +from pandas_ta import Imports def _camelCase2Title(x: str): diff --git a/setup.py b/setup.py index beacf37c..0dc65944 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "pandas_ta.volatility", "pandas_ta.volume" ], - version=".".join(("0", "3", "13b")), + version=".".join(("0", "3", "14b")), description=long_description, long_description=long_description, author="Kevin Johnson",