Skip to content

Set MarketSymbolIsUppercase to true for all Binance based exchanges #758

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 1, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 10 additions & 5 deletions src/ExchangeSharp/API/Exchanges/BinanceGroup/BinanceGroupCommon.cs
Original file line number Diff line number Diff line change
Expand Up @@ -53,7 +53,7 @@ protected BinanceGroupCommon()
NonceStyle = NonceStyle.UnixMilliseconds;
NonceOffset = TimeSpan.FromSeconds(15); // 15 seconds are deducted from current UTCTime as base of the request time window
MarketSymbolSeparator = string.Empty;
MarketSymbolIsUppercase = false;
MarketSymbolIsUppercase = true;
WebSocketOrderBookType = WebSocketOrderBookType.DeltasOnly;
ExchangeGlobalCurrencyReplacements["BCC"] = "BCH";
}
Expand Down Expand Up @@ -275,6 +275,11 @@ protected override async Task<IWebSocket> OnGetTradesWebSocketAsync(Func<KeyValu
{
marketSymbols = (await GetMarketSymbolsAsync()).ToArray();
}
if (marketSymbols.Length > 400)
{
marketSymbols = marketSymbols.Take(400).ToArray();
Logger.Warn("subscribing to the first 400 symbols"); // binance does not allow subscribing to more than 400 symbols at a time
}
string url = await GetWebSocketStreamUrlForSymbolsAsync("@aggTrade", marketSymbols);
return await ConnectPublicWebSocketAsync(url, messageCallback: async (_socket, msg) =>
{
Expand Down Expand Up @@ -302,7 +307,7 @@ protected override async Task<IWebSocket> OnGetDeltaOrderBookWebSocketAsync(Acti
return await ConnectPublicWebSocketAsync($"/stream?streams={combined}", (_socket, msg) =>
{
string json = msg.ToStringFromUTF8();
var update = JsonConvert.DeserializeObject<MultiDepthStream>(json);
var update = JsonConvert.DeserializeObject<MultiDepthStream>(json, SerializerSettings);
string marketSymbol = update.Data.MarketSymbol;
ExchangeOrderBook book = new ExchangeOrderBook { SequenceId = update.Data.FinalUpdate, MarketSymbol = marketSymbol, LastUpdatedUtc = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(update.Data.EventTime) };
foreach (List<object> ask in update.Data.Asks)
Expand Down Expand Up @@ -1091,7 +1096,7 @@ protected override async Task<IWebSocket> OnUserDataWebSocketAsync(Action<object
{
case "executionReport": // systematically check to make sure we are dealing with expected cases here
{
var update = JsonConvert.DeserializeObject<ExecutionReport>(token.ToStringInvariant());
var update = JsonConvert.DeserializeObject<ExecutionReport>(token.ToStringInvariant(), SerializerSettings);
switch (update.CurrentExecutionType)
{
case "NEW ": // The order has been accepted into the engine.
Expand All @@ -1115,7 +1120,7 @@ protected override async Task<IWebSocket> OnUserDataWebSocketAsync(Action<object
throw new NotImplementedException("has been removed (per binance 2021-01-01)");
case "outboundAccountPosition":
{
var update = JsonConvert.DeserializeObject<OutboundAccount>(token.ToStringInvariant());
var update = JsonConvert.DeserializeObject<OutboundAccount>(token.ToStringInvariant(), SerializerSettings);
callback(new ExchangeBalances()
{
EventTime = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(update.EventTime),
Expand All @@ -1138,7 +1143,7 @@ protected override async Task<IWebSocket> OnUserDataWebSocketAsync(Action<object
}
case "balanceUpdate":
{
var update = JsonConvert.DeserializeObject<BalanceUpdate>(token.ToStringInvariant());
var update = JsonConvert.DeserializeObject<BalanceUpdate>(token.ToStringInvariant(), SerializerSettings);
callback(new ExchangeBalances()
{
EventTime = CryptoUtility.UnixTimeStampToDateTimeMilliseconds(update.EventTime),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -18,11 +18,6 @@ public sealed class ExchangeBinanceAPI : BinanceGroupCommon
{
public override string BaseUrl { get; set; } = "https://api.binance.com";
public override string BaseUrlWebSocket { get; set; } = "wss://stream.binance.com:9443";

private ExchangeBinanceAPI()
{
MarketSymbolIsUppercase = true;
}
}

public partial class ExchangeName { public const string Binance = "Binance"; }
Expand Down