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

add getTickers to MarketDataService #2385

Closed plopezlpz closed 6 years ago

plopezlpz commented 6 years ago

It would be good to add a new method: MarketDataService#getTickers(Collection<CurrencyPair>, Object...) to get multiple tickets (or all tickers) in one request. At least CexIO's and Kraken's APIs support that:

npomfret commented 6 years ago

The argument should probably be a new type of Params class similar to that used in TradeHistory for example.

caleb-allen commented 6 years ago

Related to #2018

plopezlpz commented 6 years ago

@npomfret In MarketDataService all existing methods accept CurrencyPair as argument, I'd prefer to keep the argument as Collection<CurrencyPair> to keep it consistent. With this API if we want to get all tickers then we can just pass the result of Exchange#getExchangeSymbols() and we would get all the currency pairs for the exchange.

npomfret commented 6 years ago

Why not have both? The existing method (that takes a single currency pair) becomes a convenience can just delegates down to the new method.

You can also use this new object to store the optional limit parameter that some exchanges support for reducing the size of the order book. It's a much neater solution than the existing varargs approach.

plopezlpz commented 6 years ago

@npomfret Ok, I've updated the PR with a generic params: #2388 Usage can be MarketDataService#getTickers((CurrencyPairsParam) () -> currencyPairs)

npomfret commented 6 years ago

FYI - in java 8 adding a default implementation that just delegates is pretty easy...

I did the same for withdrawFunds: https://github.com/timmolter/XChange/pull/2392/commits/3c3e91aa8aa0031497c9b627fcb7f2a07bd50275

caleb-allen commented 6 years ago

Solved by #2446