Skip to content

Commit

Permalink
Updated CryptoExchange.Net
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Mar 16, 2024
1 parent 287013f commit 0b812c0
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 44 deletions.
4 changes: 1 addition & 3 deletions Binance.Net/Binance.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -52,8 +52,6 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
</ItemGroup>
<ItemGroup>
<ProjectReference Include="..\..\CryptoExchange.Net\CryptoExchange.Net\CryptoExchange.Net.csproj" />
<PackageReference Include="CryptoExchange.Net" Version="7.1.0" />
</ItemGroup>
</Project>
Original file line number Diff line number Diff line change
Expand Up @@ -439,30 +439,6 @@ public async Task<CallResult<UpdateSubscription>> SubscribeToUserDataUpdatesAsyn

#endregion

//private void HandlePossibleSingleData<T>(DataEvent<JToken> data, Action<DataEvent<IEnumerable<T>>> onMessage)
//{
// var internalData = data.Data["data"];
// if (internalData == null)
// return;
// if (internalData.Type == JTokenType.Array)
// {
// var firstItemTopic = internalData.First()["i"]?.ToString() ?? internalData.First()["s"]?.ToString();
// var deserialized = Deserialize<BinanceCombinedStream<IEnumerable<T>>>(data.Data);
// if (!deserialized)
// return;
// onMessage(data.As(deserialized.Data.Data, firstItemTopic));
// }
// else
// {
// var symbol = internalData["i"]?.ToString() ?? internalData["s"]?.ToString();
// var deserialized = Deserialize<BinanceCombinedStream<T>>(
// data.Data);
// if (!deserialized)
// return;
// onMessage(data.As<IEnumerable<T>>(new[] { deserialized.Data.Data }, symbol));
// }
//}

#endregion
internal Task<CallResult<UpdateSubscription>> SubscribeAsync<T>(string url, IEnumerable<string> topics, Action<DataEvent<T>> onData, CancellationToken ct)
{
Expand Down
20 changes: 3 additions & 17 deletions Binance.Net/Clients/SpotApi/BinanceRestClientSpotApiTrading.cs
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
using System.Collections.Generic;
using System.Globalization;
using System.Net.Http;
using System.Text;
using System.Threading;
using System.Threading.Tasks;
using Binance.Net.Converters;
Expand All @@ -19,6 +20,7 @@
using CryptoExchange.Net;
using CryptoExchange.Net.CommonObjects;
using CryptoExchange.Net.Converters;
using CryptoExchange.Net.Converters.MessageParsing;
using CryptoExchange.Net.Objects;
using Microsoft.Extensions.Logging;
using Newtonsoft.Json;
Expand Down Expand Up @@ -334,23 +336,7 @@ public async Task<WebCallResult<BinanceReplaceOrderResult>> ReplaceOrderAsync(st
parameters.AddOptionalParameter("recvWindow", receiveWindow?.ToString(CultureInfo.InvariantCulture) ?? _baseClient.ClientOptions.ReceiveWindow.TotalMilliseconds.ToString(CultureInfo.InvariantCulture));

var result = await _baseClient.SendRequestInternal<BinanceReplaceOrderResult>(_baseClient.GetUrl(cancelReplaceOrderEndpoint, api, signedVersion), HttpMethod.Post, ct, parameters, true, weight: 1).ConfigureAwait(false);
if (!result && result.OriginalData != null)
{
// TODO
//// Attempt to parse the error
//var jsonData = result.OriginalData.ToJToken(_logger);
//if (jsonData != null)
//{
// var dataNode = jsonData["data"];
// if (dataNode == null)
// return result;

// var error = dataNode?["cancelResult"]?.ToString() == "FAILURE" ? dataNode!["cancelResponse"] : jsonData["data"]!["newOrderResponse"];
// if (error != null && error.HasValues)
// return result.AsError<BinanceReplaceOrderResult>(new ServerError(error!.Value<int>("code"), error.Value<string>("msg")!));
//}
}


if (result && result.Data.NewOrderResult == OrderOperationResult.Success)
_baseClient.InvokeOrderPlaced(new OrderId() { SourceObject = result.Data, Id = result.Data.NewOrderResponse!.Id.ToString(CultureInfo.InvariantCulture) });
return result;
Expand Down

0 comments on commit 0b812c0

Please sign in to comment.