From fa7082b96aaa287ff6805eb3d0f01473ce532060 Mon Sep 17 00:00:00 2001 From: Kevin Johnson Date: Tue, 11 Jun 2024 13:54:41 -0700 Subject: [PATCH] BUG MAINT TST #779 pvi update --- README.md | 2 +- pandas_ta/overlap/sma.py | 2 +- pandas_ta/overlap/ssf3.py | 2 +- pandas_ta/overlap/wma.py | 2 +- pandas_ta/trend/alphatrend.py | 2 +- pandas_ta/trend/ht_trendline.py | 2 +- pandas_ta/trend/trendflex.py | 2 +- pandas_ta/volatility/atrts.py | 2 +- pandas_ta/volume/pvi.py | 8 +++++--- setup.py | 2 +- tests/conftest.py | 2 +- tests/test_studies.py | 6 +++--- 12 files changed, 18 insertions(+), 16 deletions(-) diff --git a/README.md b/README.md index d23df319..18b8c137 100644 --- a/README.md +++ b/README.md @@ -204,7 +204,7 @@ $ pip install pandas_ta[full] ## Development Version -The _development_ version, _0.4.13b_, includes _numerous_ bug fixes, speed improvements and better documentation since release, _0.3.14b_. +The _development_ version, _0.4.14b_, includes _numerous_ bug fixes, speed improvements and better documentation since release, _0.3.14b_. ```sh $ pip install -U git+https://github.com/twopirllc/pandas-ta.git@development diff --git a/pandas_ta/overlap/sma.py b/pandas_ta/overlap/sma.py index fadc00ed..62f24dea 100644 --- a/pandas_ta/overlap/sma.py +++ b/pandas_ta/overlap/sma.py @@ -68,7 +68,7 @@ def sma( sma = SMA(close, length) else: np_close = close.to_numpy() - sma = np_sma(np_close, length) + sma = nb_sma(np_close, length) sma = Series(sma, index=close.index) # Offset diff --git a/pandas_ta/overlap/ssf3.py b/pandas_ta/overlap/ssf3.py index 850a59bc..070d18f4 100644 --- a/pandas_ta/overlap/ssf3.py +++ b/pandas_ta/overlap/ssf3.py @@ -79,7 +79,7 @@ def ssf3( # Calculate np_close = close.to_numpy() - ssf = np_ssf3(np_close, length, pi, sqrt3) + ssf = nb_ssf3(np_close, length, pi, sqrt3) ssf = Series(ssf, index=close.index) # Offset diff --git a/pandas_ta/overlap/wma.py b/pandas_ta/overlap/wma.py index 7ad9e6e7..ac28441c 100644 --- a/pandas_ta/overlap/wma.py +++ b/pandas_ta/overlap/wma.py @@ -77,7 +77,7 @@ def wma( wma = WMA(close, length) else: np_close = close.to_numpy() - wma_ = np_wma(np_close, length, asc, True) + wma_ = nb_wma(np_close, length, asc, True) wma = Series(wma_, index=close.index) # Offset diff --git a/pandas_ta/trend/alphatrend.py b/pandas_ta/trend/alphatrend.py index 3cca99e1..fe2aad52 100644 --- a/pandas_ta/trend/alphatrend.py +++ b/pandas_ta/trend/alphatrend.py @@ -128,7 +128,7 @@ def alphatrend( np_upper_atr, np_lower_atr = upper_atr.to_numpy(), lower_atr.to_numpy() - at = np_alpha(np_lower_atr, np_upper_atr, momo.to_numpy() >= threshold) + at = nb_alpha(np_lower_atr, np_upper_atr, momo.to_numpy() >= threshold) at = Series(at, index=close.index) atl = at.shift(lag) diff --git a/pandas_ta/trend/ht_trendline.py b/pandas_ta/trend/ht_trendline.py index 6b2bd1d8..8828705c 100644 --- a/pandas_ta/trend/ht_trendline.py +++ b/pandas_ta/trend/ht_trendline.py @@ -127,7 +127,7 @@ def ht_trendline( tl = HT_TRENDLINE(close) else: np_close = close.to_numpy() - np_tl = np_ht_trendline(np_close) + np_tl = nb_ht_trendline(np_close) if prenan > 0: np_tl[:prenan] = nan diff --git a/pandas_ta/trend/trendflex.py b/pandas_ta/trend/trendflex.py index 302db52e..951a04e7 100644 --- a/pandas_ta/trend/trendflex.py +++ b/pandas_ta/trend/trendflex.py @@ -93,7 +93,7 @@ def trendflex( # Calculate np_close = close.to_numpy() - result = np_trendflex(np_close, length, smooth, alpha, pi, sqrt2) + result = nb_trendflex(np_close, length, smooth, alpha, pi, sqrt2) result[:length] = nan result = Series(result, index=close.index) diff --git a/pandas_ta/volatility/atrts.py b/pandas_ta/volatility/atrts.py index 4c650ef5..44fa39b4 100644 --- a/pandas_ta/volatility/atrts.py +++ b/pandas_ta/volatility/atrts.py @@ -123,7 +123,7 @@ def atrts( ma_ = _ma(mamode, close, length=ma_length, talib=mode_tal) np_close, np_ma, np_atr = close.to_numpy(), ma_.to_numpy(), atr_.to_numpy() - np_atrts_, _, _ = np_atrts(np_close, np_ma, np_atr, length, ma_length) + np_atrts_, _, _ = nb_atrts(np_close, np_ma, np_atr, length, ma_length) percent = kwargs.pop("percent", False) if percent: diff --git a/pandas_ta/volume/pvi.py b/pandas_ta/volume/pvi.py index 74caa626..7a48df0e 100644 --- a/pandas_ta/volume/pvi.py +++ b/pandas_ta/volume/pvi.py @@ -14,7 +14,7 @@ @njit(cache=True) -def np_pvi(np_close, np_volume, initial): +def nb_pvi(np_close, np_volume, initial): result = zeros_like(np_close, dtype=float64) result[0] = initial @@ -77,7 +77,7 @@ def pvi( # Calculate np_close, np_volume = close.to_numpy(), volume.to_numpy() - _pvi = np_pvi(np_close, np_volume, initial) + _pvi = nb_pvi(np_close, np_volume, initial) pvi = Series(_pvi, index=close.index) pvi_ma = ma(mamode, pvi, length=length) @@ -102,7 +102,9 @@ def pvi( pvi_ma.name = f"PVI{_props}" pvi.category = pvi_ma.category = "volume" - data = { pvi.name: pvi, pvi_ma.name: pvi_ma } + data = { pvi.name: pvi} + if np_close.size > length + 1: + data[pvi_ma.name] = pvi_ma df = DataFrame(data, index=close.index) # Name and Category diff --git a/setup.py b/setup.py index 51b42492..e69cad48 100644 --- a/setup.py +++ b/setup.py @@ -19,7 +19,7 @@ "pandas_ta.volatility", "pandas_ta.volume" ], - version=".".join(("0", "4", "13b")), + version=".".join(("0", "4", "14b")), description=long_description, long_description=long_description, author="Kevin Johnson", diff --git a/tests/conftest.py b/tests/conftest.py index 301fe42e..67829934 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -9,7 +9,7 @@ from pandas import read_csv -TEST_ROWS = 300 +TEST_ROWS = 200 TEST_CSV = f"data/SPY_D.csv" BEEP = False diff --git a/tests/test_studies.py b/tests/test_studies.py index 0256acde..c40fb192 100644 --- a/tests/test_studies.py +++ b/tests/test_studies.py @@ -9,7 +9,7 @@ [pytest.param(ta.CommonStudy, id="common"), pytest.param(ta.AllStudy, id="all")] # +/- when adding/removing indicators -ALL_COLUMNS = 325 +ALL_COLUMNS = 323 def test_all_study_props(all_study): @@ -33,7 +33,7 @@ def test_common_study_props(common_study): @pytest.mark.parametrize("category,columns", [ ("candles", 70), ("cycles", 2), ("momentum", 78), ("overlap", 56), ("performance", 2), ("statistics", 16), ("transform", 5), ("trend", 31), - ("volatility", 36), ("volume", 29), + ("volatility", 36), ("volume", 27), pytest.param(ta.AllStudy, ALL_COLUMNS, id=f"all-{ALL_COLUMNS}"), pytest.param(ta.CommonStudy, 5, id="common-5"), ]) @@ -89,7 +89,7 @@ def test_study_custom_e_talib(df, custom_study_e, talib): @pytest.mark.parametrize("talib", [False, True]) def test_study_all_multirun_talib(df, all_study, talib): - new_columns = 619 # +/- when adding/removing indicators + new_columns = 613 # +/- when adding/removing indicators initial_columns = df.shape[1] df.ta.study(all_study, length=10, cores=0, talib=talib) df.ta.study(all_study, length=50, cores=0, talib=talib)