knowm / XChange

XChange is a Java library providing a streamlined API for interacting with 60+ Bitcoin and Altcoin exchanges providing a consistent interface for trading and accessing market data.
http://knowm.org/open-source/xchange/
MIT License
3.81k stars 1.93k forks source link

Crash with CexIO when retrieving cancelled archived order #2157

Open T-Spoon opened 6 years ago

T-Spoon commented 6 years ago

When retrieving an trade history from CexIO, if the trade history contains any cancelled orders ("status": "c"), it will fail to parse the response.

The json response for a cancelled order is:

  {
    "id": "1",
    "type": "sell",
    "time": "2018-01-14T15:44:42.402Z",
    "lastTxTime": "2018-01-14T15:46:21.457Z",
    "lastTx": "5423491113",
    "pos": null,
    "status": "c",
    "symbol1": "XRP",
    "symbol2": "EUR",
    "amount": "67.20000000",
    "kind": "api",
    "price": "1.57",
    "remains": "67.200000",
    "a:XRP:cds": "67.200000",
    "tradingFeeMaker": "0.16",
    "tradingFeeTaker": "0.25",
    "tradingFeeUserVolumeAmount": "75631402",
    "orderId": "1"
  },

Relevant code is here: https://github.com/timmolter/XChange/blob/9235d1d743aaef8202ad5a2f4d70714b5baf9439/xchange-cexio/src/main/java/org/knowm/xchange/cexio/dto/trade/CexIOArchivedOrder.java#L195

filled.get(counter) and filled.get(base)are nullable here, because cancelled orders won't have been filled.

Alfishan commented 6 years ago

Any update on this @T-Spoon. any workaround?

npomfret commented 6 years ago

Do you have a stack trace and an another example of the data that causes the crash?

Alfishan commented 6 years ago

As @T-Spoon mentioned, " When retrieving a trade history from CexIO, if the trade history contains any cancelled orders ("status": "c"), it will fail to parse the response." or when you pass only currencyPair.

Jun 29, 2018 12:26:07 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [dispatcherServlet] in context with path [] threw exception si.mazi.rescu.HttpStatusIOException: (was java.lang.NullPointerException) (through reference chain: java.util.ArrayList[0]) at si.mazi.rescu.ResponseReader.read(ResponseReader.java:104) at si.mazi.rescu.RestInvocationHandler.mapInvocationResult(RestInvocationHandler.java:175) at si.mazi.rescu.RestInvocationHandler.receiveAndMap(RestInvocationHandler.java:163) at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:119) at com.sun.proxy.$Proxy126.archivedOrders(Unknown Source) at org.knowm.xchange.cexio.service.CexIOTradeServiceRaw.archivedOrders(CexIOTradeServiceRaw.java:182)

maybe it's an issue with a CexIOArchivedOrder.Deserializer method.

Thanks

Alfishan commented 6 years ago

14:38:32.633 [default] [main] DEBUG si.mazi.rescu.ResponseReader - Parsing response as java.util.List failed: com.fasterxml.jackson.databind.JsonMappingException: Failed to parse {"id":"6163963583","type":"sell","time":"2018-05-07T11:10:05.135Z","lastTxTime":"2018-05-07T11:13:45.205Z","lastTx":"6163981142","pos":null,"status":"c","symbol1":"BTC","symbol2":"USD","amount":"0.00200000","kind":"api","price":"9324.5","remains":"0.00200000","a:BTC:cds":"0.00200000","tradingFeeMaker":"0.16","tradingFeeTaker":"0.25","tradingFeeUserVolumeAmount":"0","orderId":"6163963583"} (through reference chain: java.util.ArrayList[2]) Exception in thread "main" si.mazi.rescu.HttpStatusIOException: Failed to parse {"id":"6163963583","type":"sell","time":"2018-05-07T11:10:05.135Z","lastTxTime":"2018-05-07T11:13:45.205Z","lastTx":"6163981142","pos":null,"status":"c","symbol1":"BTC","symbol2":"USD","amount":"0.00200000","kind":"api","price":"9324.5","remains":"0.00200000","a:BTC:cds":"0.00200000","tradingFeeMaker":"0.16","tradingFeeTaker":"0.25","tradingFeeUserVolumeAmount":"0","orderId":"6163963583"} (through reference chain: java.util.ArrayList[2]) at si.mazi.rescu.ResponseReader.read(ResponseReader.java:104) at si.mazi.rescu.RestInvocationHandler.mapInvocationResult(RestInvocationHandler.java:175) at si.mazi.rescu.RestInvocationHandler.receiveAndMap(RestInvocationHandler.java:163) at si.mazi.rescu.RestInvocationHandler.invoke(RestInvocationHandler.java:119) at com.sun.proxy.$Proxy11.archivedOrders(Unknown Source) at org.knowm.xchange.cexio.service.CexIOTradeServiceRaw.archivedOrders(CexIOTradeServiceRaw.java:182) at org.knowm.xchange.examples.cexio.trade.TradeDemo.printArchivedOrder(TradeDemo.java:81) at org.knowm.xchange.examples.cexio.trade.TradeDemo.main(TradeDemo.java:32)`

here is the Logs from CexIOTradeServiceRaw.archivedOrders(...) not able to parse when "status": "c".

npomfret commented 6 years ago

Any what version xchange are you using?

Alfishan commented 6 years ago

@npomfret I am using V 4.3.7.