Skip to content

Commit

Permalink
Fix calculation of ALMA to match trading view (#129)
Browse files Browse the repository at this point in the history
  • Loading branch information
nardew authored Apr 19, 2024
1 parent 9b1e933 commit 0776328
Show file tree
Hide file tree
Showing 4 changed files with 11 additions and 9 deletions.
7 changes: 6 additions & 1 deletion CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,10 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

## [Pending release]

## [2.2.1] - 2024-04-19

- fix `ALMA` calculation

## [2.2.0] - 2024-04-05

- new `IBS` indicator
Expand Down Expand Up @@ -100,7 +104,8 @@ The project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html

- the official release of `talipp`

[Pending release]: https://github.com/nardew/talipp/compare/2.2.0...HEAD
[Pending release]: https://github.com/nardew/talipp/compare/2.2.1...HEAD
[2.2.1]: https://github.com/nardew/talipp/releases/tag/2.2.1
[2.2.0]: https://github.com/nardew/talipp/releases/tag/2.2.0
[2.1.2]: https://github.com/nardew/talipp/releases/tag/2.1.2
[2.1.1]: https://github.com/nardew/talipp/compare/2.1.0...2.1.1
Expand Down
5 changes: 1 addition & 4 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
# talipp - Incremental Technical Analysis Library

![](https://img.shields.io/badge/python-3.8-blue.svg)
![](https://img.shields.io/badge/python-3.9-blue.svg)
![](https://img.shields.io/badge/python-3.10-blue.svg)
![](https://img.shields.io/badge/python-3.11-blue.svg)
![python](https://img.shields.io/pypi/pyversions/talipp?logo=python)
![PyPy](https://img.shields.io/badge/pypy-3-blue.svg)
![unit tests](https://github.com/nardew/talipp/workflows/unit%20tests/badge.svg)

Expand Down
2 changes: 1 addition & 1 deletion talipp/indicators/ALMA.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def __init__(self, period: int,
self.w = []
self.w_sum = 0.0
s = self.period / float(self.sigma)
m = int((self.period - 1) * self.offset)
m = (self.period - 1) * self.offset
for i in range(0, self.period):
self.w.append(exp(-1 * (i - m) * (i - m) / (2 * s * s)))
self.w_sum += self.w[-1]
Expand Down
6 changes: 3 additions & 3 deletions test/test_ALMA.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ def test_init(self):

print(ind)

self.assertAlmostEqual(ind[-3], 9.795859, places = 5)
self.assertAlmostEqual(ind[-2], 10.121439, places = 5)
self.assertAlmostEqual(ind[-1], 10.257038, places = 5)
self.assertAlmostEqual(ind[-3], 10.053326, places = 5)
self.assertAlmostEqual(ind[-2], 10.267585, places = 5)
self.assertAlmostEqual(ind[-1], 10.264363, places = 5)

def test_update(self):
self.assertIndicatorUpdate(ALMA(9, 0.85, 6, self.input_values))
Expand Down

0 comments on commit 0776328

Please sign in to comment.