Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
10 changes: 6 additions & 4 deletions stockstats.py
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down
4 changes: 4 additions & 0 deletions test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"]
Expand Down