Skip to content
This repository has been archived by the owner on Oct 30, 2023. It is now read-only.

Got exception from getCandlestickBars() #102

Closed
blaizechuang opened this issue Mar 23, 2018 · 9 comments
Closed

Got exception from getCandlestickBars() #102

blaizechuang opened this issue Mar 23, 2018 · 9 comments

Comments

@blaizechuang
Copy link

Hi, I got an exception after calling following code
client.getCandlestickBars(TradingPairSymbols.BTCPairs.ETH_BTC, CandlestickInterval.DAILY);

It seems that the type mapping in [BinanceApiServiceGenerator.java:60] is incorrect.

Stacktrace:
com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Can not construct instance of java.lang.Long from String value ("0.08000000"): not a valid Long value at
[Source: okhttp3.ResponseBody$BomAwareReader@5c25378; line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"]) at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:60) at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:89)
at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:94)
at
com.dpt.ileopard.binanceapitest.MainActivity$4.run(MainActivity.java:117) at java.lang.Thread.run(Thread.java:764)

@freezerdragon
Copy link

I am facing the same issue either. Is there any solution found so far?

@joaopsilva
Copy link
Member

joaopsilva commented May 10, 2018

Hi, I'm unable to reproduce your problem, running client.getCandlestickBars("ETHBTC", CandlestickInterval.DAILY) works well for me. Can you please share your code @freezerdragon @blaizechuang ? Thanks.

@freezerdragon
Copy link

freezerdragon commented May 10, 2018

Hello @joaopsilva , thanks for quick response. I am trying to use this library for an android project. And importing it from both https://jitpack.io/#binance-exchange/binance-java-api or compiled JAR library. Neither worked so far.

My code is straightforward as ;

Log.d("BINANCE", "Clicked");
        BinanceApiClientFactory clientFactory = BinanceApiClientFactory.newInstance();
        //sync
        BinanceApiRestClient client = clientFactory.newRestClient();
        List<Candlestick> candlesticks = client.getCandlestickBars("NEOETH", CandlestickInterval.WEEKLY);

When I run this, I get ->

05-11 01:06:00.296 24783-24783/com.cryptodragon.android E/AndroidRuntime: FATAL EXCEPTION: main
    Process: com.cryptodragon.android, PID: 24783
    com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Long` from String "0.09700000": not a valid Long value
        at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"])
        at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:60)
        at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:96)
        at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:101)
        at com.cryptodragon.android.Activities.Home.getKlines(Home.java:333)
        at com.cryptodragon.android.Activities.Home$4.onClick(Home.java:145)
        at android.view.View.performClick(View.java:5637)
        at android.view.View$PerformClick.run(View.java:22433)
        at android.os.Handler.handleCallback(Handler.java:751)
        at android.os.Handler.dispatchMessage(Handler.java:95)
        at android.os.Looper.loop(Looper.java:154)
        at android.app.ActivityThread.main(ActivityThread.java:6186)
        at java.lang.reflect.Method.invoke(Native Method)
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889)
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779)
     Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Long` from String "0.09700000": not a valid Long value
        at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"])
        at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1548)
        at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:910)
        at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer._parseLong(NumberDeserializers.java:584)
        at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer.deserialize(NumberDeserializers.java:557)
        at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer.deserialize(NumberDeserializers.java:535)
        at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:127)
        at com.fasterxml.jackson.databind.deser.impl.BeanAsArrayDeserializer.deserialize(BeanAsArrayDeserializer.java:119)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
        at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1611)
        at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1203)
        at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
        at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
        at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:122)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:217)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
        at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:91)
        at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:52)
        at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:96) 
        at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:101) 
        at com.cryptodragon.android.Activities.Home.getKlines(Home.java:333) 
        at com.cryptodragon.android.Activities.Home$4.onClick(Home.java:145) 
        at android.view.View.performClick(View.java:5637) 
        at android.view.View$PerformClick.run(View.java:22433) 
        at android.os.Handler.handleCallback(Handler.java:751) 
        at android.os.Handler.dispatchMessage(Handler.java:95) 
        at android.os.Looper.loop(Looper.java:154) 
        at android.app.ActivityThread.main(ActivityThread.java:6186) 
        at java.lang.reflect.Method.invoke(Native Method) 
        at com.android.internal.os.ZygoteInit$MethodAndArgsCaller.run(ZygoteInit.java:889) 
        at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:779) 

This exact result.

@freezerdragon
Copy link

@joaopsilva is there any progress?

@joaopsilva
Copy link
Member

