[XChange-okex] example OkexTradesDemo cant get trades data

Open
#4,457 1 comment 0 reactions 0 assignees View on GitHub

Maintainers usually reply within 2 days

Nobody has claimed this yet.

Assessment

Difficulty
2/5
Estimated time
1-3 hours
Newbie friendliness
35/100
Issue type
Bug
Clarity
Clearly specified
Activity status
Stale
Tech stack
java
Domain
api

Research direction

Start by running the OkexTradesDemo example and inspect OkexTradesDemo.java, especially generic() at line 35, where the empty result is indexed. Check the getTrades response and determine the expected handling when no trades are returned; done means the example no longer throws IndexOutOfBoundsException and handles the returned data appropriately.

Written by the indexing model from the issue text.

Description

`11:57:08.787 [default] [main] DEBUG org.knowm.xchange.ExchangeFactory - Creating exchange from specification
11:57:08.787 [default] [main] DEBUG org.knowm.xchange.ExchangeFactory - Creating default exchange from class name
11:57:08.803 [default] [main] DEBUG o.knowm.xchange.okex.v5.OkexExchange - Loading metadata from okex.json
11:57:09.412 [default] [main] DEBUG o.knowm.xchange.okex.v5.OkexExchange - ExchangeMetaData [currencyPairs={}, currencies={ALGO=CurrencyMetaData [scale=null, withdrawalFee=0.0025, minWithdrawalAmount=null, walletHealth=null], ATOM=CurrencyMetaData [scale=null, withdrawalFee=0.005, minWithdrawalAmount=null, walletHealth=null], BTC=CurrencyMetaData [scale=null, withdrawalFee=0.0005, minWithdrawalAmount=null, walletHealth=null], EOS=CurrencyMetaData [scale=null, withdrawalFee=0.1, minWithdrawalAmount=null, walletHealth=null], ETC=CurrencyMetaData [scale=null, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], ETH=CurrencyMetaData [scale=null, withdrawalFee=0.01, minWithdrawalAmount=null, walletHealth=null], LEO=CurrencyMetaData [scale=null, withdrawalFee=0.5, minWithdrawalAmount=null, walletHealth=null], LTC=CurrencyMetaData [scale=null, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], NEO=CurrencyMetaData [scale=null, withdrawalFee=0, minWithdrawalAmount=null, walletHealth=null], OMG=CurrencyMetaData [scale=null, withdrawalFee=0.1, minWithdrawalAmount=null, walletHealth=null], QTUM=CurrencyMetaData [scale=null, withdrawalFee=0.01, minWithdrawalAmount=null, walletHealth=null], TRX=CurrencyMetaData [scale=null, withdrawalFee=1, minWithdrawalAmount=null, walletHealth=null], USDT=CurrencyMetaData [scale=null, withdrawalFee=8, minWithdrawalAmount=null, walletHealth=null], VEE=CurrencyMetaData [scale=null, withdrawalFee=100, minWithdrawalAmount=null, walletHealth=null], XLM=CurrencyMetaData [scale=null, withdrawalFee=0.01, minWithdrawalAmount=null, walletHealth=null], XMR=CurrencyMetaData [scale=null, withdrawalFee=0.04, minWithdrawalAmount=null, walletHealth=null], XRP=CurrencyMetaData [scale=null, withdrawalFee=0.15, minWithdrawalAmount=null, walletHealth=null], ZEC=CurrencyMetaData [scale=null, withdrawalFee=0.001, minWithdrawalAmount=null, walletHealth=null], ZRX=CurrencyMetaData [scale=null, withdrawalFee=2, minWithdrawalAmount=null, walletHealth=null]}, futures=null, options=null, publicRateLimits=[], privateRateLimits=null, shareRateLimits=true]
11:57:09.694 [default] [main] INFO o.knowm.xchange.okex.v5.OkexExchange - Calling Remote Init...
11:57:10.881 [default] [main] INFO o.k.x.e.i.LoggingInterceptor - org.knowm.xchange.okex.v5.Okex.getInstruments took 1187 ms.
11:57:10.897 [default] [main] WARN si.mazi.rescu.RestMethodMetadata - GET request declared as consuming method body as application/json. While body is allowed, it should be ignored by the server. Is this intended? Method: public abstract org.knowm.xchange.okex.v5.dto.OkexResponse org.knowm.xchange.okex.v5.Okex.getTrades(java.lang.String,int,java.lang.String) throws java.io.IOException,org.knowm.xchange.okex.v5.dto.OkexException
11:57:10.912 [default] [main] INFO o.k.x.e.i.LoggingInterceptor - org.knowm.xchange.okex.v5.Okex.getTrades took 15 ms.
Trades
lastID= 0
nextPageCursor= null

Exception in thread "main" java.lang.IndexOutOfBoundsException: Index 0 out of bounds for length 0
at java.base/jdk.internal.util.Preconditions.outOfBounds(Preconditions.java:64)
at java.base/jdk.internal.util.Preconditions.outOfBoundsCheckIndex(Preconditions.java:70)
at java.base/jdk.internal.util.Preconditions.checkIndex(Preconditions.java:248)
at java.base/java.util.Objects.checkIndex(Objects.java:372)
at java.base/java.util.ArrayList.get(ArrayList.java:459)
at org.knowm.xchange.examples.okex.v5.marketdata.OkexTradesDemo.generic(OkexTradesDemo.java:35)
at org.knowm.xchange.examples.okex.v5.marketdata.OkexTradesDemo.main(OkexTradesDemo.java:21)
`

Dominant language
Java
Stars
4.1k
Forks
2k
Avg merge
2d 12h
Merged PRs (30d)
21

Getting set up

This project ships no dev container, Dockerfile or contributing guide, so setting up is up to you: start from its README, and see our first-contribution guide for the general steps.

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

More from knowm/XChange

All issues in knowm/XChange

Similar issues

More Java issues

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.