Skip to content
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

Feature/ce update #11

Merged
merged 2 commits into from
Jul 2, 2024
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
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
Loading