patriques82 / alphavantage4j

(Repository is not maintained anymore) A Java wrapper to get stock data and stock indicators from the Alpha Vantage API
https://www.alphavantage.co/
Apache License 2.0
124 stars 73 forks source link

macd function is not working (I think) #19

Closed solidgains closed 6 years ago

solidgains commented 6 years ago

I grabbed the method call from your macd unit test to use in my demo app. It is returning an error. I can't seem to figure out what the issue is. For what its worth, thanks for this great sdk! If you can pinpoint the issue I may be able to make the fix and contribute.

        MACD resp = technicalIndicators.macd("MSFT",
                                             Interval.FIFTEEN_MIN,
                                             TimePeriod.of(10),
                                             FastPeriod.of(10),
                                             SlowPeriod.of(26),
                                             SignalPeriod.of(10));

        log.error(resp.getData().get(1).getMacd() + "");

and it returns

**org.patriques.output.AlphaVantageException: Invalid API call. Please retry or visit the documentation (https://www.alphavantage.co/documentation/) for MACD.**
    at org.patriques.output.JsonParser.parseJson(JsonParser.java:55) ~[sdk-1.jar:1.0]
    at org.patriques.output.technicalindicators.MACD.from(MACD.java:32) ~[sdk-1.jar:1.0]
    at org.patriques.TechnicalIndicators.macd(TechnicalIndicators.java:377) ~[sdk-1.jar:1.0]
    at com.handeware.handetrade.tradebot.loop.EquitiesSwingTrader.comeAlive(EquitiesSwingTrader.java:28) ~[classes/:na]
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[na:1.8.0_121]
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:62) ~[na:1.8.0_121]
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[na:1.8.0_121]
    at java.lang.reflect.Method.invoke(Method.java:498) ~[na:1.8.0_121]
    at org.springframework.scheduling.support.ScheduledMethodRunnable.run(ScheduledMethodRunnable.java:65) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at org.springframework.scheduling.support.DelegatingErrorHandlingRunnable.run(DelegatingErrorHandlingRunnable.java:54) ~[spring-context-4.3.13.RELEASE.jar:4.3.13.RELEASE]
    at java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:511) [na:1.8.0_121]
    at java.util.concurrent.FutureTask.runAndReset(FutureTask.java:308) [na:1.8.0_121]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.access$301(ScheduledThreadPoolExecutor.java:180) [na:1.8.0_121]
    at java.util.concurrent.ScheduledThreadPoolExecutor$ScheduledFutureTask.run(ScheduledThreadPoolExecutor.java:294) [na:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1142) [na:1.8.0_121]
    at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:617) [na:1.8.0_121]
    at java.lang.Thread.run(Thread.java:745) [na:1.8.0_121]
patriques82 commented 6 years ago

I have pushed a commit to fix the issue. Try again, and please tell me if it worked or not. The problem was that I had not supplied the correct arguments in the api.

solidgains commented 6 years ago

Thank you!