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

Binance: Resilience - how to disable inital wait time #4140

Closed ts-00 closed 2 years ago

ts-00 commented 3 years ago

Currently, when using xchange api (for example, binance xchange api) there is an initial wait time before the request is fired (because of resilience4j). Is there a way to disable this first inital wait time (first inital "waitDuration") or set it to a lower value?

walec51 commented 3 years ago

I'm not awary of any initial wait time

could you provide some logs that showcase this?

ts-00 commented 3 years ago

Call any method (for example, klines()) within a Junit-Test-case and you will see that there is always an initial wait time (which is always 20 seconds for any xchange method call ), for example:

@Test
final void callBinanceMethod() {
// setup connection
var conn = ExchangeFactory.INSTANCE.createExchange(BinanceExchange.class, apiKey, secretKey);
// call method (this method is only called after an initial delay of 20 seconds
var orderbook = conn.getMarketDataService().getOrderBook(...)
assertNotNull(orderbook);
}

I think this happens because of resilience4j which has an initial waitDuration by default.

gewure commented 2 years ago

Am curious if

conn.remoteInit();

shortcuts the delay you encounter.

ts-00 commented 2 years ago

Am curious if conn.remoteInit(); shortcuts the delay you encounter.

Good point. The conn.remoteInit(); (which is responsible for the delay) is called each time the BinanceExchange is created because by default shouldLoadRemoteMetaData is set to true.

// according to ExchangeSpecification.java
 private boolean shouldLoadRemoteMetaData = true; // default value