From 8a550f75faf7848d76f6cadd64f28480b370e54a Mon Sep 17 00:00:00 2001 From: DongGeon Lee Date: Sat, 4 May 2024 17:25:23 +0900 Subject: [PATCH] feat: Add `condense()` on all supported indicators (#377) --- pyproject.toml | 2 +- requirements.txt | 2 +- stock_indicators/_cslib/__init__.py | 2 ++ stock_indicators/indicators/adl.py | 3 ++- stock_indicators/indicators/adx.py | 4 ++-- stock_indicators/indicators/alligator.py | 4 ++-- stock_indicators/indicators/alma.py | 4 ++-- stock_indicators/indicators/aroon.py | 4 ++-- stock_indicators/indicators/atr.py | 4 ++-- stock_indicators/indicators/atr_stop.py | 4 ++-- stock_indicators/indicators/awesome.py | 4 ++-- stock_indicators/indicators/beta.py | 4 ++-- .../indicators/bollinger_bands.py | 4 ++-- stock_indicators/indicators/bop.py | 4 ++-- stock_indicators/indicators/cci.py | 4 ++-- .../indicators/chaikin_oscillator.py | 4 ++-- stock_indicators/indicators/chandelier.py | 4 ++-- stock_indicators/indicators/chop.py | 4 ++-- stock_indicators/indicators/cmf.py | 4 ++-- stock_indicators/indicators/cmo.py | 4 ++-- stock_indicators/indicators/common/candles.py | 18 +++++--------- stock_indicators/indicators/common/helpers.py | 24 +++++++++++++++---- stock_indicators/indicators/connors_rsi.py | 4 ++-- stock_indicators/indicators/correlation.py | 4 ++-- stock_indicators/indicators/dema.py | 4 ++-- stock_indicators/indicators/donchian.py | 4 ++-- stock_indicators/indicators/dpo.py | 3 ++- stock_indicators/indicators/dynamic.py | 3 ++- stock_indicators/indicators/elder_ray.py | 4 ++-- stock_indicators/indicators/ema.py | 4 ++-- stock_indicators/indicators/epma.py | 4 ++-- stock_indicators/indicators/fcb.py | 4 ++-- .../indicators/fisher_transform.py | 3 ++- stock_indicators/indicators/force_index.py | 4 ++-- stock_indicators/indicators/fractal.py | 3 ++- stock_indicators/indicators/gator.py | 4 ++-- stock_indicators/indicators/hma.py | 4 ++-- stock_indicators/indicators/ht_trendline.py | 4 ++-- stock_indicators/indicators/hurst.py | 4 ++-- stock_indicators/indicators/ichimoku.py | 3 ++- stock_indicators/indicators/kama.py | 4 ++-- stock_indicators/indicators/keltner.py | 4 ++-- stock_indicators/indicators/kvo.py | 4 ++-- stock_indicators/indicators/ma_envelopes.py | 3 ++- stock_indicators/indicators/macd.py | 4 ++-- stock_indicators/indicators/mama.py | 4 ++-- stock_indicators/indicators/mfi.py | 4 ++-- stock_indicators/indicators/obv.py | 3 ++- stock_indicators/indicators/parabolic_sar.py | 4 ++-- stock_indicators/indicators/pivots.py | 3 ++- stock_indicators/indicators/pmo.py | 4 ++-- stock_indicators/indicators/prs.py | 3 ++- stock_indicators/indicators/pvo.py | 4 ++-- stock_indicators/indicators/roc.py | 6 ++--- stock_indicators/indicators/rsi.py | 4 ++-- stock_indicators/indicators/slope.py | 4 ++-- stock_indicators/indicators/sma.py | 10 +++----- stock_indicators/indicators/smi.py | 4 ++-- stock_indicators/indicators/smma.py | 4 ++-- stock_indicators/indicators/starc_bands.py | 4 ++-- stock_indicators/indicators/stc.py | 4 ++-- stock_indicators/indicators/stdev.py | 4 ++-- stock_indicators/indicators/stdev_channels.py | 4 ++-- stock_indicators/indicators/stoch.py | 4 ++-- stock_indicators/indicators/stoch_rsi.py | 4 ++-- stock_indicators/indicators/super_trend.py | 4 ++-- stock_indicators/indicators/t3.py | 3 ++- stock_indicators/indicators/tema.py | 4 ++-- stock_indicators/indicators/tr.py | 3 ++- stock_indicators/indicators/trix.py | 4 ++-- stock_indicators/indicators/tsi.py | 4 ++-- stock_indicators/indicators/ulcer_index.py | 4 ++-- stock_indicators/indicators/ultimate.py | 4 ++-- .../indicators/volatility_stop.py | 4 ++-- stock_indicators/indicators/vortex.py | 4 ++-- stock_indicators/indicators/vwap.py | 4 ++-- stock_indicators/indicators/vwma.py | 4 ++-- stock_indicators/indicators/williams_r.py | 4 ++-- stock_indicators/indicators/wma.py | 4 ++-- stock_indicators/indicators/zig_zag.py | 3 ++- tests/test_adl.py | 10 ++++++++ tests/test_adx.py | 10 ++++++++ tests/test_alligator.py | 12 +++++++++- tests/test_alma.py | 8 +++++++ tests/test_aroon.py | 10 ++++++++ tests/test_atr.py | 10 ++++++++ tests/test_atr_stop.py | 10 ++++++++ tests/test_awesome.py | 9 +++++++ tests/test_beta.py | 14 ++++++++++- tests/test_bollinger_bands.py | 15 +++++++++++- tests/test_bop.py | 10 +++++++- tests/test_cci.py | 10 +++++++- tests/test_chaikin_oscillator.py | 13 +++++++++- tests/test_chandelier.py | 8 +++++++ tests/test_chop.py | 10 +++++++- tests/test_cmf.py | 12 +++++++++- tests/test_cmo.py | 8 +++++++ tests/test_connors_rsi.py | 12 ++++++++++ tests/test_correlation.py | 11 ++++++++- tests/test_dema.py | 10 +++++++- tests/test_donchian.py | 13 +++++++++- tests/test_dpo.py | 11 ++++++++- tests/test_dynamic.py | 8 +++++++ tests/test_elder_ray.py | 12 +++++++++- tests/test_ema.py | 8 +++++++ tests/test_epma.py | 9 ++++++- tests/test_fcb.py | 11 ++++++++- tests/test_fisher_transform.py | 11 ++++++++- tests/test_force_index.py | 10 +++++++- tests/test_fractal.py | 9 +++++++ tests/test_gator.py | 11 +++++++++ tests/test_hma.py | 10 +++++++- tests/test_ht_trendline.py | 11 ++++++++- tests/test_hurst.py | 8 +++++++ tests/test_ichimoku.py | 12 ++++++++++ tests/test_kama.py | 10 +++++++- tests/test_keltner.py | 13 +++++++++- tests/test_kvo.py | 11 ++++++++- tests/test_ma_envelopes.py | 10 ++++++++ tests/test_macd.py | 10 ++++++++ tests/test_mama.py | 14 ++++++++--- tests/test_mfi.py | 10 +++++++- tests/test_obv.py | 11 ++++++++- tests/test_parabolic_sar.py | 11 ++++++++- tests/test_pivots.py | 15 +++++++++++- tests/test_pmo.py | 11 ++++++++- tests/test_prs.py | 12 +++++++++- tests/test_pvo.py | 12 +++++++++- tests/test_roc.py | 9 +++++++ tests/test_rsi.py | 8 +++++++ tests/test_slope.py | 14 ++++++++++- tests/test_sma.py | 6 +++++ ...t_sma_extended.py => test_sma_analysis.py} | 6 +++++ tests/test_smi.py | 11 ++++++++- tests/test_smma.py | 10 +++++++- tests/test_starc_bands.py | 10 ++++++++ tests/test_stc.py | 10 +++++++- tests/test_stdev.py | 13 +++++++++- tests/test_stdev_channels.py | 13 +++++++++- tests/test_stoch.py | 10 ++++++++ tests/test_stoch_rsi.py | 9 +++++++ tests/test_super_trend.py | 10 ++++++++ tests/test_t3.py | 10 +++++++- tests/test_tema.py | 8 +++++++ tests/test_tr.py | 8 +++++++ tests/test_trix.py | 10 ++++++++ tests/test_tsi.py | 14 ++++++++--- tests/test_ulcer_index.py | 13 +++++++--- tests/test_ultimate.py | 13 +++++++--- tests/test_volatility_stop.py | 12 ++++++++-- tests/test_vortex.py | 14 ++++++++--- tests/test_vwap.py | 11 +++++++++ tests/test_vwma.py | 10 +++++++- tests/test_williams_r.py | 10 +++++++- tests/test_wma.py | 10 +++++++- tests/test_zig_zag.py | 11 +++++++++ 156 files changed, 935 insertions(+), 217 deletions(-) rename tests/{test_sma_extended.py => test_sma_analysis.py} (88%) diff --git a/pyproject.toml b/pyproject.toml index 2607b36e..2b31f09f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -29,7 +29,7 @@ classifiers = [ requires-python = ">=3.8" dependencies = [ "pythonnet>=3.0.0", - "typing_extensions>=4.0.0" + "typing_extensions>=4.4.0" ] keywords = [ "Stock Indicators", "Technical Indicators", "Market", "Technical Analysis", "Algorithmic", "Trading", "Trade", diff --git a/requirements.txt b/requirements.txt index 6053abbb..9045a0c0 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,3 +1,3 @@ # _cslib pythonnet>=3.0.0 -typing_extensions>=4.0.0 +typing_extensions>=4.4.0 diff --git a/stock_indicators/_cslib/__init__.py b/stock_indicators/_cslib/__init__.py index 5fc44167..5e7be965 100644 --- a/stock_indicators/_cslib/__init__.py +++ b/stock_indicators/_cslib/__init__.py @@ -30,6 +30,7 @@ from System import Decimal as CsDecimal from System import Enum as CsEnum from System.Globalization import CultureInfo +from System.Collections.Generic import IEnumerable as CsIEnumerable from System.Collections.Generic import List as CsList # Classes @@ -38,6 +39,7 @@ from Skender.Stock.Indicators import Quote as CsQuote from Skender.Stock.Indicators import QuoteUtility as CsQuoteUtility from Skender.Stock.Indicators import ResultBase as CsResultBase +from Skender.Stock.Indicators import ResultUtility as CsResultUtility # Enums from Skender.Stock.Indicators import BetaType as CsBetaType diff --git a/stock_indicators/indicators/adl.py b/stock_indicators/indicators/adl.py index 3f0c51d6..468b6d3a 100644 --- a/stock_indicators/indicators/adl.py +++ b/stock_indicators/indicators/adl.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -69,7 +70,7 @@ def adl_sma(self, value): _T = TypeVar("_T", bound=ADLResult) -class ADLResults(IndicatorResults[_T]): +class ADLResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of ADL(Accumulation/Distribution Line) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/adx.py b/stock_indicators/indicators/adx.py index 4e259783..c7d6639b 100644 --- a/stock_indicators/indicators/adx.py +++ b/stock_indicators/indicators/adx.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -71,7 +71,7 @@ def adxr(self, value): _T = TypeVar("_T", bound=ADXResult) -class ADXResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ADXResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of ADX(Average Directional Movement Index) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/alligator.py b/stock_indicators/indicators/alligator.py index e6856415..e0aaea70 100644 --- a/stock_indicators/indicators/alligator.py +++ b/stock_indicators/indicators/alligator.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -85,7 +85,7 @@ def lips(self, value): _T = TypeVar("_T", bound=AlligatorResult) -class AlligatorResults(RemoveWarmupMixin, IndicatorResults[_T]): +class AlligatorResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Williams Alligator results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/alma.py b/stock_indicators/indicators/alma.py index f2ab2dc1..262c7112 100644 --- a/stock_indicators/indicators/alma.py +++ b/stock_indicators/indicators/alma.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.quote import Quote from stock_indicators.indicators.common.results import IndicatorResults, ResultBase @@ -53,7 +53,7 @@ def alma(self, value): _T = TypeVar("_T", bound=ALMAResult) -class ALMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ALMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of ALMA(Arnaud Legoux Moving Average) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/aroon.py b/stock_indicators/indicators/aroon.py index f9d8775e..4cf04184 100644 --- a/stock_indicators/indicators/aroon.py +++ b/stock_indicators/indicators/aroon.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -62,7 +62,7 @@ def oscillator(self, value): _T = TypeVar("_T", bound=AroonResult) -class AroonResults(RemoveWarmupMixin, IndicatorResults[_T]): +class AroonResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Aroon results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/atr.py b/stock_indicators/indicators/atr.py index dcfb0d68..6e97978c 100644 --- a/stock_indicators/indicators/atr.py +++ b/stock_indicators/indicators/atr.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -62,7 +62,7 @@ def atrp(self, value): _T = TypeVar("_T", bound=ATRResult) -class ATRResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ATRResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of ATR(Average True Range) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/atr_stop.py b/stock_indicators/indicators/atr_stop.py index 1444b169..140b1774 100644 --- a/stock_indicators/indicators/atr_stop.py +++ b/stock_indicators/indicators/atr_stop.py @@ -6,7 +6,7 @@ from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal from stock_indicators.indicators.common.enums import EndType -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -75,7 +75,7 @@ def sell_stop(self, value): _T = TypeVar("_T", bound=AtrStopResult) -class AtrStopResults(RemoveWarmupMixin, IndicatorResults[_T]): +class AtrStopResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of ATR Trailing Stop results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/awesome.py b/stock_indicators/indicators/awesome.py index fc957586..8873d29c 100644 --- a/stock_indicators/indicators/awesome.py +++ b/stock_indicators/indicators/awesome.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -58,7 +58,7 @@ def normalized(self, value): _T = TypeVar("_T", bound=AwesomeResult) -class AwesomeResults(RemoveWarmupMixin, IndicatorResults[_T]): +class AwesomeResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Awesome Oscillator (aka Super AO) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/beta.py b/stock_indicators/indicators/beta.py index 76167dab..3e317b19 100644 --- a/stock_indicators/indicators/beta.py +++ b/stock_indicators/indicators/beta.py @@ -3,7 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.common.enums import BetaType -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -106,7 +106,7 @@ def returns_mrkt(self, value): _T = TypeVar("_T", bound=BetaResult) -class BetaResults(RemoveWarmupMixin, IndicatorResults[_T]): +class BetaResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Beta results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/bollinger_bands.py b/stock_indicators/indicators/bollinger_bands.py index f0298ff6..9a955ce5 100644 --- a/stock_indicators/indicators/bollinger_bands.py +++ b/stock_indicators/indicators/bollinger_bands.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -90,7 +90,7 @@ def width(self, value): _T = TypeVar("_T", bound=BollingerBandsResult) -class BollingerBandsResults(RemoveWarmupMixin, IndicatorResults[_T]): +class BollingerBandsResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Bollinger Bands results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/bop.py b/stock_indicators/indicators/bop.py index 8c081f59..69d3f744 100644 --- a/stock_indicators/indicators/bop.py +++ b/stock_indicators/indicators/bop.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -48,7 +48,7 @@ def bop(self, value): _T = TypeVar("_T", bound=BOPResult) -class BOPResults(RemoveWarmupMixin, IndicatorResults[_T]): +class BOPResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Balance of Power (aka Balance of Market Power) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/cci.py b/stock_indicators/indicators/cci.py index 82c5a974..f6e151ba 100644 --- a/stock_indicators/indicators/cci.py +++ b/stock_indicators/indicators/cci.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def cci(self, value): _T = TypeVar("_T", bound=CCIResult) -class CCIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class CCIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Commodity Channel Index (CCI) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/chaikin_oscillator.py b/stock_indicators/indicators/chaikin_oscillator.py index 42682f39..394467ad 100644 --- a/stock_indicators/indicators/chaikin_oscillator.py +++ b/stock_indicators/indicators/chaikin_oscillator.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -74,7 +74,7 @@ def oscillator(self, value): _T = TypeVar("_T", bound=ChaikinOscResult) -class ChaikinOscResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ChaikinOscResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Chaikin Oscillator results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/chandelier.py b/stock_indicators/indicators/chandelier.py index 46e69b56..b136f231 100644 --- a/stock_indicators/indicators/chandelier.py +++ b/stock_indicators/indicators/chandelier.py @@ -3,7 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.common.enums import ChandelierType -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -56,7 +56,7 @@ def chandelier_exit(self, value): _T = TypeVar("_T", bound=ChandelierResult) -class ChandelierResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ChandelierResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Chandelier Exit results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/chop.py b/stock_indicators/indicators/chop.py index f715fb9d..40bf6048 100644 --- a/stock_indicators/indicators/chop.py +++ b/stock_indicators/indicators/chop.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def chop(self, value): _T = TypeVar("_T", bound=ChopResult) -class ChopResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ChopResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Choppiness Index (CHOP) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/cmf.py b/stock_indicators/indicators/cmf.py index 8594d6b5..a9aa24b9 100644 --- a/stock_indicators/indicators/cmf.py +++ b/stock_indicators/indicators/cmf.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -63,7 +63,7 @@ def cmf(self, value): _T = TypeVar("_T", bound=CMFResult) -class CMFResults(RemoveWarmupMixin, IndicatorResults[_T]): +class CMFResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Chaikin Money Flow (CMF) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/cmo.py b/stock_indicators/indicators/cmo.py index 9d400f59..0e6ed714 100644 --- a/stock_indicators/indicators/cmo.py +++ b/stock_indicators/indicators/cmo.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def cmo(self, value): _T = TypeVar("_T", bound=CMOResult) -class CMOResults(RemoveWarmupMixin, IndicatorResults[_T]): +class CMOResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Chande Momentum Oscillator (CMO) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/common/candles.py b/stock_indicators/indicators/common/candles.py index 36cefaf0..d46990c3 100644 --- a/stock_indicators/indicators/common/candles.py +++ b/stock_indicators/indicators/common/candles.py @@ -1,27 +1,17 @@ from decimal import Decimal from typing import Optional, TypeVar - -from typing_extensions import Self +from typing_extensions import override from stock_indicators._cslib import CsCandleProperties from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal from stock_indicators.indicators.common._contrib.type_resolver import generate_cs_inherited_class from stock_indicators.indicators.common.enums import Match +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.quote import _Quote from stock_indicators.indicators.common.results import IndicatorResults, ResultBase -class CondenseMixin: - """Mixin for condense().""" - @IndicatorResults._verify_data - def condense(self) -> Self: - """ - Remove results which have no match, so it only returns meaningful data records. - """ - return self.__class__(filter(lambda x: x.match != Match.NONE, self), self._wrapper_class) - - class _CandleProperties(_Quote): @property def size(self) -> Optional[Decimal]: @@ -115,3 +105,7 @@ class CandleResults(CondenseMixin, IndicatorResults[_T]): It is exactly same with built-in `list` except for that it provides some useful helper methods written in CSharp implementation. """ + + @override + def condense(self): + return self.__class__(filter(lambda x: x.match != Match.NONE, self), self._wrapper_class) \ No newline at end of file diff --git a/stock_indicators/indicators/common/helpers.py b/stock_indicators/indicators/common/helpers.py index 8f89232f..12343b17 100644 --- a/stock_indicators/indicators/common/helpers.py +++ b/stock_indicators/indicators/common/helpers.py @@ -2,15 +2,15 @@ from typing_extensions import Self -from stock_indicators._cslib import CsIndicator +from stock_indicators._cslib import CsIndicator, CsIEnumerable, CsResultUtility from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.common.results import IndicatorResults class RemoveWarmupMixin: - """Mixin for remove_warmup_periods().""" + """IndicatorResults Mixin for remove_warmup_periods().""" @IndicatorResults._verify_data - def remove_warmup_periods(self, remove_periods: Optional[int] = None) -> Self: + def remove_warmup_periods(self: IndicatorResults, remove_periods: Optional[int] = None) -> Self: """ Remove the recommended(or specified) quantity of results from the beginning of the results list. """ @@ -18,5 +18,21 @@ def remove_warmup_periods(self, remove_periods: Optional[int] = None) -> Self: return super().remove_warmup_periods(remove_periods) removed_results = CsIndicator.RemoveWarmupPeriods(CsList(self._get_csdata_type(), self._csdata)) - return self.__class__(removed_results, self._wrapper_class) + + +class CondenseMixin: + """IndicatorResults Mixin for condense().""" + @IndicatorResults._verify_data + def condense(self: IndicatorResults) -> Self: + """ + Removes non-essential records containing null values with unique consideration for this indicator. + """ + cs_results_type = self._get_csdata_type() + try: # to check whether there's matched overloaded method. + condense_method = CsIndicator.Condense.Overloads[CsIEnumerable[cs_results_type]] + except TypeError: + condense_method = CsResultUtility.Condense[cs_results_type] + + condensed_results = condense_method(CsList(cs_results_type, self._csdata)) + return self.__class__(condensed_results, self._wrapper_class) diff --git a/stock_indicators/indicators/connors_rsi.py b/stock_indicators/indicators/connors_rsi.py index 5bc568b9..1e0af0ec 100644 --- a/stock_indicators/indicators/connors_rsi.py +++ b/stock_indicators/indicators/connors_rsi.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -81,7 +81,7 @@ def connors_rsi(self, value): _T = TypeVar("_T", bound=ConnorsRSIResult) -class ConnorsRSIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ConnorsRSIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Connors RSI results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/correlation.py b/stock_indicators/indicators/correlation.py index aa31d305..630d771e 100644 --- a/stock_indicators/indicators/correlation.py +++ b/stock_indicators/indicators/correlation.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -83,7 +83,7 @@ def r_squared(self, value): _T = TypeVar("_T", bound=CorrelationResult) -class CorrelationResults(RemoveWarmupMixin, IndicatorResults[_T]): +class CorrelationResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Correlation Coefficient results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/dema.py b/stock_indicators/indicators/dema.py index c22c7a70..bc7b54af 100644 --- a/stock_indicators/indicators/dema.py +++ b/stock_indicators/indicators/dema.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -46,7 +46,7 @@ def dema(self, value): _T = TypeVar("_T", bound=DEMAResult) -class DEMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class DEMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Double Exponential Moving Average (DEMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/donchian.py b/stock_indicators/indicators/donchian.py index be22d82e..f577e109 100644 --- a/stock_indicators/indicators/donchian.py +++ b/stock_indicators/indicators/donchian.py @@ -5,7 +5,7 @@ from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -73,7 +73,7 @@ def width(self, value): _T = TypeVar("_T", bound=DonchianResult) -class DonchianResults(RemoveWarmupMixin, IndicatorResults[_T]): +class DonchianResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Donchian Channels results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/dpo.py b/stock_indicators/indicators/dpo.py index 017ee3d8..6d2d9123 100644 --- a/stock_indicators/indicators/dpo.py +++ b/stock_indicators/indicators/dpo.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -54,7 +55,7 @@ def dpo(self, value): _T = TypeVar("_T", bound=DPOResult) -class DPOResults(IndicatorResults[_T]): +class DPOResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Detrended Price Oscillator (DPO) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/dynamic.py b/stock_indicators/indicators/dynamic.py index 12608cef..e6a9565c 100644 --- a/stock_indicators/indicators/dynamic.py +++ b/stock_indicators/indicators/dynamic.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -48,7 +49,7 @@ def dynamic(self, value): _T = TypeVar("_T", bound=DynamicResult) -class DynamicResults(IndicatorResults[_T]): +class DynamicResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of McGinley Dynamic results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/elder_ray.py b/stock_indicators/indicators/elder_ray.py index 207453a1..1ac3a97c 100644 --- a/stock_indicators/indicators/elder_ray.py +++ b/stock_indicators/indicators/elder_ray.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -62,7 +62,7 @@ def bear_power(self, value): _T = TypeVar("_T", bound=ElderRayResult) -class ElderRayResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ElderRayResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Elder-ray Index results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/ema.py b/stock_indicators/indicators/ema.py index 2059ac0e..8de55047 100644 --- a/stock_indicators/indicators/ema.py +++ b/stock_indicators/indicators/ema.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators.indicators.common.enums import CandlePart -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -51,7 +51,7 @@ def ema(self, value): _T = TypeVar("_T", bound=EMAResult) -class EMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class EMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of EMA(Exponential Moving Average) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/epma.py b/stock_indicators/indicators/epma.py index ba2a6be3..5616cb83 100644 --- a/stock_indicators/indicators/epma.py +++ b/stock_indicators/indicators/epma.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -48,7 +48,7 @@ def epma(self, value): _T = TypeVar("_T", bound=EPMAResult) -class EPMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class EPMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Endpoint Moving Average (EPMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/fcb.py b/stock_indicators/indicators/fcb.py index ef6995c8..a7c6615b 100644 --- a/stock_indicators/indicators/fcb.py +++ b/stock_indicators/indicators/fcb.py @@ -5,7 +5,7 @@ from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -59,7 +59,7 @@ def lower_band(self, value): _T = TypeVar("_T", bound=FCBResult) -class FCBResults(RemoveWarmupMixin, IndicatorResults[_T]): +class FCBResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Fractal Chaos Bands (FCB) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/fisher_transform.py b/stock_indicators/indicators/fisher_transform.py index 4682d52c..b208c29d 100644 --- a/stock_indicators/indicators/fisher_transform.py +++ b/stock_indicators/indicators/fisher_transform.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -55,7 +56,7 @@ def trigger(self, value): _T = TypeVar("_T", bound=FisherTransformResult) -class FisherTransformResults(IndicatorResults[_T]): +class FisherTransformResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Ehlers Fisher Transform results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/force_index.py b/stock_indicators/indicators/force_index.py index c60c1da3..ec7fe444 100644 --- a/stock_indicators/indicators/force_index.py +++ b/stock_indicators/indicators/force_index.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -46,7 +46,7 @@ def force_index(self, value): _T = TypeVar("_T", bound=ForceIndexResult) -class ForceIndexResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ForceIndexResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Force Index results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/fractal.py b/stock_indicators/indicators/fractal.py index 462cd18a..18548d63 100644 --- a/stock_indicators/indicators/fractal.py +++ b/stock_indicators/indicators/fractal.py @@ -6,6 +6,7 @@ from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal from stock_indicators.indicators.common.enums import EndType +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -76,7 +77,7 @@ def fractal_bull(self, value): _T = TypeVar("_T", bound=FractalResult) -class FractalResults(IndicatorResults[_T]): +class FractalResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Williams Fractal results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/gator.py b/stock_indicators/indicators/gator.py index d363bf21..885dcc98 100644 --- a/stock_indicators/indicators/gator.py +++ b/stock_indicators/indicators/gator.py @@ -3,7 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.alligator import AlligatorResult -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -80,7 +80,7 @@ def is_lower_expanding(self, value): _T = TypeVar("_T", bound=GatorResult) -class GatorResults(RemoveWarmupMixin, IndicatorResults[_T]): +class GatorResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Gator Oscillator results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/hma.py b/stock_indicators/indicators/hma.py index 4a02b1bb..7738ea26 100644 --- a/stock_indicators/indicators/hma.py +++ b/stock_indicators/indicators/hma.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def hma(self, value): _T = TypeVar("_T", bound=HMAResult) -class HMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class HMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Hull Moving Average (HMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/ht_trendline.py b/stock_indicators/indicators/ht_trendline.py index e3f6dbf6..79843bb5 100644 --- a/stock_indicators/indicators/ht_trendline.py +++ b/stock_indicators/indicators/ht_trendline.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -60,7 +60,7 @@ def smooth_price(self, value): _T = TypeVar("_T", bound=HTTrendlineResult) -class HTTrendlineResults(RemoveWarmupMixin, IndicatorResults[_T]): +class HTTrendlineResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Hilbert Transform Instantaneous Trendline (HTL) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/hurst.py b/stock_indicators/indicators/hurst.py index 600032f5..cea24f49 100644 --- a/stock_indicators/indicators/hurst.py +++ b/stock_indicators/indicators/hurst.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def hurst_exponent(self, value): _T = TypeVar("_T", bound=HurstResult) -class HurstResults(RemoveWarmupMixin, IndicatorResults[_T]): +class HurstResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Hurst Exponent results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/ichimoku.py b/stock_indicators/indicators/ichimoku.py index cccab6f0..5a11444d 100644 --- a/stock_indicators/indicators/ichimoku.py +++ b/stock_indicators/indicators/ichimoku.py @@ -5,6 +5,7 @@ from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -120,7 +121,7 @@ def chikou_span(self, value): _T = TypeVar("_T", bound=IchimokuResult) -class IchimokuResults(IndicatorResults[_T]): +class IchimokuResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Ichimoku Cloud results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/kama.py b/stock_indicators/indicators/kama.py index 7cf3e762..eb4c06f4 100644 --- a/stock_indicators/indicators/kama.py +++ b/stock_indicators/indicators/kama.py @@ -5,7 +5,7 @@ from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -66,7 +66,7 @@ def kama(self, value): _T = TypeVar("_T", bound=KAMAResult) -class KAMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class KAMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Kaufman’s Adaptive Moving Average (KAMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/keltner.py b/stock_indicators/indicators/keltner.py index d26b8e5f..57b79399 100644 --- a/stock_indicators/indicators/keltner.py +++ b/stock_indicators/indicators/keltner.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -79,7 +79,7 @@ def width(self, value): _T = TypeVar("_T", bound=KeltnerResult) -class KeltnerResults(RemoveWarmupMixin, IndicatorResults[_T]): +class KeltnerResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Keltner Channels results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/kvo.py b/stock_indicators/indicators/kvo.py index 708349d2..cea328dc 100644 --- a/stock_indicators/indicators/kvo.py +++ b/stock_indicators/indicators/kvo.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -63,7 +63,7 @@ def signal(self, value): _T = TypeVar("_T", bound=KVOResult) -class KVOResults(RemoveWarmupMixin, IndicatorResults[_T]): +class KVOResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Klinger Volume Oscillator (KVO) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/ma_envelopes.py b/stock_indicators/indicators/ma_envelopes.py index ba9d482b..55ccccd7 100644 --- a/stock_indicators/indicators/ma_envelopes.py +++ b/stock_indicators/indicators/ma_envelopes.py @@ -3,6 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.common.enums import MAType +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -71,7 +72,7 @@ def lower_envelope(self, value): _T = TypeVar("_T", bound=MAEnvelopeResult) -class MAEnvelopeResults(IndicatorResults[_T]): +class MAEnvelopeResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Moving Average Envelopes results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/macd.py b/stock_indicators/indicators/macd.py index 55ceea97..647537b6 100644 --- a/stock_indicators/indicators/macd.py +++ b/stock_indicators/indicators/macd.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators.indicators.common.enums import CandlePart -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -92,7 +92,7 @@ def slow_ema(self, value): _T = TypeVar("_T", bound=MACDResult) -class MACDResults(RemoveWarmupMixin ,IndicatorResults[_T]): +class MACDResults(CondenseMixin, RemoveWarmupMixin ,IndicatorResults[_T]): """ A wrapper class for the list of MACD(Moving Average Convergence/Divergence) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/mama.py b/stock_indicators/indicators/mama.py index 97275056..f48e7cde 100644 --- a/stock_indicators/indicators/mama.py +++ b/stock_indicators/indicators/mama.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -60,7 +60,7 @@ def fama(self, value): _T = TypeVar("_T", bound=MAMAResult) -class MAMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class MAMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of MESA Adaptive Moving Average (MAMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/mfi.py b/stock_indicators/indicators/mfi.py index 0da5be3d..f610c4d2 100644 --- a/stock_indicators/indicators/mfi.py +++ b/stock_indicators/indicators/mfi.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def mfi(self, value): _T = TypeVar("_T", bound=MFIResult) -class MFIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class MFIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Money Flow Index (MFI) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/obv.py b/stock_indicators/indicators/obv.py index 06ed0768..0d3754cc 100644 --- a/stock_indicators/indicators/obv.py +++ b/stock_indicators/indicators/obv.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -54,7 +55,7 @@ def obv_sma(self, value): _T = TypeVar("_T", bound=OBVResult) -class OBVResults(IndicatorResults[_T]): +class OBVResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of On-balance Volume (OBV) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/parabolic_sar.py b/stock_indicators/indicators/parabolic_sar.py index 250c0a92..b3bd3b79 100644 --- a/stock_indicators/indicators/parabolic_sar.py +++ b/stock_indicators/indicators/parabolic_sar.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -76,7 +76,7 @@ def is_reversal(self, value): _T = TypeVar("_T", bound=ParabolicSARResult) -class ParabolicSARResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ParabolicSARResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Parabolic SAR(stop and reverse) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/pivots.py b/stock_indicators/indicators/pivots.py index dc532968..26540ea9 100644 --- a/stock_indicators/indicators/pivots.py +++ b/stock_indicators/indicators/pivots.py @@ -6,6 +6,7 @@ from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal from stock_indicators.indicators.common.enums import EndType, PivotTrend +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -108,7 +109,7 @@ def low_trend(self, value): _T = TypeVar("_T", bound=PivotsResult) -class PivotsResults(IndicatorResults[_T]): +class PivotsResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Pivots results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/pmo.py b/stock_indicators/indicators/pmo.py index 2efeaa8b..1e42dbd9 100644 --- a/stock_indicators/indicators/pmo.py +++ b/stock_indicators/indicators/pmo.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -63,7 +63,7 @@ def signal(self, value): _T = TypeVar("_T", bound=PMOResult) -class PMOResults(RemoveWarmupMixin, IndicatorResults[_T]): +class PMOResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Price Momentum Oscillator (PMO) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/prs.py b/stock_indicators/indicators/prs.py index f4555bdf..9eba1070 100644 --- a/stock_indicators/indicators/prs.py +++ b/stock_indicators/indicators/prs.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -77,7 +78,7 @@ def prs_percent(self, value): _T = TypeVar("_T", bound=PRSResult) -class PRSResults(IndicatorResults[_T]): +class PRSResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Price Relative Strength (PRS) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/pvo.py b/stock_indicators/indicators/pvo.py index 7133605c..f1eba34f 100644 --- a/stock_indicators/indicators/pvo.py +++ b/stock_indicators/indicators/pvo.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -71,7 +71,7 @@ def histogram(self, value): _T = TypeVar("_T", bound=PVOResult) -class PVOResults(RemoveWarmupMixin, IndicatorResults[_T]): +class PVOResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Percentage Volume Oscillator (PVO) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/roc.py b/stock_indicators/indicators/roc.py index e6c1b785..98d473f4 100644 --- a/stock_indicators/indicators/roc.py +++ b/stock_indicators/indicators/roc.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -96,7 +96,7 @@ def roc_sma(self, value): _T = TypeVar("_T", bound=ROCResult) -class ROCResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ROCResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of ROC(Rate of Change) results. It is exactly same with built-in `list` except for that it provides @@ -143,7 +143,7 @@ def lower_band(self, value): _T = TypeVar("_T", bound=ROCWBResult) -class ROCWBResults(RemoveWarmupMixin, IndicatorResults[_T]): +class ROCWBResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of ROC(Rate of Change) with band results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/rsi.py b/stock_indicators/indicators/rsi.py index 8018603c..a55352d6 100644 --- a/stock_indicators/indicators/rsi.py +++ b/stock_indicators/indicators/rsi.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def rsi(self, value): _T = TypeVar("_T", bound=RSIResult) -class RSIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class RSIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of RSI(Relative Strength Index) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/slope.py b/stock_indicators/indicators/slope.py index 37bc8b85..40457b93 100644 --- a/stock_indicators/indicators/slope.py +++ b/stock_indicators/indicators/slope.py @@ -5,7 +5,7 @@ from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -81,7 +81,7 @@ def line(self, value): self._csdata.Line = CsDecimal(value) _T = TypeVar("_T", bound=SlopeResult) -class SlopeResults(RemoveWarmupMixin, IndicatorResults[_T]): +class SlopeResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Slope results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/sma.py b/stock_indicators/indicators/sma.py index 5d1e5b05..8fcd4688 100644 --- a/stock_indicators/indicators/sma.py +++ b/stock_indicators/indicators/sma.py @@ -3,7 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.common.enums import CandlePart -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -80,9 +80,7 @@ def sma(self, value): _T = TypeVar("_T", bound=SMAResult) - - -class SMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class SMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of SMA(Simple Moving Average) results. It is exactly same with built-in `list` except for that it provides @@ -121,9 +119,7 @@ def mape(self, value): _T = TypeVar("_T", bound=SMAAnalysisResult) - - -class SMAAnalysisResults(RemoveWarmupMixin, IndicatorResults[_T]): +class SMAAnalysisResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of SMA Analysis results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/smi.py b/stock_indicators/indicators/smi.py index 9ea33139..eaea2ffc 100644 --- a/stock_indicators/indicators/smi.py +++ b/stock_indicators/indicators/smi.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -68,7 +68,7 @@ def signal(self, value): _T = TypeVar("_T", bound=SMIResult) -class SMIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class SMIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Stochastic Momentum Index (SMI) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/smma.py b/stock_indicators/indicators/smma.py index 1f1fc708..10a63c72 100644 --- a/stock_indicators/indicators/smma.py +++ b/stock_indicators/indicators/smma.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def smma(self, value): _T = TypeVar("_T", bound=SMMAResult) -class SMMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class SMMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Smoothed Moving Average (SMMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/starc_bands.py b/stock_indicators/indicators/starc_bands.py index 4e47444f..779d3f85 100644 --- a/stock_indicators/indicators/starc_bands.py +++ b/stock_indicators/indicators/starc_bands.py @@ -3,7 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -76,7 +76,7 @@ def lower_band(self, value): _T = TypeVar("_T", bound=STARCBandsResult) -class STARCBandsResults(RemoveWarmupMixin, IndicatorResults[_T]): +class STARCBandsResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Stoller Average Range Channel (STARC) Bands results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/stc.py b/stock_indicators/indicators/stc.py index b0f157ac..92217822 100644 --- a/stock_indicators/indicators/stc.py +++ b/stock_indicators/indicators/stc.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -55,7 +55,7 @@ def stc(self, value): _T = TypeVar("_T", bound=STCResult) -class STCResults(RemoveWarmupMixin, IndicatorResults[_T]): +class STCResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Schaff Trend Cycle (STC) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/stdev.py b/stock_indicators/indicators/stdev.py index 673f3d27..d7a3c767 100644 --- a/stock_indicators/indicators/stdev.py +++ b/stock_indicators/indicators/stdev.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -74,7 +74,7 @@ def stdev_sma(self, value): _T = TypeVar("_T", bound=StdevResult) -class StdevResults(RemoveWarmupMixin, IndicatorResults[_T]): +class StdevResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Rolling Standard Deviation results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/stdev_channels.py b/stock_indicators/indicators/stdev_channels.py index 911eac32..ee62a96d 100644 --- a/stock_indicators/indicators/stdev_channels.py +++ b/stock_indicators/indicators/stdev_channels.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -76,7 +76,7 @@ def break_point(self, value): _T = TypeVar("_T", bound=StdevChannelsResult) -class StdevChannelsResults(RemoveWarmupMixin, IndicatorResults[_T]): +class StdevChannelsResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Standard Deviation Channels results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/stoch.py b/stock_indicators/indicators/stoch.py index fe619dbc..071587bb 100644 --- a/stock_indicators/indicators/stoch.py +++ b/stock_indicators/indicators/stoch.py @@ -3,7 +3,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators.indicators.common.enums import MAType -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -87,7 +87,7 @@ def percent_j(self, value): _T = TypeVar("_T", bound=StochResult) -class StochResults(RemoveWarmupMixin, IndicatorResults[_T]): +class StochResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Stochastic Oscillator(with KDJ Index) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/stoch_rsi.py b/stock_indicators/indicators/stoch_rsi.py index 8765cdc9..98221ca3 100644 --- a/stock_indicators/indicators/stoch_rsi.py +++ b/stock_indicators/indicators/stoch_rsi.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -63,7 +63,7 @@ def signal(self, value): _T = TypeVar("_T", bound=StochRSIResult) -class StochRSIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class StochRSIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Stochastic RSI results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/super_trend.py b/stock_indicators/indicators/super_trend.py index 03de73e1..012d237b 100644 --- a/stock_indicators/indicators/super_trend.py +++ b/stock_indicators/indicators/super_trend.py @@ -5,7 +5,7 @@ from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -70,7 +70,7 @@ def lower_band(self, value): _T = TypeVar("_T", bound=SuperTrendResult) -class SuperTrendResults(RemoveWarmupMixin, IndicatorResults[_T]): +class SuperTrendResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Super Trend results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/t3.py b/stock_indicators/indicators/t3.py index 39aba769..4cea9652 100644 --- a/stock_indicators/indicators/t3.py +++ b/stock_indicators/indicators/t3.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -51,7 +52,7 @@ def t3(self, value): _T = TypeVar("_T", bound=T3Result) -class T3Results(IndicatorResults[_T]): +class T3Results(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Tillson T3 results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/tema.py b/stock_indicators/indicators/tema.py index 51dc2fc6..1cbf93c8 100644 --- a/stock_indicators/indicators/tema.py +++ b/stock_indicators/indicators/tema.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def tema(self, value): _T = TypeVar("_T", bound=TEMAResult) -class TEMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class TEMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Triple Exponential Moving Average (TEMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/tr.py b/stock_indicators/indicators/tr.py index 9535041a..e5b260f9 100644 --- a/stock_indicators/indicators/tr.py +++ b/stock_indicators/indicators/tr.py @@ -2,6 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -42,7 +43,7 @@ def tr(self, value): _T = TypeVar("_T", bound=TrResult) -class TrResults(IndicatorResults[_T]): +class TrResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of True Range (TR) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/trix.py b/stock_indicators/indicators/trix.py index a459fa4d..4ce81b96 100644 --- a/stock_indicators/indicators/trix.py +++ b/stock_indicators/indicators/trix.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -66,7 +66,7 @@ def signal(self, value): _T = TypeVar("_T", bound=TRIXResult) -class TRIXResults(RemoveWarmupMixin, IndicatorResults[_T]): +class TRIXResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Triple EMA Oscillator (TRIX) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/tsi.py b/stock_indicators/indicators/tsi.py index 699493bf..128e6172 100644 --- a/stock_indicators/indicators/tsi.py +++ b/stock_indicators/indicators/tsi.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -63,7 +63,7 @@ def signal(self, value): _T = TypeVar("_T", bound=TSIResult) -class TSIResults(RemoveWarmupMixin, IndicatorResults[_T]): +class TSIResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of True Strength Index (TSI) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/ulcer_index.py b/stock_indicators/indicators/ulcer_index.py index 1e741933..92e859ec 100644 --- a/stock_indicators/indicators/ulcer_index.py +++ b/stock_indicators/indicators/ulcer_index.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def ui(self, value): _T = TypeVar("_T", bound=UlcerIndexResult) -class UlcerIndexResults(RemoveWarmupMixin, IndicatorResults[_T]): +class UlcerIndexResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Ulcer Index (UI) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/ultimate.py b/stock_indicators/indicators/ultimate.py index 9aeb87dd..88033fa8 100644 --- a/stock_indicators/indicators/ultimate.py +++ b/stock_indicators/indicators/ultimate.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -55,7 +55,7 @@ def ultimate(self, value): _T = TypeVar("_T", bound=UltimateResult) -class UltimateResults(RemoveWarmupMixin, IndicatorResults[_T]): +class UltimateResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Ultimate Oscillator results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/volatility_stop.py b/stock_indicators/indicators/volatility_stop.py index e8855655..ac78d9f0 100644 --- a/stock_indicators/indicators/volatility_stop.py +++ b/stock_indicators/indicators/volatility_stop.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -76,7 +76,7 @@ def is_stop(self, value): _T = TypeVar("_T", bound=VolatilityStopResult) -class VolatilityStopResults(RemoveWarmupMixin, IndicatorResults[_T]): +class VolatilityStopResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Volatility Stop results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/vortex.py b/stock_indicators/indicators/vortex.py index 816e4943..3ace0fe0 100644 --- a/stock_indicators/indicators/vortex.py +++ b/stock_indicators/indicators/vortex.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -56,7 +56,7 @@ def nvi(self, value): _T = TypeVar("_T", bound=VortexResult) -class VortexResults(RemoveWarmupMixin, IndicatorResults[_T]): +class VortexResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Vortex Indicator (VI) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/vwap.py b/stock_indicators/indicators/vwap.py index db4bfc5c..7833da69 100644 --- a/stock_indicators/indicators/vwap.py +++ b/stock_indicators/indicators/vwap.py @@ -4,7 +4,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList from stock_indicators._cstypes import DateTime as CsDateTime -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -61,7 +61,7 @@ def vwap(self, value): _T = TypeVar("_T", bound=VWAPResult) -class VWAPResults(RemoveWarmupMixin, IndicatorResults[_T]): +class VWAPResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Volume Weighted Average Price (VWAP) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/vwma.py b/stock_indicators/indicators/vwma.py index b2b28ca8..9df7abfc 100644 --- a/stock_indicators/indicators/vwma.py +++ b/stock_indicators/indicators/vwma.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -47,7 +47,7 @@ def vwma(self, value): _T = TypeVar("_T", bound=VWMAResult) -class VWMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class VWMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Volume Weighted Moving Average (VWMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/williams_r.py b/stock_indicators/indicators/williams_r.py index abd7df49..2276898c 100644 --- a/stock_indicators/indicators/williams_r.py +++ b/stock_indicators/indicators/williams_r.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators._cstypes import List as CsList -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -48,7 +48,7 @@ def williams_r(self, value): _T = TypeVar("_T", bound=WilliamsResult) -class WilliamsResults(RemoveWarmupMixin, IndicatorResults[_T]): +class WilliamsResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Williams %R results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/wma.py b/stock_indicators/indicators/wma.py index 0a018337..dc34b1f6 100644 --- a/stock_indicators/indicators/wma.py +++ b/stock_indicators/indicators/wma.py @@ -2,7 +2,7 @@ from stock_indicators._cslib import CsIndicator from stock_indicators.indicators.common.enums import CandlePart -from stock_indicators.indicators.common.helpers import RemoveWarmupMixin +from stock_indicators.indicators.common.helpers import CondenseMixin, RemoveWarmupMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -53,7 +53,7 @@ def wma(self, value): _T = TypeVar("_T", bound=WMAResult) -class WMAResults(RemoveWarmupMixin, IndicatorResults[_T]): +class WMAResults(CondenseMixin, RemoveWarmupMixin, IndicatorResults[_T]): """ A wrapper class for the list of Weighted Moving Average (WMA) results. It is exactly same with built-in `list` except for that it provides diff --git a/stock_indicators/indicators/zig_zag.py b/stock_indicators/indicators/zig_zag.py index d79646ae..7ccb2165 100644 --- a/stock_indicators/indicators/zig_zag.py +++ b/stock_indicators/indicators/zig_zag.py @@ -6,6 +6,7 @@ from stock_indicators._cstypes import Decimal as CsDecimal from stock_indicators._cstypes import to_pydecimal from stock_indicators.indicators.common.enums import EndType +from stock_indicators.indicators.common.helpers import CondenseMixin from stock_indicators.indicators.common.results import IndicatorResults, ResultBase from stock_indicators.indicators.common.quote import Quote @@ -79,7 +80,7 @@ def retrace_low(self, value): _T = TypeVar("_T", bound=ZigZagResult) -class ZigZagResults(IndicatorResults[_T]): +class ZigZagResults(CondenseMixin, IndicatorResults[_T]): """ A wrapper class for the list of Zig Zag results. It is exactly same with built-in `list` except for that it provides diff --git a/tests/test_adl.py b/tests/test_adl.py index 3d9e4410..1c5d1b87 100644 --- a/tests/test_adl.py +++ b/tests/test_adl.py @@ -52,6 +52,16 @@ def test_with_sma(self, quotes): assert 3439986548.42 == round(float(r.adl), 2) assert 3595352721.16 == round(float(r.adl_sma), 2) + def test_condense(self, quotes): + results = indicators.get_adl(quotes).condense() + + assert 502 == len(results) + + r = results[-1] + assert 0.8052 == round(float(r.money_flow_multiplier), 4) + assert 118396116.25 == round(float(r.money_flow_volume), 2) + assert 3439986548.42 == round(float(r.adl), 2) + assert r.adl_sma is None def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException diff --git a/tests/test_adx.py b/tests/test_adx.py index 9b88d7c1..79ecb309 100644 --- a/tests/test_adx.py +++ b/tests/test_adx.py @@ -54,6 +54,16 @@ def test_removed(self, quotes): assert 31.1510 == round(float(r.mdi), 4) assert 34.2987 == round(float(r.adx), 4) + def test_condense(self, quotes): + results = indicators.get_adx(quotes, 14).condense() + + assert 475 == len(results) + + r = results[-1] + assert 17.7565 == round(float(r.pdi), 4) + assert 31.1510 == round(float(r.mdi), 4) + assert 34.2987 == round(float(r.adx), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_alligator.py b/tests/test_alligator.py index ded85785..2d208b7c 100644 --- a/tests/test_alligator.py +++ b/tests/test_alligator.py @@ -59,7 +59,17 @@ def test_removed(self, quotes): assert 260.98953 == round(float(r.jaw), 5) assert 253.53576 == round(float(r.teeth), 5) assert 244.29591 == round(float(r.lips), 5) - + + def test_condense(self, quotes): + results = indicators.get_alligator(quotes).condense() + + assert 495 == len(results) + + r = results[-1] + assert 260.98953 == round(float(r.jaw), 5) + assert 253.53576 == round(float(r.teeth), 5) + assert 244.29591 == round(float(r.lips), 5) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_alma.py b/tests/test_alma.py index 3954fa5c..c59e645f 100644 --- a/tests/test_alma.py +++ b/tests/test_alma.py @@ -40,6 +40,14 @@ def test_removed(self, quotes): last = results.pop() assert 242.1871 == round(float(last.alma), 4) + def test_condense(self, quotes): + results = indicators.get_alma(quotes, 10, .85, 6).condense() + + assert 493 == len(results) + + r = results[-1] + assert 242.1871 == round(float(r.alma), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_aroon.py b/tests/test_aroon.py index df3127af..3af7aede 100644 --- a/tests/test_aroon.py +++ b/tests/test_aroon.py @@ -50,6 +50,16 @@ def test_removed(self, quotes): assert +88 == float(last.aroon_down) assert -60 == float(last.oscillator) + def test_condense(self, quotes): + results = indicators.get_aroon(quotes, 25).condense() + + assert 477 == len(results) + + r = results[-1] + assert 28 == float(r.aroon_up) + assert 88 == float(r.aroon_down) + assert -60 == float(r.oscillator) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_atr.py b/tests/test_atr.py index 8f37b403..a4af1af5 100644 --- a/tests/test_atr.py +++ b/tests/test_atr.py @@ -48,6 +48,16 @@ def test_removed(self, quotes): assert 6.1497 == round(float(last.atr), 4) assert 2.5072 == round(float(last.atrp), 4) + def test_condense(self, quotes): + results = indicators.get_atr(quotes, 14).condense() + + assert 488 == len(results) + + last = results.pop() + assert 2.6700 == round(float(last.tr), 4) + assert 6.1497 == round(float(last.atr), 4) + assert 2.5072 == round(float(last.atrp), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_atr_stop.py b/tests/test_atr_stop.py index 1b690160..db1788c4 100644 --- a/tests/test_atr_stop.py +++ b/tests/test_atr_stop.py @@ -98,6 +98,16 @@ def test_removed(self, quotes): assert last.atr_stop == last.buy_stop assert last.sell_stop is None + def test_condense(self, quotes): + results = indicators.get_atr_stop(quotes, 21, 3).condense() + + assert 481 == len(results) + + r = results[-1] + assert 246.3232 == round(float(r.atr_stop), 4) + assert r.atr_stop == r.buy_stop + assert r.sell_stop is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_awesome.py b/tests/test_awesome.py index c0604236..be303034 100644 --- a/tests/test_awesome.py +++ b/tests/test_awesome.py @@ -38,6 +38,15 @@ def test_removed(self, quotes): assert -17.7692 == round(float(last.oscillator), 4) assert -7.2763 == round(float(last.normalized), 4) + def test_condense(self, quotes): + results = indicators.get_awesome(quotes, 5, 34).condense() + + assert 469 == len(results) + + last = results.pop() + assert -17.7692 == round(float(last.oscillator), 4) + assert -7.2763 == round(float(last.normalized), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_beta.py b/tests/test_beta.py index d0f7e2cb..7bae55c5 100644 --- a/tests/test_beta.py +++ b/tests/test_beta.py @@ -34,7 +34,7 @@ def test_all(self, quotes, other_quotes): assert 3.1066 == round(float(r.ratio), 4) assert 0.6944 == round(float(r.convexity), 4) - r= results[501] + r = results[501] assert 1.5123 == round(float(r.beta), 4) assert 2.0721 == round(float(r.beta_up), 4) assert 1.5908 == round(float(r.beta_down), 4) @@ -114,6 +114,18 @@ def test_no_quotes(self, quotes): r = indicators.get_beta(quotes[:1], quotes[:1], 5) assert 1 == len(r) + def test_condense(self, quotes, other_quotes): + results = indicators.get_beta(other_quotes, quotes, 20, BetaType.ALL).condense() + + assert 482 == len(results) + + r = results[-1] + assert 1.5123 == round(float(r.beta), 4) + assert 2.0721 == round(float(r.beta_up), 4) + assert 1.5908 == round(float(r.beta_down), 4) + assert 1.3026 == round(float(r.ratio), 4) + assert 0.2316 == round(float(r.convexity), 4) + def test_exceptions(self, quotes, other_quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_bollinger_bands.py b/tests/test_bollinger_bands.py index b34e2d3d..1f07dd05 100644 --- a/tests/test_bollinger_bands.py +++ b/tests/test_bollinger_bands.py @@ -29,7 +29,6 @@ def test_standard(self, quotes): assert -0.602552 == round(float(r.z_score), 6) assert 0.173433 == round(float(r.width), 6) - def test_bad_data(self, bad_quotes): r = indicators.get_bollinger_bands(bad_quotes, 15, 3) @@ -48,6 +47,20 @@ def test_removed(self, quotes): assert -0.602552 == round(float(last.z_score), 6) assert 0.173433 == round(float(last.width), 6) + def test_condense(self, quotes): + results = indicators.get_bollinger_bands(quotes, 20, 2).condense() + + assert 483 == len(results) + + last = results.pop() + assert 251.8600 == round(float(last.sma), 4) + assert 273.7004 == round(float(last.upper_band), 4) + assert 230.0196 == round(float(last.lower_band), 4) + assert 0.349362 == round(float(last.percent_b), 6) + assert -0.602552 == round(float(last.z_score), 6) + assert 0.173433 == round(float(last.width), 6) + + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_bop.py b/tests/test_bop.py index 9352a597..d5434c92 100644 --- a/tests/test_bop.py +++ b/tests/test_bop.py @@ -34,7 +34,15 @@ def test_removed(self, quotes): last = results.pop() assert -0.292788 == round(float(last.bop), 6) - + + def test_condense(self, quotes): + results = indicators.get_bop(quotes).condense() + + assert 489 == len(results) + + last = results.pop() + assert -0.292788 == round(float(last.bop), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_cci.py b/tests/test_cci.py index 3739fd74..8a555f04 100644 --- a/tests/test_cci.py +++ b/tests/test_cci.py @@ -22,7 +22,15 @@ def test_removed(self, quotes): last = results.pop() assert -52.9946 == round(float(last.cci), 4) - + + def test_condense(self, quotes): + results = indicators.get_cci(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert -52.9946 == round(float(last.cci), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_chaikin_oscillator.py b/tests/test_chaikin_oscillator.py index e9e33cb9..c7b0c085 100644 --- a/tests/test_chaikin_oscillator.py +++ b/tests/test_chaikin_oscillator.py @@ -34,7 +34,18 @@ def test_removed(self, quotes): assert 0.8052 == round(float(last.money_flow_multiplier), 4) assert 118396116.25 == round(float(last.money_flow_volume), 2) assert -19135200.72 == round(float(last.oscillator), 2) - + + def test_condense(self, quotes): + results = indicators.get_chaikin_osc(quotes, 3, 10).condense() + + assert 493 == len(results) + + last = results.pop() + assert 3439986548.42 == round(float(last.adl), 2) + assert 0.8052 == round(float(last.money_flow_multiplier), 4) + assert 118396116.25 == round(float(last.money_flow_volume), 2) + assert -19135200.72 == round(float(last.oscillator), 2) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_chandelier.py b/tests/test_chandelier.py index 7407961a..4a6ab150 100644 --- a/tests/test_chandelier.py +++ b/tests/test_chandelier.py @@ -39,6 +39,14 @@ def test_removed(self, quotes): last = long_results.pop() assert 256.5860 == round(float(last.chandelier_exit), 4) + def test_condense(self, quotes): + long_results = indicators.get_chandelier(quotes, 22, 3).condense() + + assert 480 == len(long_results) + + last = long_results.pop() + assert 256.5860 == round(float(last.chandelier_exit), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_chop.py b/tests/test_chop.py index f9cebbd4..cb80f851 100644 --- a/tests/test_chop.py +++ b/tests/test_chop.py @@ -37,7 +37,15 @@ def test_removed(self, quotes): last = results.pop() assert 38.6526 == round(float(last.chop), 4) - + + def test_condense(self, quotes): + results = indicators.get_chop(quotes, 14).condense() + + assert 488 == len(results) + + last = results.pop() + assert 38.6526 == round(float(last.chop), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_cmf.py b/tests/test_cmf.py index 3307a7a6..2a58d9fb 100644 --- a/tests/test_cmf.py +++ b/tests/test_cmf.py @@ -40,7 +40,17 @@ def test_removed(self, quotes): assert 0.8052 == round(float(last.money_flow_multiplier), 4) assert 118396116.25 == round(float(last.money_flow_volume), 2) assert -0.123754 == round(float(last.cmf), 6) - + + def test_condense(self, quotes): + results = indicators.get_cmf(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 0.8052 == round(float(last.money_flow_multiplier), 4) + assert 118396116.25 == round(float(last.money_flow_volume), 2) + assert -0.123754 == round(float(last.cmf), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_cmo.py b/tests/test_cmo.py index c1c01426..d8b4c971 100644 --- a/tests/test_cmo.py +++ b/tests/test_cmo.py @@ -40,6 +40,14 @@ def test_removed(self, quotes): last = results.pop() assert -26.7502 == round(float(last.cmo), 4) + def test_condense(self, quotes): + results = indicators.get_cmo(quotes, 14).condense() + + assert 488 == len(results) + + last = results.pop() + assert -26.7502 == round(float(last.cmo), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_connors_rsi.py b/tests/test_connors_rsi.py index ef03509d..189df499 100644 --- a/tests/test_connors_rsi.py +++ b/tests/test_connors_rsi.py @@ -46,7 +46,19 @@ def test_removed(self, quotes): assert 67.4899 == round(float(last.rsi_streak), 4) assert 88.0000 == round(float(last.percent_rank), 4) assert 74.7662 == round(float(last.connors_rsi), 4) + + def test_condense(self, quotes): + results = indicators.get_connors_rsi(quotes, 3, 2, 100) + results = results.condense() + assert 401 == len(results) + + last = results.pop() + assert 68.8087 == round(float(last.rsi_close), 4) + assert 67.4899 == round(float(last.rsi_streak), 4) + assert 88.0000 == round(float(last.percent_rank), 4) + assert 74.7662 == round(float(last.connors_rsi), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_correlation.py b/tests/test_correlation.py index 21a78675..046bdac8 100644 --- a/tests/test_correlation.py +++ b/tests/test_correlation.py @@ -41,7 +41,16 @@ def test_removed(self, quotes, other_quotes): last = results.pop() assert 0.8460 == round(float(last.correlation), 4) assert 0.7157 == round(float(last.r_squared), 4) - + + def test_condense(self, quotes, other_quotes): + results = indicators.get_correlation(quotes, other_quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 0.8460 == round(float(last.correlation), 4) + assert 0.7157 == round(float(last.r_squared), 4) + def test_exceptions(self, quotes, other_quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_dema.py b/tests/test_dema.py index 6a3d2a04..547d0c3c 100644 --- a/tests/test_dema.py +++ b/tests/test_dema.py @@ -28,7 +28,15 @@ def test_removed(self, quotes): last = results.pop() assert 241.1677 == round(float(last.dema), 4) - + + def test_condense(self, quotes): + results = indicators.get_dema(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 241.1677 == round(float(last.dema), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_donchian.py b/tests/test_donchian.py index 00e6084d..186da95c 100644 --- a/tests/test_donchian.py +++ b/tests/test_donchian.py @@ -55,7 +55,18 @@ def test_removed(self, quotes): assert 273.5900 == round(float(last.upper_band), 4) assert 229.4200 == round(float(last.lower_band), 4) assert 0.175623 == round(float(last.width), 6) - + + def test_condense(self, quotes): + results = indicators.get_donchian(quotes, 20).condense() + + assert 482 == len(results) + + last = results.pop() + assert 251.5050 == round(float(last.center_line), 4) + assert 273.5900 == round(float(last.upper_band), 4) + assert 229.4200 == round(float(last.lower_band), 4) + assert 0.175623 == round(float(last.width), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_dpo.py b/tests/test_dpo.py index 3452f530..d890e522 100644 --- a/tests/test_dpo.py +++ b/tests/test_dpo.py @@ -32,7 +32,16 @@ def test_bad_data(self, bad_quotes): r = indicators.get_dpo(bad_quotes, 5) assert 502 == len(r) - + + def test_condense(self, quotes): + results = indicators.get_dpo(quotes, 14).condense() + + assert 489 == len(results) + + last = results.pop() + assert 2.1821 == round(float(last.dpo), 4) + assert 246.7079 == round(float(last.sma), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_dynamic.py b/tests/test_dynamic.py index 44c9fab2..8f8938d6 100644 --- a/tests/test_dynamic.py +++ b/tests/test_dynamic.py @@ -32,6 +32,14 @@ def test_no_quotes(self, quotes): r = indicators.get_dynamic(quotes[:1], 14) assert 1 == len(r) + def test_condense(self, quotes): + results = indicators.get_dynamic(quotes, 14).condense() + + assert 501 == len(results) + + last = results.pop() + assert 245.7356 == round(float(last.dynamic), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_elder_ray.py b/tests/test_elder_ray.py index ab0617c7..013bd213 100644 --- a/tests/test_elder_ray.py +++ b/tests/test_elder_ray.py @@ -52,7 +52,17 @@ def test_removed(self, quotes): assert 246.0129 == round(float(last.ema), 4) assert -00.4729 == round(float(last.bull_power), 4) assert -3.1429 == round(float(last.bear_power), 4) - + + def test_condense(self, quotes): + results = indicators.get_elder_ray(quotes, 13).condense() + + assert 490 == len(results) + + last = results.pop() + assert 246.0129 == round(float(last.ema), 4) + assert -00.4729 == round(float(last.bull_power), 4) + assert -3.1429 == round(float(last.bear_power), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_ema.py b/tests/test_ema.py index 381b291f..14065d62 100644 --- a/tests/test_ema.py +++ b/tests/test_ema.py @@ -53,6 +53,14 @@ def test_removed(self, quotes): last = results.pop() assert 249.3519 == round(float(last.ema), 4) + def test_condense(self, quotes): + results = indicators.get_ema(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 249.3519 == round(float(last.ema), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_epma.py b/tests/test_epma.py index 3899f149..d90292ec 100644 --- a/tests/test_epma.py +++ b/tests/test_epma.py @@ -35,7 +35,14 @@ def test_removed(self, quotes): last = results.pop() assert 235.8131 == round(float(last.epma), 4) - + + def test_condense(self, quotes): + results = indicators.get_epma(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 235.8131 == round(float(last.epma), 4) def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException diff --git a/tests/test_fcb.py b/tests/test_fcb.py index 09db80c8..f0cb00df 100644 --- a/tests/test_fcb.py +++ b/tests/test_fcb.py @@ -46,7 +46,16 @@ def test_removed(self, quotes): last = results.pop() assert 262.47 == round(float(last.upper_band), 2) assert 229.42 == round(float(last.lower_band), 2) - + + def test_condense(self, quotes): + results = indicators.get_fcb(quotes, 2).condense() + + assert 497 == len(results) + + last = results.pop() + assert 262.47 == round(float(last.upper_band), 2) + assert 229.42 == round(float(last.lower_band), 2) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_fisher_transform.py b/tests/test_fisher_transform.py index db6e0609..87910a83 100644 --- a/tests/test_fisher_transform.py +++ b/tests/test_fisher_transform.py @@ -58,7 +58,16 @@ def test_no_quotes(self, quotes): r = indicators.get_fisher_transform(quotes[:1]) assert 1 == len(r) - + + def test_condense(self, quotes): + results = indicators.get_fisher_transform(quotes, 10).condense() + + assert 502 == len(results) + + last = results.pop() + assert -1.2876 == round(float(last.fisher), 4) + assert -2.0071 == round(float(last.trigger), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_force_index.py b/tests/test_force_index.py index 2f91b977..e3666b83 100644 --- a/tests/test_force_index.py +++ b/tests/test_force_index.py @@ -34,7 +34,15 @@ def test_removed(self, quotes): last = results.pop() assert -16824018.428 == round(float(last.force_index), 3) - + + def test_condense(self, quotes): + results = indicators.get_force_index(quotes, 13).condense() + + assert 489 == len(results) + + last = results.pop() + assert -16824018.428 == round(float(last.force_index), 3) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_fractal.py b/tests/test_fractal.py index ee3faeb0..eec67c31 100644 --- a/tests/test_fractal.py +++ b/tests/test_fractal.py @@ -78,6 +78,15 @@ def test_bad_data(self, bad_quotes): assert 502 == len(r) + def test_condense(self, quotes): + results = indicators.get_fractal(quotes).condense() + + assert 129 == len(results) + + last = results.pop() + assert 229.42 == round(float(last.fractal_bull), 2) + assert last.fractal_bear is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_gator.py b/tests/test_gator.py index 15b3b562..429ffdff 100644 --- a/tests/test_gator.py +++ b/tests/test_gator.py @@ -92,3 +92,14 @@ def test_removed(self, quotes): assert -9.2399 == round(float(last.lower), 4) assert last.is_upper_expanding == True assert last.is_lower_expanding == True + + def test_condense(self, quotes): + results = indicators.get_gator(quotes).condense() + + assert 490 == len(results) + + last = results.pop() + assert 7.4538 == round(float(last.upper), 4) + assert -9.2399 == round(float(last.lower), 4) + assert last.is_upper_expanding == True + assert last.is_lower_expanding == True diff --git a/tests/test_hma.py b/tests/test_hma.py index c3c39c94..2065e766 100644 --- a/tests/test_hma.py +++ b/tests/test_hma.py @@ -32,7 +32,15 @@ def test_removed(self, quotes): last = results.pop() assert 235.6972 == round(float(last.hma), 4) - + + def test_condense(self, quotes): + results = indicators.get_hma(quotes, 20).condense() + + assert 480 == len(results) + + last = results.pop() + assert 235.6972 == round(float(last.hma), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_ht_trendline.py b/tests/test_ht_trendline.py index bcdcc612..ca42ceb4 100644 --- a/tests/test_ht_trendline.py +++ b/tests/test_ht_trendline.py @@ -59,7 +59,16 @@ def test_removed(self, quotes): last = results.pop() assert 252.2172 == round(float(last.trendline), 4) assert 242.3435 == round(float(last.smooth_price), 4) - + + def test_condense(self, quotes): + results = indicators.get_ht_trendline(quotes).condense() + + assert 502 == len(results) + + last = results.pop() + assert 252.2172 == round(float(last.trendline), 4) + assert 242.3435 == round(float(last.smooth_price), 4) + def test_penny_data(self, penny_quotes): results = indicators.get_ht_trendline(penny_quotes) assert 533 == len(results) diff --git a/tests/test_hurst.py b/tests/test_hurst.py index 50a25606..12461863 100644 --- a/tests/test_hurst.py +++ b/tests/test_hurst.py @@ -42,6 +42,14 @@ def test_removed(self, longest_quotes): last = results.pop() assert 0.483563 == round(float(last.hurst_exponent), 6) + def test_condense(self, longest_quotes): + results = indicators.get_hurst(longest_quotes, len(longest_quotes) - 1).condense() + + assert 1 == len(results) + + last = results.pop() + assert 0.483563 == round(float(last.hurst_exponent), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_ichimoku.py b/tests/test_ichimoku.py index 46177571..055e5264 100644 --- a/tests/test_ichimoku.py +++ b/tests/test_ichimoku.py @@ -55,6 +55,18 @@ def test_no_quotes(self, quotes): r = indicators.get_ichimoku(quotes[:1]) assert 1 == len(r) + def test_condense(self, quotes): + results = indicators.get_ichimoku(quotes, 9, 26, 52).condense() + + assert 502 == len(results) + + last = results.pop() + assert 241.2600 == round(float(last.tenkan_sen), 4) + assert 251.5050 == round(float(last.kijun_sen), 4) + assert 264.7700 == round(float(last.senkou_span_a), 4) + assert 269.8200 == round(float(last.senkou_span_b), 4) + assert last.chikou_span is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_kama.py b/tests/test_kama.py index c666fa7a..bd90970c 100644 --- a/tests/test_kama.py +++ b/tests/test_kama.py @@ -59,7 +59,15 @@ def test_removed(self, quotes): assert 502 - max(er_periods + 100, er_periods * 10) == len(results) last = results.pop() - + assert 0.2214 == round(float(last.efficiency_ratio), 4) + assert 240.1138 == round(float(last.kama), 4) + + def test_condense(self, quotes): + results = indicators.get_kama(quotes, 10, 2, 30).condense() + + assert 493 == len(results) + + last = results.pop() assert 0.2214 == round(float(last.efficiency_ratio), 4) assert 240.1138 == round(float(last.kama), 4) diff --git a/tests/test_keltner.py b/tests/test_keltner.py index 279b741a..cc36954b 100644 --- a/tests/test_keltner.py +++ b/tests/test_keltner.py @@ -58,7 +58,18 @@ def test_removed(self, quotes): assert 249.3519 == round(float(last.center_line), 4) assert 236.5165 == round(float(last.lower_band), 4) assert 0.102950 == round(float(last.width), 6) - + + def test_condense(self, quotes): + results = indicators.get_keltner(quotes, 20, 2, 10).condense() + + assert 483 == len(results) + + last = results.pop() + assert 262.1873 == round(float(last.upper_band), 4) + assert 249.3519 == round(float(last.center_line), 4) + assert 236.5165 == round(float(last.lower_band), 4) + assert 0.102950 == round(float(last.width), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_kvo.py b/tests/test_kvo.py index 56c0bf5e..e2527204 100644 --- a/tests/test_kvo.py +++ b/tests/test_kvo.py @@ -57,7 +57,16 @@ def test_removed(self, quotes): last = results.pop() assert -539224047 == round(float(last.oscillator), 0) assert -1548306127 == round(float(last.signal), 0) - + + def test_condense(self, quotes): + results = indicators.get_kvo(quotes, 34, 55, 13).condense() + + assert 446 == len(results) + + last = results.pop() + assert -539224047 == round(float(last.oscillator), 0) + assert -1548306127 == round(float(last.signal), 0) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_ma_envelopes.py b/tests/test_ma_envelopes.py index 952cf6ae..9b26b8dd 100644 --- a/tests/test_ma_envelopes.py +++ b/tests/test_ma_envelopes.py @@ -207,6 +207,16 @@ def test_bad_data(self, bad_quotes): r = indicators.get_ma_envelopes(bad_quotes, 5, 2.5, MAType.WMA) assert 502 == len(r) + def test_condense(self, quotes): + results = indicators.get_ma_envelopes(quotes, 10, 2.5, MAType.ALMA).condense() + + assert 493 == len(results) + + last = results.pop() + assert 242.1871 == round(float(last.center_line), 4) + assert 248.2418 == round(float(last.upper_envelope), 4) + assert 236.1324 == round(float(last.lower_envelope), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_macd.py b/tests/test_macd.py index 7419d9cb..e1cd7546 100644 --- a/tests/test_macd.py +++ b/tests/test_macd.py @@ -45,6 +45,16 @@ def test_removed(self, quotes): assert -5.8569 == round(float(last.signal), 4) assert -0.3629 == round(float(last.histogram), 4) + def test_condense(self, quotes): + results = indicators.get_macd(quotes, 12, 26, 9).condense() + + assert 477 == len(results) + + last = results.pop() + assert -6.2198 == round(float(last.macd), 4) + assert -5.8569 == round(float(last.signal), 4) + assert -0.3629 == round(float(last.histogram), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_mama.py b/tests/test_mama.py index 3922aba9..a6001e28 100644 --- a/tests/test_mama.py +++ b/tests/test_mama.py @@ -48,15 +48,23 @@ def test_no_quotes(self, quotes): assert 1 == len(r) def test_removed(self, quotes): - results = indicators.get_mama(quotes, 0.5, 0.05) - results = results.remove_warmup_periods() + results = indicators.get_mama(quotes, 0.5, 0.05).remove_warmup_periods() assert 502 - 50 == len(results) last = results.pop() assert 244.1092 == round(float(last.mama), 4) assert 252.6139 == round(float(last.fama), 4) - + + def test_condense(self, quotes): + results = indicators.get_mama(quotes, 0.5, 0.05).condense() + + assert 497 == len(results) + + last = results.pop() + assert 244.1092 == round(float(last.mama), 4) + assert 252.6139 == round(float(last.fama), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_mfi.py b/tests/test_mfi.py index 0845c068..fc3eac8a 100644 --- a/tests/test_mfi.py +++ b/tests/test_mfi.py @@ -44,7 +44,15 @@ def test_removed(self, quotes): last = results.pop() assert 39.9494 == round(float(last.mfi), 4) - + + def test_condense(self, quotes): + results = indicators.get_mfi(quotes, 14).condense() + + assert 488 == len(results) + + last = results.pop() + assert 39.9494 == round(float(last.mfi), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_obv.py b/tests/test_obv.py index 75728100..50fdae4d 100644 --- a/tests/test_obv.py +++ b/tests/test_obv.py @@ -51,7 +51,16 @@ def test_no_quotes(self, quotes): r = indicators.get_obv(quotes[:1]) assert 1 == len(r) - + + def test_condense(self, quotes): + results = indicators.get_obv(quotes).condense() + + assert 502 == len(results) + + last = results.pop() + assert 539843504 == last.obv + assert last.obv_sma is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_parabolic_sar.py b/tests/test_parabolic_sar.py index 6673aba5..ef1b211b 100644 --- a/tests/test_parabolic_sar.py +++ b/tests/test_parabolic_sar.py @@ -67,7 +67,16 @@ def test_removed(self, quotes): last = results.pop() assert 229.7662 == round(float(last.sar), 4) assert False == last.is_reversal - + + def test_condense(self, quotes): + results = indicators.get_parabolic_sar(quotes, 0.02, 0.2).condense() + + assert 488 == len(results) + + last = results.pop() + assert 229.7662 == round(float(last.sar), 4) + assert False == last.is_reversal + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_pivots.py b/tests/test_pivots.py index 4aaf5fde..2d25084f 100644 --- a/tests/test_pivots.py +++ b/tests/test_pivots.py @@ -88,7 +88,20 @@ def test_no_quotes(self, quotes): r = indicators.get_pivots(quotes[:1]) assert 1 == len(r) - + + def test_condense(self, quotes): + results = indicators.get_pivots(quotes, 4, 4, 20, EndType.HIGH_LOW).condense() + + assert 67 == len(results) + + r = results.pop() + assert r.high_point is None + assert r.high_trend is None + assert r.high_line is None + assert 252.34 == float(round(r.low_point, 2)) + assert r.low_trend == PivotTrend.LL + assert 252.34 == float(round(r.low_line, 2)) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_pmo.py b/tests/test_pmo.py index ca0d2b0f..dd8ae1a2 100644 --- a/tests/test_pmo.py +++ b/tests/test_pmo.py @@ -36,7 +36,16 @@ def test_removed(self, quotes): last = results.pop() assert -2.7016 == round(float(last.pmo), 4) assert -2.3117 == round(float(last.signal), 4) - + + def test_condense(self, quotes): + results = indicators.get_pmo(quotes, 35, 20, 10).condense() + + assert 448 == len(results) + + last = results.pop() + assert -2.7016 == round(float(last.pmo), 4) + assert -2.3117 == round(float(last.signal), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_prs.py b/tests/test_prs.py index 2c3c21cb..5028949e 100644 --- a/tests/test_prs.py +++ b/tests/test_prs.py @@ -34,7 +34,17 @@ def test_no_quotes(self, quotes): r = indicators.get_prs(quotes[:1], quotes[:1]) assert 1 == len(r) - + + def test_condense(self, quotes, other_quotes): + results = indicators.get_prs(other_quotes, quotes, 30, 10).condense() + + assert 502 == len(results) + + last = results.pop() + assert 1.356817 == round(float(last.prs), 6) + assert 1.343445 == round(float(last.prs_sma), 6) + assert 0.037082 == round(float(last.prs_percent), 6) + def test_exceptions(self, quotes, other_quotes, mismatch_quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_pvo.py b/tests/test_pvo.py index 20ebab0b..80ae409c 100644 --- a/tests/test_pvo.py +++ b/tests/test_pvo.py @@ -60,7 +60,17 @@ def test_removed(self, quotes): assert 10.4395 == float(round(last.pvo, 4)) assert 12.2681 == float(round(last.signal, 4)) assert -1.8286 == float(round(last.histogram, 4)) - + + def test_condense(self, quotes): + results = indicators.get_pvo(quotes, 12, 26, 9).condense() + + assert 477 == len(results) + + last = results.pop() + assert 10.4395 == float(round(last.pvo, 4)) + assert 12.2681 == float(round(last.signal, 4)) + assert -1.8286 == float(round(last.histogram, 4)) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_roc.py b/tests/test_roc.py index 1d266625..72c2bd8b 100644 --- a/tests/test_roc.py +++ b/tests/test_roc.py @@ -53,6 +53,15 @@ def test_removed(self, quotes): assert -8.2482 == round(float(last.roc), 4) assert last.roc_sma is None + def test_condense(self, quotes): + results = indicators.get_roc(quotes, 20).condense() + + assert 482 == len(results) + + last = results.pop() + assert -8.2482 == round(float(last.roc), 4) + assert last.roc_sma is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_rsi.py b/tests/test_rsi.py index b8628401..b5da70a1 100644 --- a/tests/test_rsi.py +++ b/tests/test_rsi.py @@ -56,6 +56,14 @@ def test_removed(self, quotes): last = results.pop() assert 42.0773 == round(float(last.rsi), 4) + def test_condense(self, quotes): + results = indicators.get_rsi(quotes, 14).condense() + + assert 488 == len(results) + + last = results.pop() + assert 42.0773 == round(float(last.rsi), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_slope.py b/tests/test_slope.py index 701b145e..8fe17ecc 100644 --- a/tests/test_slope.py +++ b/tests/test_slope.py @@ -45,7 +45,19 @@ def test_removed(self, quotes): assert 0000.7955 == round(float(last.r_squared), 4) assert 10.9202 == round(float(last.stdev), 4) assert 235.8131 == round(float(last.line), 4) - + + def test_condense(self, quotes): + results = indicators.get_slope(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert -1.689143 == round(float(last.slope), 6) + assert 1083.7629 == round(float(last.intercept), 4) + assert 0000.7955 == round(float(last.r_squared), 4) + assert 10.9202 == round(float(last.stdev), 4) + assert 235.8131 == round(float(last.line), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_sma.py b/tests/test_sma.py index d2931ba6..572c0efe 100644 --- a/tests/test_sma.py +++ b/tests/test_sma.py @@ -68,6 +68,12 @@ def test_removed(self, quotes): assert 502 - 19 == len(results) assert 251.8600 == round(float(results[len(results)-1].sma), 4) + def test_condense(self, quotes): + results = indicators.get_sma(quotes, 20).condense() + + assert 483 == len(results) + assert 251.8600 == round(float(results[len(results)-1].sma), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_sma_extended.py b/tests/test_sma_analysis.py similarity index 88% rename from tests/test_sma_extended.py rename to tests/test_sma_analysis.py index 97a76bd8..532d5cd2 100644 --- a/tests/test_sma_extended.py +++ b/tests/test_sma_analysis.py @@ -41,6 +41,12 @@ def test_removed(self, quotes): assert 502 - 19 == len(results) assert 251.8600 == round(float(results[len(results)-1].sma), 4) + def test_condense(self, quotes): + results = indicators.get_sma_analysis(quotes, 20).condense() + + assert 483 == len(results) + assert 251.8600 == round(float(results[len(results)-1].sma), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_smi.py b/tests/test_smi.py index cfef9d13..96a7ef11 100644 --- a/tests/test_smi.py +++ b/tests/test_smi.py @@ -80,7 +80,16 @@ def test_removed(self, quotes): last = results.pop() assert -52.6560 == round(float(last.smi), 4) assert -54.1903 == round(float(last.signal), 4) - + + def test_condense(self, quotes): + results = indicators.get_smi(quotes, 14, 20, 5, 3).condense() + + assert 489 == len(results) + + last = results.pop() + assert -52.6560 == round(float(last.smi), 4) + assert -54.1903 == round(float(last.signal), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_smma.py b/tests/test_smma.py index 3abfaeca..571746e5 100644 --- a/tests/test_smma.py +++ b/tests/test_smma.py @@ -47,7 +47,15 @@ def test_removed(self, quotes): last = results.pop() assert 255.67462 == round(float(last.smma), 5) - + + def test_condense(self, quotes): + results = indicators.get_smma(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 255.67462 == round(float(last.smma), 5) + def test_exceptions(self, quotes, other_quotes, mismatch_quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_starc_bands.py b/tests/test_starc_bands.py index 1f3d835c..abf489ff 100644 --- a/tests/test_starc_bands.py +++ b/tests/test_starc_bands.py @@ -69,6 +69,16 @@ def test_removed(self, quotes): assert 264.1595 == round(float(last.upper_band), 4) assert 239.5605 == round(float(last.lower_band), 4) + def test_condense(self, quotes): + results = indicators.get_starc_bands(quotes, 20, 2, 14).condense() + + assert 483 == len(results) + + last = results.pop() + assert 251.8600 == round(float(last.center_line), 4) + assert 264.1595 == round(float(last.upper_band), 4) + assert 239.5605 == round(float(last.lower_band), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_stc.py b/tests/test_stc.py index 8516e4e1..ef42ae82 100644 --- a/tests/test_stc.py +++ b/tests/test_stc.py @@ -45,7 +45,15 @@ def test_removed(self, quotes): last = results.pop() assert 19.2544 == round(float(last.stc), 4) - + + def test_condense(self, quotes): + results = indicators.get_stc(quotes, 9, 12, 26).condense() + + assert 467 == len(results) + + last = results.pop() + assert 19.2544 == round(float(last.stc), 4) + def test_exceptions(self, quotes, other_quotes, mismatch_quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_stdev.py b/tests/test_stdev.py index 701075e5..f03a98d1 100644 --- a/tests/test_stdev.py +++ b/tests/test_stdev.py @@ -77,7 +77,18 @@ def test_removed(self, quotes): assert 242.4100 == round(float(last.mean), 4) assert 0.524312 == round(float(last.z_score), 6) assert last.stdev_sma is None - + + def test_condense(self, quotes): + results = indicators.get_stdev(quotes, 10).condense() + + assert 493 == len(results) + + last = results.pop() + assert 5.4738 == round(float(last.stdev), 4) + assert 242.4100 == round(float(last.mean), 4) + assert 0.524312 == round(float(last.z_score), 6) + assert last.stdev_sma is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_stdev_channels.py b/tests/test_stdev_channels.py index a56af862..31f66de8 100644 --- a/tests/test_stdev_channels.py +++ b/tests/test_stdev_channels.py @@ -91,7 +91,18 @@ def test_removed(self, quotes): assert 257.6536 == round(float(last.upper_channel), 4) assert 213.9727 == round(float(last.lower_channel), 4) assert last.break_point is False - + + def test_condense(self, quotes): + results = indicators.get_stdev_channels(quotes, 20, 2).condense() + + assert 500 == len(results) + + last = results.pop() + assert 235.8131 == round(float(last.center_line), 4) + assert 257.6536 == round(float(last.upper_channel), 4) + assert 213.9727 == round(float(last.lower_channel), 4) + assert last.break_point is False + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_stoch.py b/tests/test_stoch.py index 9ef29172..79b46196 100644 --- a/tests/test_stoch.py +++ b/tests/test_stoch.py @@ -131,6 +131,16 @@ def test_removed(self, quotes): assert 35.5674 == round(float(last.signal), 4) assert 58.2712 == round(float(last.percent_j), 4) + def test_condense(self, quotes): + results = indicators.get_stoch(quotes, 14, 3, 3).condense() + + assert 487 == len(results) + + last = results.pop() + assert 43.1353 == round(float(last.oscillator), 4) + assert 35.5674 == round(float(last.signal), 4) + assert 58.2712 == round(float(last.percent_j), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_stoch_rsi.py b/tests/test_stoch_rsi.py index 247ab3d2..8bdf8059 100644 --- a/tests/test_stoch_rsi.py +++ b/tests/test_stoch_rsi.py @@ -79,6 +79,15 @@ def test_removed(self, quotes): assert 89.8385 == round(float(last.stoch_rsi), 4) assert 73.4176 == round(float(last.signal), 4) + def test_condense(self, quotes): + results = indicators.get_stoch_rsi(quotes, 14, 14, 3, 3).condense() + + assert 473 == len(results) + + last = results.pop() + assert 89.8385 == round(float(last.stoch_rsi), 4) + assert 73.4176 == round(float(last.signal), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_super_trend.py b/tests/test_super_trend.py index cda8e40d..de260b2f 100644 --- a/tests/test_super_trend.py +++ b/tests/test_super_trend.py @@ -61,6 +61,16 @@ def test_removed(self, quotes): assert last.super_trend == last.upper_band assert last.lower_band is None + def test_condense(self, quotes): + results = indicators.get_super_trend(quotes, 14, 3).condense() + + assert 488 == len(results) + + last = results.pop() + assert 250.7954 == round(float(last.super_trend), 4) + assert last.super_trend == last.upper_band + assert last.lower_band is None + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_t3.py b/tests/test_t3.py index 02f25e6d..119371d8 100644 --- a/tests/test_t3.py +++ b/tests/test_t3.py @@ -36,7 +36,15 @@ def test_no_quotes(self, quotes): r = indicators.get_t3(quotes[:1]) assert 1 == len(r) - + + def test_condense(self, quotes): + results = indicators.get_t3(quotes, 5, 0.7).condense() + + assert 502 == len(results) + + last = results.pop() + assert 238.9308 == round(float(last.t3), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_tema.py b/tests/test_tema.py index fb92eb64..63d493cf 100644 --- a/tests/test_tema.py +++ b/tests/test_tema.py @@ -29,6 +29,14 @@ def test_removed(self, quotes): last = results.pop() assert 238.7690 == round(float(last.tema), 4) + def test_condense(self, quotes): + results = indicators.get_tema(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 238.7690 == round(float(last.tema), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_tr.py b/tests/test_tr.py index e0808f5a..b8e07945 100644 --- a/tests/test_tr.py +++ b/tests/test_tr.py @@ -38,3 +38,11 @@ def test_no_quotes(self, quotes): r = indicators.get_tr(quotes[:1]) assert 1 == len(r) + + def test_condense(self, quotes): + results = indicators.get_tr(quotes).condense() + + assert 501 == len(results) + + last = results.pop() + assert 2.67 == round(float(last.tr), 2) diff --git a/tests/test_trix.py b/tests/test_trix.py index 78300c95..665119f6 100644 --- a/tests/test_trix.py +++ b/tests/test_trix.py @@ -39,6 +39,16 @@ def test_removed(self, quotes): assert -0.230742 == round(float(last.trix), 6) assert -0.204536 == round(float(last.signal), 6) + def test_condense(self, quotes): + results = indicators.get_trix(quotes, 20, 5).condense() + + assert 482 == len(results) + + last = results.pop() + assert 263.3216 == round(float(last.ema3), 4) + assert -0.230742 == round(float(last.trix), 6) + assert -0.204536 == round(float(last.signal), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_tsi.py b/tests/test_tsi.py index 509cb7d7..c7e3726b 100644 --- a/tests/test_tsi.py +++ b/tests/test_tsi.py @@ -49,15 +49,23 @@ def test_no_data(self, quotes): assert 1 == len(r) def test_removed(self, quotes): - results = indicators.get_tsi(quotes, 25, 13, 7) - results = results.remove_warmup_periods() + results = indicators.get_tsi(quotes, 25, 13, 7).remove_warmup_periods() assert 502 - (25 + 13 + 250) == len(results) last = results.pop() assert -28.3513 == round(float(last.tsi), 4) assert -29.3597 == round(float(last.signal), 4) - + + def test_condense(self, quotes): + results = indicators.get_tsi(quotes, 25, 13, 7).condense() + + assert 465 == len(results) + + last = results.pop() + assert -28.3513 == round(float(last.tsi), 4) + assert -29.3597 == round(float(last.signal), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_ulcer_index.py b/tests/test_ulcer_index.py index f776e470..7f4d6392 100644 --- a/tests/test_ulcer_index.py +++ b/tests/test_ulcer_index.py @@ -23,14 +23,21 @@ def test_no_data(self, quotes): assert 1 == len(r) def test_removed(self, quotes): - results = indicators.get_ulcer_index(quotes, 14) - results = results.remove_warmup_periods() + results = indicators.get_ulcer_index(quotes, 14).remove_warmup_periods() assert 502 - 13 == len(results) last = results.pop() assert 5.7255 == round(float(last.ui), 4) - + + def test_condense(self, quotes): + results = indicators.get_ulcer_index(quotes, 14).condense() + + assert 489 == len(results) + + last = results.pop() + assert 5.7255 == round(float(last.ui), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_ultimate.py b/tests/test_ultimate.py index e50d6d24..6e68b11d 100644 --- a/tests/test_ultimate.py +++ b/tests/test_ultimate.py @@ -29,14 +29,21 @@ def test_no_quotes(self, quotes): assert 1 == len(r) def test_removed(self, quotes): - results = indicators.get_ultimate(quotes, 7, 14, 28) - results = results.remove_warmup_periods() + results = indicators.get_ultimate(quotes, 7, 14, 28).remove_warmup_periods() assert 502 - 28 == len(results) last = results.pop() assert 49.5257 == round(float(last.ultimate), 4) - + + def test_condense(self, quotes): + results = indicators.get_ultimate(quotes, 7, 14, 28).condense() + + assert 474 == len(results) + + last = results.pop() + assert 49.5257 == round(float(last.ultimate), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_volatility_stop.py b/tests/test_volatility_stop.py index 88eaadcb..29b1f6fd 100644 --- a/tests/test_volatility_stop.py +++ b/tests/test_volatility_stop.py @@ -65,8 +65,7 @@ def test_no_quotes(self, quotes): assert 1 == len(r) def test_removed(self, quotes): - results = indicators.get_volatility_stop(quotes, 14, 3) - results = results.remove_warmup_periods() + results = indicators.get_volatility_stop(quotes, 14, 3).remove_warmup_periods() assert 402 == len(results) @@ -74,6 +73,15 @@ def test_removed(self, quotes): assert 249.2423 == round(float(last.sar), 4) assert last.is_stop is False + def test_condense(self, quotes): + results = indicators.get_volatility_stop(quotes, 14, 3).condense() + + assert 448 == len(results) + + last = results.pop() + assert 249.2423 == round(float(last.sar), 4) + assert last.is_stop is False + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_vortex.py b/tests/test_vortex.py index 8bbc4bfd..313290d1 100644 --- a/tests/test_vortex.py +++ b/tests/test_vortex.py @@ -40,15 +40,23 @@ def test_no_quotes(self, quotes): assert 1 == len(r) def test_removed(self, quotes): - results = indicators.get_vortex(quotes, 14) - results = results.remove_warmup_periods() + results = indicators.get_vortex(quotes, 14).remove_warmup_periods() assert 502 - 14 == len(results) last = results.pop() assert 0.8712 == round(float(last.pvi), 4) assert 1.1163 == round(float(last.nvi), 4) - + + def test_condense(self, quotes): + results = indicators.get_vortex(quotes, 14).condense() + + assert 488 == len(results) + + last = results.pop() + assert 0.8712 == round(float(last.pvi), 4) + assert 1.1163 == round(float(last.nvi), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_vwap.py b/tests/test_vwap.py index 4457d666..58211023 100644 --- a/tests/test_vwap.py +++ b/tests/test_vwap.py @@ -97,7 +97,18 @@ def test_removed(self, intraday_quotes): assert 368.2908 == round(float(last_d.vwap), 4) assert 368.2908 == round(float(last_i.vwap), 4) + + def test_condense(self, intraday_quotes): + intraday_quotes.sort(key=lambda x: x.date) + + results_int = indicators.get_vwap(intraday_quotes[:391], 2020, 12, 15, 10) + results_int = results_int.condense() + + assert 361 == len(results_int) + last_i = results_int.pop() + assert 368.2908 == round(float(last_i.vwap), 4) + def test_exceptions(self, quotes): start_date = datetime(2000, 12, 15) diff --git a/tests/test_vwma.py b/tests/test_vwma.py index e91e3b42..7b1185e1 100644 --- a/tests/test_vwma.py +++ b/tests/test_vwma.py @@ -45,7 +45,15 @@ def test_removed(self, quotes): last = results.pop() assert 242.101548 == round(float(last.vwma), 6) - + + def test_condense(self, quotes): + results = indicators.get_vwma(quotes, 10).condense() + + assert 493 == len(results) + + last = results.pop() + assert 242.101548 == round(float(last.vwma), 6) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_williams_r.py b/tests/test_williams_r.py index 26e0f263..9a94a673 100644 --- a/tests/test_williams_r.py +++ b/tests/test_williams_r.py @@ -33,7 +33,15 @@ def test_removed(self, quotes): last = results.pop() assert -52.0121 == round(float(last.williams_r), 4) - + + def test_condense(self, quotes): + results = indicators.get_williams_r(quotes, 14).condense() + + assert 489 == len(results) + + last = results.pop() + assert -52.0121 == round(float(last.williams_r), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_wma.py b/tests/test_wma.py index 9afc2e50..82aa8bd6 100644 --- a/tests/test_wma.py +++ b/tests/test_wma.py @@ -33,7 +33,15 @@ def test_removed(self, quotes): last = results.pop() assert 246.5110 == round(float(last.wma), 4) - + + def test_condense(self, quotes): + results = indicators.get_wma(quotes, 20).condense() + + assert 483 == len(results) + + last = results.pop() + assert 246.5110 == round(float(last.wma), 4) + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException): diff --git a/tests/test_zig_zag.py b/tests/test_zig_zag.py index 5d1524f5..3c4d94e8 100644 --- a/tests/test_zig_zag.py +++ b/tests/test_zig_zag.py @@ -130,6 +130,17 @@ def test_bad_quotes(self, bad_quotes): r = indicators.get_zig_zag(bad_quotes, EndType.HIGH_LOW) assert 502 == len(r) + def test_condense(self, quotes): + results = indicators.get_zig_zag(quotes, EndType.CLOSE, 3).condense() + + assert 14 == len(results) + + last = results.pop() + assert 229.99 == float(round(last.zig_zag, 2)) + assert 251.33 == float(round(last.retrace_high, 2)) + assert 229.99 == float(round(last.retrace_low, 2)) + assert "L" == last.point_type + def test_exceptions(self, quotes): from System import ArgumentOutOfRangeException with pytest.raises(ArgumentOutOfRangeException):