Is there a bug in the EMA calculation #50
gokcenkarasu
started this conversation in
Configs
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I developed some new feature in your project and I am writing testing class for calculation class, I found a bug in the EMA calculation class.
Cloud you please validate it for us?
@test
public void testEMA() {
List closingPrices = Arrays.asList(100.0, 105.0, 110.0, 115.0, 120.0);
EMA ema = new EMA(closingPrices, 3, false);
Expectation : 105 , But you are updating currentEMA with new numbers that in closing array, after it was found correct number.
java.lang.AssertionError: expected:<105.0> but was:<110.0>
at org.junit.Assert.fail(Assert.java:89)
at org.junit.Assert.failNotEquals(Assert.java:835)
at org.junit.Assert.assertEquals(Assert.java:555)
at org.junit.Assert.assertEquals(Assert.java:685)
currentEMA = currentEMA / (double) period;
if (historyNeeded) EMAhistory.add(currentEMA);
Beta Was this translation helpful? Give feedback.
All reactions