Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

McGinley Dynamic unit test #101

Merged
merged 1 commit into from
Dec 27, 2023
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 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()