Skip to content

Commit

Permalink
Fixed inverted order side for Shared trades
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Nov 21, 2024
1 parent 14e3b05 commit dd34af7
Show file tree
Hide file tree
Showing 6 changed files with 9 additions and 9 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -186,7 +186,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> IRecentTradeRestClient.G

return result.AsExchangeResult<IEnumerable<SharedTrade>>(Exchange, request.Symbol.TradingMode, result.Data.Select(x => new SharedTrade(x.BaseQuantity, x.Price, x.TradeTime)
{
Side = x.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = x.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
}).ToArray());
}

Expand Down Expand Up @@ -686,7 +686,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> ITradeHistoryRestClient.
// Return
return result.AsExchangeResult<IEnumerable<SharedTrade>>(Exchange, request.Symbol.TradingMode, result.Data.Where(x => x.TradeTime < request.EndTime).Select(x => new SharedTrade(x.Quantity, x.Price, x.TradeTime)
{
Side = x.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = x.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
}).ToArray(), nextToken);
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,7 @@ async Task<ExchangeResult<UpdateSubscription>> ITradeSocketClient.SubscribeToTra
return new ExchangeResult<UpdateSubscription>(Exchange, validationError);

var symbol = request.Symbol.GetSymbol(FormatSymbol);
var result = await SubscribeToAggregatedTradeUpdatesAsync(symbol, update => handler(update.AsExchangeEvent<IEnumerable<SharedTrade>>(Exchange, new[] { new SharedTrade(update.Data.Quantity, update.Data.Price, update.Data.TradeTime) { Side = update.Data.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell } })), ct:ct).ConfigureAwait(false);
var result = await SubscribeToAggregatedTradeUpdatesAsync(symbol, update => handler(update.AsExchangeEvent<IEnumerable<SharedTrade>>(Exchange, new[] { new SharedTrade(update.Data.Quantity, update.Data.Price, update.Data.TradeTime) { Side = update.Data.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy } })), ct:ct).ConfigureAwait(false);

return new ExchangeResult<UpdateSubscription>(Exchange, result);
}
Expand Down
4 changes: 2 additions & 2 deletions Binance.Net/Clients/SpotApi/BinanceRestClientSpotApiShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -149,7 +149,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> IRecentTradeRestClient.G
// Return
return result.AsExchangeResult<IEnumerable<SharedTrade>>(Exchange, TradingMode.Spot, result.Data.Select(x => new SharedTrade(x.BaseQuantity, x.Price, x.TradeTime)
{
Side = x.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = x.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
}).ToArray());
}
#endregion
Expand Down Expand Up @@ -185,7 +185,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> ITradeHistoryRestClient.
// Return
return result.AsExchangeResult<IEnumerable<SharedTrade>>(Exchange, TradingMode.Spot, result.Data.Where(x => x.TradeTime < request.EndTime).Select(x => new SharedTrade(x.Quantity, x.Price, x.TradeTime)
{
Side = x.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = x.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
}).ToArray(), nextToken);
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ async Task<ExchangeResult<UpdateSubscription>> ITradeSocketClient.SubscribeToTra
var symbol = request.Symbol.GetSymbol(FormatSymbol);
var result = await ExchangeData.SubscribeToTradeUpdatesAsync(symbol, update => handler(update.AsExchangeEvent<IEnumerable<SharedTrade>>(Exchange, new[] { new SharedTrade(update.Data.Quantity, update.Data.Price, update.Data.TradeTime)
{
Side = update.Data.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = update.Data.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
} })), ct).ConfigureAwait(false);

return new ExchangeResult<UpdateSubscription>(Exchange, result);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -239,7 +239,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> IRecentTradeRestClient.G

return result.AsExchangeResult<IEnumerable<SharedTrade>>(Exchange, request.Symbol.TradingMode, result.Data.Select(x => new SharedTrade(x.BaseQuantity, x.Price, x.TradeTime)
{
Side = x.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = x.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
}).ToArray());
}

Expand Down Expand Up @@ -682,7 +682,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> ITradeHistoryRestClient.
// Return
return result.AsExchangeResult<IEnumerable<SharedTrade>>(Exchange, request.Symbol.TradingMode, result.Data.Where(x => x.TradeTime < request.EndTime).Select(x => new SharedTrade(x.Quantity, x.Price, x.TradeTime)
{
Side = x.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = x.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
}).ToArray(), nextToken);
}
#endregion
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ async Task<ExchangeResult<UpdateSubscription>> ITradeSocketClient.SubscribeToTra
var symbol = request.Symbol.GetSymbol(FormatSymbol);
var result = await ExchangeData.SubscribeToAggregatedTradeUpdatesAsync(symbol, update => handler(update.AsExchangeEvent<IEnumerable<SharedTrade>>(Exchange, new[] { new SharedTrade(update.Data.Quantity, update.Data.Price, update.Data.TradeTime)
{
Side = update.Data.BuyerIsMaker ? SharedOrderSide.Buy : SharedOrderSide.Sell
Side = update.Data.BuyerIsMaker ? SharedOrderSide.Sell : SharedOrderSide.Buy,
} })), ct:ct).ConfigureAwait(false);

return new ExchangeResult<UpdateSubscription>(Exchange, result);
Expand Down

0 comments on commit dd34af7

Please sign in to comment.