Skip to content

Commit

Permalink
Add Dust Log, Trade Fee, and Asset Detail HTTP client extensions
Browse files Browse the repository at this point in the history
  • Loading branch information
sonvister committed Dec 4, 2018
1 parent fd7d4e6 commit 6df97f5
Show file tree
Hide file tree
Showing 2 changed files with 80 additions and 2 deletions.
4 changes: 2 additions & 2 deletions samples/BinanceConsoleApp/Controllers/IntegrationTests.cs
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ public async Task<bool> HandleAsync(string command, CancellationToken token = de


///////////////////////////////////////////////////////////////////
var trades = (await Program.Api.GetAccountTradesAsync(Program.User, symbol, endTime.Subtract(TimeSpan.FromHours(24)), endTime, token:token))
var trades = (await Program.Api.GetAccountTradesAsync(Program.User, symbol, endTime.Subtract(TimeSpan.FromHours(24)), endTime, token: token))
.Reverse().ToArray();

lock (Program.ConsoleSync)
Expand All @@ -83,7 +83,7 @@ public async Task<bool> HandleAsync(string command, CancellationToken token = de

///////////////////////////////////////////////////////////////////
var orders = await Program.Api
.GetOrdersAsync(Program.User, symbol, endTime.Subtract(TimeSpan.FromHours(24)), endTime, token:token);
.GetOrdersAsync(Program.User, symbol, endTime.Subtract(TimeSpan.FromHours(24)), endTime, token: token);

lock (Program.ConsoleSync)
{
Expand Down
78 changes: 78 additions & 0 deletions src/Binance/Extensions/BinanceHttpClientExtensions.cs
Original file line number Diff line number Diff line change
Expand Up @@ -1187,6 +1187,84 @@ await client.SignAsync(request, user, token)
.ConfigureAwait(false);
}

public static async Task<string> GetDustLogAsync(this IBinanceHttpClient client, IBinanceApiUser user, long recvWindow = default, CancellationToken token = default)
{
Throw.IfNull(client, nameof(client));

if (client.RateLimiter != null)
{
await client.RateLimiter.DelayAsync(token: token)
.ConfigureAwait(false);
}

var request = new BinanceHttpRequest("/wapi/v3/userAssetDribbletLog.html")
{
ApiKey = user.ApiKey
};

if (recvWindow > 0)
request.AddParameter("recvWindow", recvWindow);

await client.SignAsync(request, user, token)
.ConfigureAwait(false);

return await client.GetAsync(request, token)
.ConfigureAwait(false);
}

public static async Task<string> GetTradeFeeAsync(this IBinanceHttpClient client, IBinanceApiUser user, string symbol, long recvWindow = default, CancellationToken token = default)
{
Throw.IfNull(client, nameof(client));

if (client.RateLimiter != null)
{
await client.RateLimiter.DelayAsync(token: token)
.ConfigureAwait(false);
}

var request = new BinanceHttpRequest("/wapi/v3/tradeFee.html")
{
ApiKey = user.ApiKey
};

if (!string.IsNullOrWhiteSpace(symbol))
request.AddParameter("symbol", symbol.FormatSymbol());

if (recvWindow > 0)
request.AddParameter("recvWindow", recvWindow);

await client.SignAsync(request, user, token)
.ConfigureAwait(false);

return await client.GetAsync(request, token)
.ConfigureAwait(false);
}

public static async Task<string> GetAssetDetailAsync(this IBinanceHttpClient client, IBinanceApiUser user, long recvWindow = default, CancellationToken token = default)
{
Throw.IfNull(client, nameof(client));

if (client.RateLimiter != null)
{
await client.RateLimiter.DelayAsync(token: token)
.ConfigureAwait(false);
}

var request = new BinanceHttpRequest("/wapi/v3/assetDetail.html")
{
ApiKey = user.ApiKey
};

if (recvWindow > 0)
request.AddParameter("recvWindow", recvWindow);

await client.SignAsync(request, user, token)
.ConfigureAwait(false);

return await client.GetAsync(request, token)
.ConfigureAwait(false);
}

#endregion Account

#region User Stream
Expand Down

0 comments on commit 6df97f5

Please sign in to comment.