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.87k stars 1.94k forks source link

BCH/BTC : [EQuery:Unknown asset pair] #1652

Closed labeoVlad closed 7 years ago

labeoVlad commented 7 years ago

I have added a new currency BCH in KrakenUtils.java DIGITAL_CURRENCIES.add(KrakenAdapters.adaptCurrency("BCH"));

When requesting a ticker System.out.println(marketDataService.getTicker(new CurrencyPair(Currency.BCH, Currency.BTC))) ;

I am still getting ExchangeException [main] INFO org.knowm.xchange.kraken.KrakenExchange - Calling Remote Init... Exception in thread "main" org.knowm.xchange.exceptions.ExchangeException: [EQuery:Unknown asset pair] at org.knowm.xchange.kraken.service.KrakenBaseService.checkResult(KrakenBaseService.java:82) at org.knowm.xchange.kraken.service.KrakenMarketDataServiceRaw.getKrakenTicker(KrakenMarketDataServiceRaw.java:38) at org.knowm.xchange.kraken.service.KrakenMarketDataService.getTicker(KrakenMarketDataService.java:31)

Why it is happening. I thought a pair may be created as soon a Currency is introduced. Isn't it? Do you need to create a pair manually?

Give a hint what else must be edited to correct it?

Thanks

Achterhoeker commented 7 years ago

@labeoVlad I'm doing the same. It seems that kraken isn't supporting BTH on their api. See for example: https://api.kraken.com/0/public/AssetPairs The unknown asset pair error is from kraken.

labeoVlad commented 7 years ago

what about https://api.kraken.com/0/public/Ticker?pair=BCHXBT

it looks like Kraken API is working. Therefore I am expecting same from XChange API

labeoVlad commented 7 years ago

Also, a pair called BCHXBT can be easily found in https://api.kraken.com/0/public/AssetPairs

Achterhoeker commented 7 years ago

@labeoVlad You are correct. They are present now. For 15 minutes ago it wasn't... I'm currently again debugging what is going wrong.

labeoVlad commented 7 years ago

I think this is what causing issues in KrakenBaseService.java . We are not getting success in checkResult

public KrakenAssets getKrakenAssets(Currency... assets) throws IOException {

KrakenAssetsResult assetPairsResult = kraken.getAssets(null, delimitAssets(assets));

return new KrakenAssets(checkResult(assetPairsResult));

}

protected R checkResult(KrakenResult krakenResult) {

if (!krakenResult.isSuccess()) {
  String[] errors = krakenResult.getError();
  if (errors.length == 0) {
    throw new ExchangeException("Missing error message");
  }
  String error = errors[0];
  if ("EAPI:Invalid nonce".equals(error)) {
    throw new NonceException(error);
  } else if ("EGeneral:Temporary lockout".equals(error)) {
    throw new FrequencyLimitExceededException(error);
  }

  throw new ExchangeException(Arrays.toString(errors));
}

return krakenResult.getResult();

}

Achterhoeker commented 7 years ago

@labeoVlad Sorry, I'm using an older version of kraken, The latest version isn't usable for me anymore. Open orders on Dash are for example reported as DAS. I don't have the time currently to find out which PR causes these new errors. On the old version all exceptions for GNO are also needed for BTH to create a correct kraken asset pair.

labeoVlad commented 7 years ago

Bittrex is working with new currency just fine

Ticker ticker = marketDataService.getTicker(new CurrencyPair("BCC", "BTC"));

Bittrex returns this pair through XChange API

[main] INFO org.knowm.xchange.bittrex.v1.BittrexExchange - Calling Remote Init... Ticker [currencyPair=BCC/BTC, last=0.11000010, bid=0.11000010, ask=0.11012500, high=0.14789000, low=0.00300000,avg=null, volume=23546.31626708, timestamp=1501617907347]

Kraken may have returned similar answer I believe, should their API receive a correct request

Achterhoeker commented 7 years ago

@labeoVlad I have it working on Kraken, but on an older version. :-( The utils for kraken are trying to add an Z or X to all currencypairs. For BCH that isn't needed. (like GNO) You also need to add the pairs to the json file if you use the reported pairs from an xchange.

npomfret commented 7 years ago

Does this API support the face that different exchanges may use different symbols for the same currency? Is is that something you have to deal with yourself?

labeoVlad commented 7 years ago

@Achterhoeker oh, that was a great hint! Thanks

Achterhoeker commented 7 years ago

@npomfret That is an open question. Currently it is a chaos. Polo is using bcc for an other altcoin. Bittrex is using bcc for bch. Bitfinex is using bcc for a strange older split off coin. (and bch communicated for bch). Kraken is using bch. Currently i think that the best option is to use bch and let the bittrex xchange translate that to bch. And these are only the xchanges i use in my bot with bch.

labeoVlad commented 7 years ago

This is what needs to be changed in KrakenUtils.java in order to bring this new Currency BCH into play

image

douggie commented 7 years ago

HI,

I beleive we need to have Kraken adapters not add in the X's and Z's into a pair when submitting the request where the quote currency is BCH.

Currently the latest develop branch is market data request by sending https://api.kraken.com/0/public/Trades?pair=ZBCHXXBT, as ZBCHXXBT is not a valid pair (https://api.kraken.com/0/public/AssetPairs) the valid pair is just BCHXBT.

Essentially when the quote currency is BCH the kraken adapter should not add the Z and X's to create the pair.

Happy to fix it up later today, or if someone else is taking a look, great!

npomfret commented 7 years ago

Thanks @labeoVlad PR?

Achterhoeker commented 7 years ago

@labeoVlad @douggie @timmolter I've started rewriting the Kraken implementation with the translations. The code is now using the assets retrieved from the exchange. So no hardcoded translations needed anymore. Only left problem is the dark markets, i think i can ignore them ? Does anyone uses those markets ? (dark markets is without order books, only placing orders is allowed) Last evening I didn't have the time to finish it. Today there is also no time left. I'll try to push this change tomorrow evening. (UTC+2)

douggie commented 7 years ago

Wow sounds like a nice change. I dont use dark markets

On Thu, 3 Aug 2017, 09:19 Achterhoeker, notifications@github.com wrote:

@labeoVlad https://github.com/labeovlad @douggie https://github.com/douggie @timmolter https://github.com/timmolter I've started rewriting the Kraken implementation with the translations. The code is now using the assets retrieved from the exchange. So no hardcoded translations needed anymore. Only left problem is the dark markets, i think i can ignore them ? Does anyone uses those markets ? (dark markets is without order books, only placing orders is allowed) Last evening I didn't have the time to finish it. Today there is also no time left. I'll try to push this change tomorrow evening. (UTC+2)

— You are receiving this because you were mentioned.

Reply to this email directly, view it on GitHub https://github.com/timmolter/XChange/issues/1652#issuecomment-319901780, or mute the thread https://github.com/notifications/unsubscribe-auth/AENHau8n2FvmxJFt1yQ1JkuaJtW0W8NLks5sUYKmgaJpZM4OqLN3 .

npomfret commented 7 years ago

That does sound like a good change. (And I also don't use dark markets).

I think we still need to consider a general solution to this problem though. Not all exchanges will have the necessary API calls to do it magically.