Skip to content

Commit

Permalink
CryptoExchange update, tp/sl parameters
Browse files Browse the repository at this point in the history
* CryptoExchange update, added tp/sl parameters perpetual futures order placement, updated ratelimit

* Updated reference
  • Loading branch information
JKorf authored Jul 2, 2024
1 parent f5de4ee commit 0d5b5cd
Show file tree
Hide file tree
Showing 10 changed files with 362 additions and 166 deletions.
4 changes: 2 additions & 2 deletions BingX.Net/BingX.Net.csproj
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
<Project Sdk="Microsoft.NET.Sdk">
<Project Sdk="Microsoft.NET.Sdk">
<PropertyGroup>
<TargetFrameworks>netstandard2.0;netstandard2.1</TargetFrameworks>
<LangVersion>10.0</LangVersion>
Expand Down Expand Up @@ -48,7 +48,7 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="7.7.2" />
<PackageReference Include="CryptoExchange.Net" Version="7.8.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
Expand Down
78 changes: 74 additions & 4 deletions BingX.Net/BingX.Net.xml

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

9 changes: 8 additions & 1 deletion BingX.Net/BingXAuthenticationProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,8 @@
using CryptoExchange.Net.Clients;
using CryptoExchange.Net.Objects;
using CryptoExchange.Net.Converters.SystemTextJson;
using System.Linq;
using System.Globalization;

namespace BingX.Net
{
Expand Down Expand Up @@ -44,7 +46,12 @@ public override void AuthenticateRequest(
parameters.Add("recvWindow", (int)receiveWindow.TotalMilliseconds);
}

var parameterSignData = parameters.CreateParamString(true, arraySerialization);
string parameterSignData;
if (parameterPosition == HttpMethodParameterPosition.InBody)
parameterSignData = string.Join("&", parameters.OrderBy(p => p.Key).Select(o => o.Key + "=" + string.Format(CultureInfo.InvariantCulture, "{0}", o.Value)));
else
parameterSignData = parameters.CreateParamString(true, arraySerialization);

parameters.Add("signature", SignHMACSHA256(parameterSignData, SignOutputType.Hex));
}
}
Expand Down
4 changes: 3 additions & 1 deletion BingX.Net/BingXExchange.cs
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,9 @@ internal BingXRateLimiters()
private void Initialize()
{
RestMarket = new RateLimitGate("Spot Rest Market")
.AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new List<IGuardFilter>(), 100, TimeSpan.FromSeconds(10), RateLimitWindowType.Sliding)); // IP limit of 100 requests per 10 seconds in total
.AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new List<IGuardFilter>(), 10, TimeSpan.FromSeconds(1), RateLimitWindowType.Sliding)) // As suggested by BingX API support: IP limit of 10 requests per 1 second in total
.AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new List<IGuardFilter>(), 100, TimeSpan.FromSeconds(10), RateLimitWindowType.Sliding)) // IP limit of 100 requests per 10 seconds in total
.AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new List<IGuardFilter>(), 500, TimeSpan.FromSeconds(60), RateLimitWindowType.Sliding)); // IP limit of 500 requests per 60 seconds in total
RestAccount1 = new RateLimitGate("Spot Rest Account 1")
.AddGuard(new RateLimitGuard(RateLimitGuard.PerHost, new List<IGuardFilter>(), 1000, TimeSpan.FromSeconds(10), RateLimitWindowType.Sliding)) // IP limit of 1000 requests per 10 seconds in total
.AddGuard(new RateLimitGuard(RateLimitGuard.PerEndpoint, new List<IGuardFilter>(), 100, TimeSpan.FromSeconds(10), RateLimitWindowType.Sliding)); // IP limit of 100 requests per 10 seconds per endpoint
Expand Down
Loading

0 comments on commit 0d5b5cd

Please sign in to comment.