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

[Binance] Call for pair BTC/USD and ETH/USD fails with org.knowm.xchange.exceptions.CurrencyPairNotValidException: Invalid symbol. #3180

Closed oleksandrkyetov closed 5 years ago

oleksandrkyetov commented 5 years ago

When using https://github.com/knowm/XChange/blob/develop/xchange-binance/src/main/java/org/knowm/xchange/binance/service/BinanceMarketDataServiceRaw.java#L61 https://github.com/knowm/XChange/blob/develop/xchange-binance/src/main/java/org/knowm/xchange/binance/service/BinanceMarketDataServiceRaw.java#L46 calls fail with org.knowm.xchange.exceptions.CurrencyPairNotValidException: Invalid symbol.

Reason for that is that currency pairs BTC/USD and ETH/USD are being resolved to BTCUSD and ETHUSD symbols respectively, but should resolve to BTCUSDC and ETHUSDC

walec51 commented 5 years ago

No it should not USD is plain old vanilla fiat USA Dollar which Binance does not support directly on the exchange USDC is a ERC20 token representing a stable coin tied to USD by Circle and Coinbase

oleksandrkyetov commented 5 years ago

Thank you @walec51 , that make sense, how do I get a price for BTC/USDC in this case? Binance REST API allows that https://api.binance.com/api/v3/ticker/price?symbol=BTCUSDC But, there is no USDC in the CurrencyPair class https://github.com/knowm/XChange/blob/develop/xchange-core/src/main/java/org/knowm/xchange/currency/CurrencyPair.java

walec51 commented 5 years ago

exchange.getMarketDataService().getTicker(new CurrencyPair("BTC", "USDC"));