ta-rs icon indicating copy to clipboard operation
ta-rs copied to clipboard

Feat: Add weighted moving average (WMA)

Open menkaru opened this issue 2 years ago • 6 comments

Hey there, this PR implements the weighted moving average indicator, which assigns weights that decrease linearly (n, n-1, etc) as opposed to exponentially as in the EMA.

From what I can see the WMA seems to be a requirement to implement the hull moving average (Issue #36), which I'll likely be tackling next.

menkaru avatar Aug 07 '21 18:08 menkaru

Update: I finished implementing the hull moving average on this branch. If you'd like I can merge that with this pull request, or just submit a new one later.

Edit: Solves #36

menkaru avatar Aug 07 '21 21:08 menkaru

My PR now also includes all three new indicators merged from @menkaru's resp. branches.

virtualritz avatar Nov 22 '21 15:11 virtualritz

@menkaru, is your branch for QuantitativeQualitativeEstimation WIP/unfinished? The indicators::quantitative_qualitative_estimation::tests::test_next for this feature fails for me:

thread 'indicators::quantitative_qualitative_estimation::tests::test_next' panicked at 'assertion failed: `(left == right)`
  left: `(44.52, 24.53)`,
 right: `(46.11, 23.18)`', src/indicators/quantitative_qualitative_estimation.rs:241:9

virtualritz avatar Nov 22 '21 16:11 virtualritz

@virtualritz, it's been a while but iirc I ran into issue #46 due to all the EMAs required. It's pretty much done, but it just gives slightly different results to the reference I used (pandas_ta) to generate the test cases.

menkaru avatar Nov 23 '21 00:11 menkaru

What does "pretty much done" mean? You consider it close enough and won't touch the code or minor tweaks are needed to fix? In the former case we could just update the test case values, I guess?

virtualritz avatar Nov 23 '21 15:11 virtualritz

Sorry, I should have been more specific. The implementation is correct and complete. From what I can tell the problem is the same as issue #46, which seems to require structural changes to the library. I considered changing the test cases, but the results didn't seem close enough to warrant it.

For what it's worth, I wouldn't merge it until a fix for #46 is decided on.

menkaru avatar Nov 23 '21 17:11 menkaru

@menkaru Sorry, it took way too long.. Thanks for the PR!

greyblake avatar Oct 21 '22 15:10 greyblake