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

Commit

Permalink
fixed DMI calculation
Browse files Browse the repository at this point in the history
  • Loading branch information
peerchemist committed May 5, 2019
1 parent b191a58 commit 4929446
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 4 deletions.
5 changes: 4 additions & 1 deletion finta/finta.py
Original file line number Diff line number Diff line change
Expand Up @@ -810,10 +810,13 @@ def DMI(cls, ohlc: DataFrame, period: int = 14) -> Series:
relative strength index. DMI tells you when to be long or short.
It is especially useful for trend trading strategies because it differentiates between strong and weak trends,
allowing the trader to enter only the strongest trends.
source https://www.fidelity.com/learning-center/trading-investing/technical-analysis/technical-indicator-guide/dmi
:period: Specifies the number of Periods used for DMI calculation
"""

ohlc["up_move"] = ohlc["high"].diff()
ohlc["down_move"] = ohlc["low"].diff()
ohlc["down_move"] = -ohlc["low"].diff()

DMp = []
DMm = []
Expand Down
6 changes: 3 additions & 3 deletions tests/test_unit.py
Original file line number Diff line number Diff line change
Expand Up @@ -348,8 +348,8 @@ def test_dmi():
assert isinstance(dmi["DI+"], series.Series)
assert isinstance(dmi["DI-"], series.Series)

assert dmi["DI+"].values[-1] == 0.32826999511691435
assert dmi["DI-"].values[-1] == 10.09866984475557
assert dmi["DI+"].values[-1] == 4.2514733223789332
assert dmi["DI-"].values[-1] == 20.093318043215021


def test_adx():
Expand All @@ -358,7 +358,7 @@ def test_adx():
adx = TA.ADX(ohlc)

assert isinstance(adx, series.Series)
assert adx.values[-1] == 66.589993072391422
assert adx.values[-1] == 54.781005617031234


def test_stoch():
Expand Down

0 comments on commit 4929446

Please sign in to comment.