diff --git a/README.md b/README.md index 69869418..4386c393 100644 --- a/README.md +++ b/README.md @@ -4,7 +4,7 @@ [![codecov](https://codecov.io/gh/jealous/stockstats/branch/master/graph/badge.svg?token=IFMD1pVJ7T)](https://codecov.io/gh/jealous/stockstats) [![pypi](https://img.shields.io/pypi/v/stockstats.svg)](https://pypi.python.org/pypi/stockstats) -VERSION: 0.6.6 +VERSION: 0.6.7 ## Introduction diff --git a/stockstats.py b/stockstats.py index 278f9d35..df9a8fa7 100644 --- a/stockstats.py +++ b/stockstats.py @@ -969,11 +969,13 @@ def _shifted_cr_sma(self, cr, window): cr_sma = self.sma(cr, window) return self.s_shift(cr_sma, -int(window / 2.5 + 1)) - def _tp(self): + def _tp(self) -> pd.Series: if "amount" in self: - return self.amount.values / self.volume.values - total = self.close.values + self.high.values + self.low.values - return self.to_series(total / 3.0) + tp = self.amount.values / self.volume.values + else: + total = self.close.values + self.high.values + self.low.values + tp = total / 3.0 + return self.to_series(tp) def _get_tp(self, meta: _Meta): self[meta.name] = self._tp() diff --git a/test.py b/test.py index 96080f83..02de2f83 100644 --- a/test.py +++ b/test.py @@ -728,6 +728,10 @@ def test_mfi(self): assert_that(mfi_15.loc[first], near_to(0.5)) assert_that(mfi_15.loc[last], near_to(0.6733)) + def test_mfi_with_amount(self): + mfi = self._supor['mfi'] + assert_that(mfi.loc[20160817], near_to(0.48265)) + def test_ker(self): stock = self.get_stock_90days() k = stock["ker"]