Hi @freezerdragon , I am really unable to reproduce this problem, I've tried on multiple JDKs and it works. The retrofit library has since been updated, could you please update your repo and try again? Thanks.

@eunomiadev
Copy link

eunomiadev commented Aug 9, 2019

Same error here, only affected on Android
Repo:

implementation 'com.github.binance-exchange:binance-java-api:master-SNAPSHOT'

Code:

BinanceApiRestClient client = BinanceApiClientFactory.newInstance().newRestClient();
List<Candlestick> candlestickBars = client.getCandlestickBars("ZRXETH", CandlestickInterval.HOURLY, 100, null, null);
System.out.println("Candlestick size " + candlestickBars.size());

Error logs:

E/AndroidRuntime: FATAL EXCEPTION: Thread-5
    Process: cryptomaniac.co.id.cmrandroserver, PID: 21334
    com.binance.api.client.exception.BinanceApiException: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Long` from String "0.00094076": not a valid Long value
        at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"])
        at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:80)
        at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:97)
        at tester.CandleTester.start(CandleTester.java:14)
        at cryptomaniac.co.id.cmrandroserver.MainActivity.lambda$onCreate$0(MainActivity.java:29)
        at cryptomaniac.co.id.cmrandroserver.-$$Lambda$MainActivity$S6Ew4qP_TgBDrVlGukzcTJZjv_A.run(Unknown Source:0)
        at java.lang.Thread.run(Thread.java:764)
     Caused by: com.fasterxml.jackson.databind.exc.InvalidFormatException: Cannot deserialize value of type `java.lang.Long` from String "0.00094076": not a valid Long value
        at [Source: (okhttp3.ResponseBody$BomAwareReader); line: 1, column: 17] (through reference chain: java.util.ArrayList[0]->com.binance.api.client.domain.market.Candlestick["closeTime"])
        at com.fasterxml.jackson.databind.DeserializationContext.weirdStringException(DeserializationContext.java:1552)
        at com.fasterxml.jackson.databind.DeserializationContext.handleWeirdStringValue(DeserializationContext.java:912)
        at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer._parseLong(NumberDeserializers.java:584)
        at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer.deserialize(NumberDeserializers.java:557)
        at com.fasterxml.jackson.databind.deser.std.NumberDeserializers$LongDeserializer.deserialize(NumberDeserializers.java:535)
        at com.fasterxml.jackson.databind.deser.impl.MethodProperty.deserializeAndSet(MethodProperty.java:129)
        at com.fasterxml.jackson.databind.deser.impl.BeanAsArrayDeserializer.deserialize(BeanAsArrayDeserializer.java:119)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:286)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:245)
        at com.fasterxml.jackson.databind.deser.std.CollectionDeserializer.deserialize(CollectionDeserializer.java:27)
        at com.fasterxml.jackson.databind.ObjectReader._bindAndClose(ObjectReader.java:1683)
        at com.fasterxml.jackson.databind.ObjectReader.readValue(ObjectReader.java:1219)
        at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:32)
        at retrofit2.converter.jackson.JacksonResponseBodyConverter.convert(JacksonResponseBodyConverter.java:23)
        at retrofit2.ServiceMethod.toResponse(ServiceMethod.java:122)
        at retrofit2.OkHttpCall.parseResponse(OkHttpCall.java:217)
        at retrofit2.OkHttpCall.execute(OkHttpCall.java:180)
        at retrofit2.ExecutorCallAdapterFactory$ExecutorCallbackCall.execute(ExecutorCallAdapterFactory.java:91)
        at com.binance.api.client.impl.BinanceApiServiceGenerator.executeSync(BinanceApiServiceGenerator.java:72)
        at com.binance.api.client.impl.BinanceApiRestClientImpl.getCandlestickBars(BinanceApiRestClientImpl.java:97) 
        at tester.CandleTester.start(CandleTester.java:14) 
        at cryptomaniac.co.id.cmrandroserver.MainActivity.lambda$onCreate$0(MainActivity.java:29) 
        at cryptomaniac.co.id.cmrandroserver.-$$Lambda$MainActivity$S6Ew4qP_TgBDrVlGukzcTJZjv_A.run(Unknown Source:0) 
        at java.lang.Thread.run(Thread.java:764) 

@eunomiadev
Copy link

eunomiadev commented Aug 9, 2019

Added pull request joaopsilva#23 @joaopsilva

@JitanderVerma
Copy link

Facing same error.. Any help?

@xXSkyWalkerXx1
Copy link

Still the same... xD

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

No branches or pull requests

6 participants