Skip to content
This repository has been archived by the owner on May 12, 2019. It is now read-only.

Division by zero in updated WalkForward example #16

Closed
dan-lind opened this issue Oct 25, 2014 · 2 comments
Closed

Division by zero in updated WalkForward example #16

dan-lind opened this issue Oct 25, 2014 · 2 comments
Labels

Comments

@dan-lind
Copy link
Contributor

When running the updated WalkForward example with release 0.5, I'm now seeing:

Exception in thread "main" java.lang.ArithmeticException: Division by zero
    at java.math.BigDecimal.divide(BigDecimal.java:1669)
    at eu.verdelhan.ta4j.TADecimal.dividedBy(TADecimal.java:117)
    at eu.verdelhan.ta4j.indicators.trackers.RSIIndicator.relativeStrength(RSIIndicator.java:66)
    at eu.verdelhan.ta4j.indicators.trackers.RSIIndicator.getValue(RSIIndicator.java:47)
    at eu.verdelhan.ta4j.indicators.trackers.RSIIndicator.getValue(RSIIndicator.java:34)
    at eu.verdelhan.ta4j.strategies.SupportStrategy.shouldEnter(SupportStrategy.java:57)
    at eu.verdelhan.ta4j.strategies.CombinedBuyAndSellStrategy.shouldEnter(CombinedBuyAndSellStrategy.java:52)
    at eu.verdelhan.ta4j.strategies.AndStrategy.shouldEnter(AndStrategy.java:51)
    at eu.verdelhan.ta4j.strategies.AbstractStrategy.shouldOperate(AbstractStrategy.java:37)
    at eu.verdelhan.ta4j.TimeSeries.run(TimeSeries.java:235)
    at eu.verdelhan.ta4j.TimeSeries.run(TimeSeries.java:219)
    at ta4jexamples.walkforward.WalkForward.main(WalkForward.java:80)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:134)
@mdeverdelhan
Copy link
Owner

In fact the arithmetic exception occurs when running RSI-2 strategy.

Stacktrace:

Exception in thread "main" java.lang.ArithmeticException: Division by zero
    at java.math.BigDecimal.divide(BigDecimal.java:1655)
    at eu.verdelhan.ta4j.TADecimal.dividedBy(TADecimal.java:117)
    at eu.verdelhan.ta4j.indicators.trackers.RSIIndicator.relativeStrength(RSIIndicator.java:66)
    at eu.verdelhan.ta4j.indicators.trackers.RSIIndicator.getValue(RSIIndicator.java:47)
    at eu.verdelhan.ta4j.indicators.trackers.RSIIndicator.getValue(RSIIndicator.java:34)
    at eu.verdelhan.ta4j.strategies.SupportStrategy.shouldEnter(SupportStrategy.java:57)
    at eu.verdelhan.ta4j.strategies.CombinedBuyAndSellStrategy.shouldEnter(CombinedBuyAndSellStrategy.java:52)
    at eu.verdelhan.ta4j.strategies.AndStrategy.shouldEnter(AndStrategy.java:51)
    at eu.verdelhan.ta4j.strategies.AbstractStrategy.shouldOperate(AbstractStrategy.java:37)
    at eu.verdelhan.ta4j.TimeSeries.run(TimeSeries.java:235)
    at eu.verdelhan.ta4j.TimeSeries.run(TimeSeries.java:219)
    at ta4jexamples.strategies.RSI2Strategy.main(RSI2Strategy.java:89)

It's due to the replacement of doubles by TADecimals. I don't know how to address it yet (i.e. for now I didn't find enough time: my son has been sick for 2 days).

mdeverdelhan added a commit that referenced this issue Oct 28, 2014
@mdeverdelhan
Copy link
Owner

Fixed in 0.6-SNAPSHOT.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
Projects
None yet
Development

No branches or pull requests

2 participants