diff --git a/exchanges/binance/binance_websocket.go b/exchanges/binance/binance_websocket.go index 91b68a11ded..8343848685b 100644 --- a/exchanges/binance/binance_websocket.go +++ b/exchanges/binance/binance_websocket.go @@ -337,6 +337,11 @@ func (b *Binance) wsHandleData(respRaw []byte) error { b.Name, err) } + // maker placed buy order, so taker market sell + side := order.Buy + if t.Maker { + side = order.Sell + } return b.Websocket.Trade.Update(saveTradeData, trade.Data{ CurrencyPair: pair, @@ -345,6 +350,7 @@ func (b *Binance) wsHandleData(respRaw []byte) error { Amount: t.Quantity.Float64(), Exchange: b.Name, AssetType: asset.Spot, + Side: side, TID: strconv.FormatInt(t.TradeID, 10), }) case "ticker": diff --git a/exchanges/binance/binance_wrapper.go b/exchanges/binance/binance_wrapper.go index 475f274814d..6ed9f6d9841 100644 --- a/exchanges/binance/binance_wrapper.go +++ b/exchanges/binance/binance_wrapper.go @@ -783,6 +783,11 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset. } for i := range tradeData { + // maker placed buy order, so taker market sell + side := order.Buy + if tradeData[i].IsBuyerMaker { + side = order.Sell + } resp = append(resp, trade.Data{ TID: strconv.FormatInt(tradeData[i].ID, 10), Exchange: b.Name, @@ -790,6 +795,7 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset. AssetType: a, Price: tradeData[i].Price, Amount: tradeData[i].Quantity, + Side: side, Timestamp: tradeData[i].Time, }) } @@ -800,6 +806,11 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset. } for i := range tradeData { + // maker placed buy order, so taker market sell + side := order.Buy + if tradeData[i].IsBuyerMaker { + side = order.Sell + } resp = append(resp, trade.Data{ TID: strconv.FormatInt(tradeData[i].ID, 10), Exchange: b.Name, @@ -807,6 +818,7 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset. AssetType: a, Price: tradeData[i].Price, Amount: tradeData[i].Qty, + Side: side, Timestamp: tradeData[i].Time.Time(), }) } @@ -817,6 +829,11 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset. } for i := range tradeData { + // maker placed buy order, so taker market sell + side := order.Buy + if tradeData[i].IsBuyerMaker { + side = order.Sell + } resp = append(resp, trade.Data{ TID: strconv.FormatInt(tradeData[i].ID, 10), Exchange: b.Name, @@ -824,6 +841,7 @@ func (b *Binance) GetRecentTrades(ctx context.Context, p currency.Pair, a asset. AssetType: a, Price: tradeData[i].Price, Amount: tradeData[i].Qty, + Side: side, Timestamp: tradeData[i].Time.Time(), }) } @@ -864,6 +882,11 @@ func (b *Binance) GetHistoricTrades(ctx context.Context, p currency.Pair, a asse } result := make([]trade.Data, len(trades)) for i := range trades { + // maker placed buy order, so taker market sell + side := order.Buy + if trades[i].Maker { + side = order.Sell + } result[i] = trade.Data{ CurrencyPair: p, TID: strconv.FormatInt(trades[i].ATradeID, 10), @@ -872,7 +895,7 @@ func (b *Binance) GetHistoricTrades(ctx context.Context, p currency.Pair, a asse Price: trades[i].Price, Timestamp: trades[i].TimeStamp, AssetType: a, - Side: order.AnySide, + Side: side, } } return result, nil