Skip to content

Commit

Permalink
Added PerpetualFuturesApi.GetTickersAsync endpoint, Added PerpetualFu…
Browse files Browse the repository at this point in the history
…turesApi.GetLastTradePricesAsyncendpoint, Added PerpetualFuturesApi.GetFundingRatesAsync endpoint, Added SpotApi.GetLastTradesAsync endpoint, updated API docs references
  • Loading branch information
JKorf committed Jul 11, 2024
1 parent 33bda99 commit 20785f5
Show file tree
Hide file tree
Showing 10 changed files with 218 additions and 79 deletions.
79 changes: 64 additions & 15 deletions BingX.Net/BingX.Net.xml

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

Original file line number Diff line number Diff line change
Expand Up @@ -117,6 +117,17 @@ public async Task<WebCallResult<BingXFundingRate>> GetFundingRateAsync(string sy

#endregion

#region Get Funding Rates

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<BingXFundingRate>>> GetFundingRatesAsync(CancellationToken ct = default)
{
var request = _definitions.GetOrCreate(HttpMethod.Get, "/openApi/swap/v2/quote/premiumIndex", BingXExchange.RateLimiter.RestMarket, 1);
return await _baseClient.SendAsync<IEnumerable<BingXFundingRate>>(request, null, ct).ConfigureAwait(false);
}

#endregion

#region Get Funding Rate History

/// <inheritdoc />
Expand Down Expand Up @@ -207,6 +218,17 @@ public async Task<WebCallResult<BingXFuturesTicker>> GetTickerAsync(string symbo

#endregion

#region Get Ticker

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<BingXFuturesTicker>>> GetTickersAsync(CancellationToken ct = default)
{
var request = _definitions.GetOrCreate(HttpMethod.Get, "/openApi/swap/v2/quote/ticker", BingXExchange.RateLimiter.RestMarket, 1);
return await _baseClient.SendAsync<IEnumerable<BingXFuturesTicker>>(request, null, ct).ConfigureAwait(false);
}

#endregion

#region Get Book Ticker

/// <inheritdoc />
Expand All @@ -229,15 +251,26 @@ public async Task<WebCallResult<BingXFuturesBookTicker>> GetBookTickerAsync(stri
/// <inheritdoc />
public async Task<WebCallResult<BingXLastTradePrice>> GetLastTradePriceAsync(string symbol, CancellationToken ct = default)
{
var parameters = new ParameterCollection()
{
{ "symbol", symbol }
};
var parameters = new ParameterCollection();
parameters.Add("symbol", symbol);
parameters.AddOptionalMillisecondsString("timestamp", DateTime.UtcNow);
var request = _definitions.GetOrCreate(HttpMethod.Get, "/openApi/swap/v1/ticker/price", BingXExchange.RateLimiter.RestMarket, 1);
return await _baseClient.SendAsync<BingXLastTradePrice>(request, parameters, ct).ConfigureAwait(false);
}

#endregion

#region Get Last Trade Prices

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<BingXLastTradePrice>>> GetLastTradePricesAsync(CancellationToken ct = default)
{
var parameters = new ParameterCollection();
parameters.AddOptionalMillisecondsString("timestamp", DateTime.UtcNow);
var request = _definitions.GetOrCreate(HttpMethod.Get, "/openApi/swap/v1/ticker/price", BingXExchange.RateLimiter.RestMarket, 1);
return await _baseClient.SendAsync<IEnumerable<BingXLastTradePrice>>(request, parameters, ct).ConfigureAwait(false);
}

#endregion
}
}
19 changes: 18 additions & 1 deletion BingX.Net/Clients/SpotApi/BingXRestClientSpotApiExchangeData.cs
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,24 @@ public async Task<WebCallResult<BingXLastTrade>> GetLastTradeAsync(string symbol

var request = _definitions.GetOrCreate(HttpMethod.Get, "/openApi/spot/v1/ticker/price", BingXExchange.RateLimiter.RestMarket, 1, false);
var result = await _baseClient.SendAsync<IEnumerable<BingXLastTradeWrapper>>(request, parameters, ct).ConfigureAwait(false);
return result.As<BingXLastTrade>(result.Data?.Single().Trades.Single());
var tradeResult = result.As<BingXLastTrade>(result.Data?.Single().Trades.Single());
if (!tradeResult)
return tradeResult;

tradeResult.Data.Symbol = symbol;
return tradeResult;
}

#endregion

#region Get Last Trades

/// <inheritdoc />
public async Task<WebCallResult<IEnumerable<BingXLastTrade>>> GetLastTradesAsync(CancellationToken ct = default)
{
var request = _definitions.GetOrCreate(HttpMethod.Get, "/openApi/spot/v1/ticker/price", BingXExchange.RateLimiter.RestMarket, 1, false);
var result = await _baseClient.SendAsync<IEnumerable<BingXLastTradeWrapper>>(request, null, ct).ConfigureAwait(false);
return result.As<IEnumerable<BingXLastTrade>>(result.Data?.Select(x => x.Trades.Single() with { Symbol = x.Symbol }));
}

#endregion
Expand Down
Loading

0 comments on commit 20785f5

Please sign in to comment.