Skip to content

Commit

Permalink
McGinley Dynamic test (#101)
Browse files Browse the repository at this point in the history
  • Loading branch information
nardew committed Dec 27, 2023
1 parent 8c3cf42 commit 0ec35c8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 1 deletion.
2 changes: 1 addition & 1 deletion tests/TalippTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ def assertIndicatorDelete(self, indicator: Indicator, iterations_no: int = 20):
if isinstance(last_input_value, OHLCV):
new_val = OHLCV((i + 1)**2, (i + 3)**2, (i + 5)**2, (i + 7)**2, i**2)
else:
new_val = i
new_val = (i + 1)**2
indicator.add_input_value(new_val)

for i in range(1, iterations_no):
Expand Down
32 changes: 32 additions & 0 deletions tests/test_McGinleyDynamic.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,32 @@
import unittest

from talipp.indicators import McGinleyDynamic

from TalippTest import TalippTest


class Test(TalippTest):
def setUp(self) -> None:
self.input_values = list(TalippTest.CLOSE_TMPL)

def test_init(self):
ind = McGinleyDynamic(14, self.input_values)

print(ind)

self.assertAlmostEqual(ind[-3], 8.839868, places = 5)
self.assertAlmostEqual(ind[-2], 8.895229, places = 5)
self.assertAlmostEqual(ind[-1], 8.944634, places = 5)

def test_update(self):
self.assertIndicatorUpdate(McGinleyDynamic(14, self.input_values))

def test_delete(self):
self.assertIndicatorDelete(McGinleyDynamic(14, self.input_values))

def test_purge_oldest(self):
self.assertIndicatorPurgeOldest(McGinleyDynamic(14, self.input_values))


if __name__ == '__main__':
unittest.main()

0 comments on commit 0ec35c8

Please sign in to comment.