Skip to content
This repository has been archived by the owner on Sep 2, 2022. It is now read-only.

Commit

Permalink
fix EFI indicator
Browse files Browse the repository at this point in the history
  • Loading branch information
baihou committed Aug 5, 2019
1 parent 3ad9088 commit aff1569
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion finta/finta.py
Expand Up @@ -1248,7 +1248,8 @@ def EFI(cls, ohlcv: DataFrame, period: int = 13) -> Series:
"""Elder's Force Index is an indicator that uses price and volume to assess the power
behind a move or identify possible turning points."""

fi = pd.Series((ohlcv["close"] - ohlcv["close"].diff()) * ohlcv["volume"])
# https://tradingsim.com/blog/elders-force-index/
fi = pd.Series(ohlcv["close"].diff() * ohlcv["volume"])
return pd.Series(
fi.ewm(ignore_na=False, span=period).mean(),
name="{0} period Force Index".format(period),
Expand Down
6 changes: 5 additions & 1 deletion tests/test_unit.py
Expand Up @@ -537,7 +537,11 @@ def test_efi():
efi = TA.EFI(ohlc)

assert isinstance(efi, series.Series)
assert efi.values[-1] == 6918216.7131493781
assert efi.values[1] > 0
assert efi.values[2] > 0

assert efi.values[-2] < 0
assert efi.values[-1] < 0


def test_cfi():
Expand Down

0 comments on commit aff1569

Please sign in to comment.