From 246ea48281ca793618342de2473b918b0b88cd20 Mon Sep 17 00:00:00 2001 From: David Brazda Date: Fri, 18 Oct 2024 12:37:33 +0200 Subject: [PATCH] fix --- setup.py | 2 +- ttools/vbtindicators.py | 17 +++++------------ 2 files changed, 6 insertions(+), 13 deletions(-) diff --git a/setup.py b/setup.py index b036bd9..9785130 100644 --- a/setup.py +++ b/setup.py @@ -2,7 +2,7 @@ from setuptools import setup, find_packages setup( name='ttools', - version='0.2.6', + version='0.2.7', packages=find_packages(), install_requires=[ 'vectorbtpro', diff --git a/ttools/vbtindicators.py b/ttools/vbtindicators.py index 14f8bf4..3ccefff 100644 --- a/ttools/vbtindicators.py +++ b/ttools/vbtindicators.py @@ -80,25 +80,18 @@ def register_custom_inds(indicator_name: str = None, if_exists: str ="skip"): raise ValueError(f"Indicator '{indicator_name}' not found") else: for var_name, var_value in globals().items(): - if var_name.startswith("IND_") and isinstance(var_value, vbt.IndicatorFactory): + if var_name.startswith("IND_"): vbt.IF.register_custom_indicator(var_value, location="ttools", if_exists=if_exists) def deregister_custom_inds(indicator_name: str = None): """Deregister a custom indicator or all custom indicators. - If `indicator_name` is provided, only the indicator with that name is registered. - Otherwise, all indicators are registered - they are the ones starting with "IND_" . + If `indicator_name` is provided, only the indicator with that name is deregistered. + Otherwise, all ttools indicators are deregistered. This function does not have an `if_exists` argument. """ if indicator_name is not None: - var_name = f"IND_{indicator_name}" - var_value = globals().get(var_name) - if var_value is not None and isinstance(var_value, vbt.IndicatorFactory): - vbt.IF.deregister_custom_indicator(var_value, location="ttools") - else: - raise ValueError(f"Indicator '{indicator_name}' not found") + vbt.IF.deregister_custom_indicator(indicator_name, location="ttools") else: - for var_name, var_value in globals().items(): - if var_name.startswith("IND_") and isinstance(var_value, vbt.IndicatorFactory): - vbt.IF.deregister_custom_indicator(var_value, location="ttools") \ No newline at end of file + vbt.IF.deregister_custom_indicator(location="ttools") \ No newline at end of file