From fc4a04af261c6e457979eba0d1304daf1a0489d6 Mon Sep 17 00:00:00 2001 From: Kevin Johnson Date: Fri, 15 Oct 2021 12:39:15 -0700 Subject: [PATCH] MAINT minor refactoring ENH sample json strategy --- examples/simple_strategy.json | 13 +++++++++++++ pandas_ta/candles/cdl_pattern.py | 11 ++++++++++- pandas_ta/core.py | 2 +- pandas_ta/utils/_stats.py | 1 - pandas_ta/utils/_time.py | 4 ++-- pandas_ta/utils/data/processes.py | 4 ++-- strategy.json | 0 tests/config.py | 2 +- 8 files changed, 29 insertions(+), 8 deletions(-) create mode 100644 examples/simple_strategy.json create mode 100644 strategy.json diff --git a/examples/simple_strategy.json b/examples/simple_strategy.json new file mode 100644 index 0000000..43402d0 --- /dev/null +++ b/examples/simple_strategy.json @@ -0,0 +1,13 @@ +{ + "name": "Sample JSON Strategy", + "description": "Sample JSON Strategy", + "ta": [ + {"kind": "ema", "length": 8, "sma": true}, + {"kind": "ema", "length": 21, "talib": true}, + {"kind": "sma", "length": 50, "talib": true}, + {"kind": "sma", "length": 200, "talib": true}, + {"kind": "sma", "close": "volume", "length": 20, "talib": true}, + {"kind": "rsi", "talib": true}, + {"kind": "obv"} + ] +} \ No newline at end of file diff --git a/pandas_ta/candles/cdl_pattern.py b/pandas_ta/candles/cdl_pattern.py index 954d831..f806c35 100644 --- a/pandas_ta/candles/cdl_pattern.py +++ b/pandas_ta/candles/cdl_pattern.py @@ -23,7 +23,16 @@ ALL_PATTERNS = [ ] -def cdl_pattern(open_, high, low, close, name: Union[str, Sequence[str]]="all", scalar=None, offset=None, **kwargs) -> DataFrame: +def cdl_pattern( + open_, + high, + low, + close, + name: Union[str, Sequence[str]]="all", + scalar=None, + offset=None, + **kwargs + ) -> DataFrame: """TA Lib Candle Patterns A wrapper around all TA Lib's candle patterns. diff --git a/pandas_ta/core.py b/pandas_ta/core.py index 71f8c37..cd094ad 100644 --- a/pandas_ta/core.py +++ b/pandas_ta/core.py @@ -53,7 +53,7 @@ class Strategy: name: str # = None # Required. ta: List = field(default_factory=list) # Required. # Helpful. More descriptive version or notes or w/e. - description: str = "TA Description" + description: str = "" # Optional. Gets Exchange Time and Local Time execution time created: str = get_time(to_string=True) diff --git a/pandas_ta/utils/_stats.py b/pandas_ta/utils/_stats.py index 4bbfc4d..f565957 100644 --- a/pandas_ta/utils/_stats.py +++ b/pandas_ta/utils/_stats.py @@ -70,7 +70,6 @@ def inv_norm(value: Tuple[float, int]) -> Tuple[float, None]: If the user has package "statsmodels" installed, the method will call and return norm().ppf(value) - Source: https://github.com/scipy/scipy/blob/701ffcc8a6f04509d115aac5e5681c538b5265a2/scipy/special/cephes/ndtri.c """ diff --git a/pandas_ta/utils/_time.py b/pandas_ta/utils/_time.py index 611e5a2..76160be 100644 --- a/pandas_ta/utils/_time.py +++ b/pandas_ta/utils/_time.py @@ -97,8 +97,8 @@ def total_time(df: DataFrame, tf: str = "years") -> float: def to_utc(df: DataFrame) -> DataFrame: - """Either localizes the DataFrame Index to UTC or it applies - tz_convert to set the Index to UTC. + """Either localizes the DataFrame Index to UTC or it applies tz_convert to + set the Index to UTC. """ if not df.empty: try: diff --git a/pandas_ta/utils/data/processes.py b/pandas_ta/utils/data/processes.py index 6a446c5..132ac12 100644 --- a/pandas_ta/utils/data/processes.py +++ b/pandas_ta/utils/data/processes.py @@ -36,8 +36,8 @@ class sample(object): This is a Numpy and stochastics package wrapper Class that easily creates stochastic process realization with or without stochastic noise. - To get the most out of sample(), install the _stochastic_ - package: pip install stochastic. + To get the most out of sample(), install the 'stochastic' package: + $ pip install stochastic The following stochastic package noise and processes have been implemented: * Noise[9]: Blue "b", Brownian "br, Fractal Gaussian "fg", Gaussian "g", diff --git a/strategy.json b/strategy.json new file mode 100644 index 0000000..e69de29 diff --git a/tests/config.py b/tests/config.py index 6769089..29b3f6c 100644 --- a/tests/config.py +++ b/tests/config.py @@ -18,7 +18,7 @@ sample_data = read_csv( ) sample_data.set_index(DatetimeIndex(sample_data["date"]), inplace=True, drop=True) sample_data.drop("date", axis=1, inplace=True) -sample_data = sample_data[:200] +# sample_data = sample_data[:200] def error_analysis(df, kind, msg, icon=INFO, newline=True):