Open andrewlin0410 opened 6 years ago
Is this issue gonna be addressed in the next version?
Can you guys please do something about this cos the entire feature of getting trades seems useless when we don't know which side is which.
Please submit a PR with the fix.
I have also observed this, however GDAX is not the only one.
GDAX, Bitfinex, Bitstamp and Kucoin all follow the same behaviour as GDAX (sell=ASK, buy=BID). The only exchange I use that does the opposite (sell=BID, buy=ASK) is Binance.
I was about to put in a fix which reversed the Binance behaviour to bring it in line with the rest, but if @andrewlin0410 is right and actually Binance is the only one that's correctly implemented, that complicates things a bit.
Should I go swapping the order types on all these exchanges? That's a pretty big impact on existing users, and ultimately probably academic. Who cares whether XChange returns BID
or ASK
as long as it's consistent between exchanges?
Thoughts @timmolter? I'm leaning towards just changing Binance.
I think the best would be to make XChange consistent across all exchanges. Originally, we went with the sell=ASK and buy=BID convention from the client's (taker's) perspective. I think someone tried to reverse the convention of Binance once, and some people were opposed to it. However, I wasn't really aware of the overall convention mismatch at the time I think.
OK, so, @timmolter, it's either:
Are we leaning towards (2)?
According to GDAX : The trade side indicates the maker order side. The maker order is the order that was open on the order book. buy side indicates a down-tick because the maker was a buy order and their order was removed. Conversely, sell side indicates an up-tick. However, the resultant xchange trades from Gdax do not follow this. I looked at the Json from gdax, it does follow the above statement. I think this line needs to be changed: OrderType type = trade.getSide().equals("sell") ? OrderType.BID : OrderType.ASK; For BFX, the Json and resultant xchange trades follow the opposite. For Binance, the resultant xchange trades follow the above statement. I did not check Json. It's all very confusing, I hope we can standardize this issue for xchange. To manually reverse I wrote the bellow. Tell me if there's a better way. void flipBuySellSides(Trades trades) { for (int i = 0; i < trades.getTrades().size(); i++) { Trade trade = trades.getTrades().get(i); if (trade.getType() == Order.OrderType.BID) { trades.getTrades().set(i, new Trade(Order.OrderType.ASK, trade.getOriginalAmount(), trade.getCurrencyPair(), trade.getPrice(), trade.getTimestamp(), trade.getId())); } else if (trade.getType() == Order.OrderType.ASK) { trades.getTrades().set(i, new Trade(Order.OrderType.BID, trade.getOriginalAmount(), trade.getCurrencyPair(), trade.getPrice(), trade.getTimestamp(), trade.getId())); } } }