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 streaming adapter buys and sells reversed #4613

Open m1dnightc0der opened 1 year ago

m1dnightc0der commented 1 year ago

org.knowm.xchange.binance.BinanceAdapters has the following method, that sets weather the trade is a buy or sell.

Looking at the order flow, when the buyerMarketMaker=true means that buyer was the maker/seller was the taker, so we want to show this as a sell order as per other markets seems we do the reverse.

Ho


    return isBuyer ? OrderType.BID : OrderType.ASK;
  }```

as per 
https://dev.binance.vision/t/a-little-confusion-about-is-buyer-market-maker-part-of-trade-stream/5660
m1dnightc0der commented 1 year ago

here is an example with the code fix.

The 0.11647@16538.57 is a buy in the binanace UI and now also a buy via the xchange streaming lib Screenshot 2022-11-17 at 12 12 57

using this


  public static OrderType convertType(boolean isBuyer) {
    return isBuyer ? OrderType.ASK : OrderType.BID;
  }```
m1dnightc0der commented 1 year ago

Screenshot 2022-11-17 at 19 03 24