From ea72ba6ba405ca3a661cf9611bf18c98820d9d83 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Thu, 28 Nov 2024 14:38:05 +0100 Subject: [PATCH] CryptoExchange update --- .../Bitfinex.Net.UnitTests.csproj | 8 ++--- Bitfinex.Net/Bitfinex.Net.csproj | 4 +-- Bitfinex.Net/Bitfinex.Net.xml | 25 -------------- .../BitfinexRestClientSpotApiShared.cs | 34 ++++++++++++++----- .../IBitfinexRestClientSpotApiShared.cs | 3 +- .../Objects/Options/BitfinexOptions.cs | 27 ++------------- 6 files changed, 35 insertions(+), 66 deletions(-) diff --git a/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj b/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj index f57caa5..5f854d2 100644 --- a/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj +++ b/Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj @@ -7,10 +7,10 @@ - - - - + + + + diff --git a/Bitfinex.Net/Bitfinex.Net.csproj b/Bitfinex.Net/Bitfinex.Net.csproj index 91f3f56..c56f0e0 100644 --- a/Bitfinex.Net/Bitfinex.Net.csproj +++ b/Bitfinex.Net/Bitfinex.Net.csproj @@ -51,8 +51,8 @@ all runtime; build; native; contentfiles; analyzers; buildtransitive - - + + all runtime; build; native; contentfiles; analyzers; buildtransitive diff --git a/Bitfinex.Net/Bitfinex.Net.xml b/Bitfinex.Net/Bitfinex.Net.xml index 80602e3..6c998a5 100644 --- a/Bitfinex.Net/Bitfinex.Net.xml +++ b/Bitfinex.Net/Bitfinex.Net.xml @@ -5569,31 +5569,6 @@ Bitfinex options - - - Rest client options - - - - - Socket client options - - - - - Trade environment. Contains info about URL's to use to connect to the API. Use `BitfinexEnvironment` to swap environment, for example `Environment = BitfinexEnvironment.Live` - - - - - The api credentials used for signing requests. - - - - - The DI service lifetime for the IBinanceSocketClient - - Options for the Bitfinex SymbolOrderBook diff --git a/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApiShared.cs b/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApiShared.cs index 19e5c5d..0973d8c 100644 --- a/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApiShared.cs +++ b/Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApiShared.cs @@ -19,10 +19,7 @@ internal partial class BitfinexRestClientSpotApi : IBitfinexRestClientSpotApiSha #region Kline client - GetKlinesOptions IKlineRestClient.GetKlinesOptions { get; } = new GetKlinesOptions(SharedPaginationSupport.Descending, false) - { - MaxRequestDataPoints = 10000 - }; + GetKlinesOptions IKlineRestClient.GetKlinesOptions { get; } = new GetKlinesOptions(SharedPaginationSupport.Descending, true, 10000, false); async Task>> IKlineRestClient.GetKlinesAsync(GetKlinesRequest request, INextPageToken? pageToken, CancellationToken ct) { @@ -407,7 +404,7 @@ async Task>> ISpotOrderRestClient }).ToArray()); } - PaginatedEndpointOptions ISpotOrderRestClient.GetClosedSpotOrdersOptions { get; } = new PaginatedEndpointOptions(SharedPaginationSupport.Descending, true); + PaginatedEndpointOptions ISpotOrderRestClient.GetClosedSpotOrdersOptions { get; } = new PaginatedEndpointOptions(SharedPaginationSupport.Descending, true, 2500, true); async Task>> ISpotOrderRestClient.GetClosedSpotOrdersAsync(GetClosedOrdersRequest request, INextPageToken? pageToken, CancellationToken ct) { @@ -483,7 +480,7 @@ async Task>> ISpotOrderRestClient }).ToArray()); } - PaginatedEndpointOptions ISpotOrderRestClient.GetSpotUserTradesOptions { get; } = new PaginatedEndpointOptions(SharedPaginationSupport.Descending, true); + PaginatedEndpointOptions ISpotOrderRestClient.GetSpotUserTradesOptions { get; } = new PaginatedEndpointOptions(SharedPaginationSupport.Descending, true, 2500, true); async Task>> ISpotOrderRestClient.GetSpotUserTradesAsync(GetUserTradesRequest request, INextPageToken? pageToken, CancellationToken ct) { var validationError = ((ISpotOrderRestClient)this).GetSpotUserTradesOptions.ValidateRequest(Exchange, request, request.Symbol.TradingMode, SupportedTradingModes); @@ -609,7 +606,7 @@ async Task>> IDepositRestCli }); } - GetDepositsOptions IDepositRestClient.GetDepositsOptions { get; } = new GetDepositsOptions(SharedPaginationSupport.Descending, true); + GetDepositsOptions IDepositRestClient.GetDepositsOptions { get; } = new GetDepositsOptions(SharedPaginationSupport.Descending, true, 1000); async Task>> IDepositRestClient.GetDepositsAsync(GetDepositsRequest request, INextPageToken? pageToken, CancellationToken ct) { var validationError = ((IDepositRestClient)this).GetDepositsOptions.ValidateRequest(Exchange, request, TradingMode.Spot, SupportedTradingModes); @@ -670,7 +667,7 @@ async Task> IOrderBookRestClient.GetOrderBook #region Trade History client - GetTradeHistoryOptions ITradeHistoryRestClient.GetTradeHistoryOptions { get; } = new GetTradeHistoryOptions(SharedPaginationSupport.Descending, false); + GetTradeHistoryOptions ITradeHistoryRestClient.GetTradeHistoryOptions { get; } = new GetTradeHistoryOptions(SharedPaginationSupport.Descending, true, 10000, false); async Task>> ITradeHistoryRestClient.GetTradeHistoryAsync(GetTradeHistoryRequest request, INextPageToken? pageToken, CancellationToken ct) { var validationError = ((ITradeHistoryRestClient)this).GetTradeHistoryOptions.ValidateRequest(Exchange, request, request.Symbol.TradingMode, SupportedTradingModes); @@ -709,7 +706,7 @@ async Task>> ITradeHistoryRestClient. #region Withdrawal client - GetWithdrawalsOptions IWithdrawalRestClient.GetWithdrawalsOptions { get; } = new GetWithdrawalsOptions(SharedPaginationSupport.Descending, true); + GetWithdrawalsOptions IWithdrawalRestClient.GetWithdrawalsOptions { get; } = new GetWithdrawalsOptions(SharedPaginationSupport.Descending, true, 1000); async Task>> IWithdrawalRestClient.GetWithdrawalsAsync(GetWithdrawalsRequest request, INextPageToken? pageToken, CancellationToken ct) { var validationError = ((IWithdrawalRestClient)this).GetWithdrawalsOptions.ValidateRequest(Exchange, request, TradingMode.Spot, SupportedTradingModes); @@ -776,5 +773,24 @@ async Task> IWithdrawRestClient.WithdrawAsync(Withdr } #endregion + + #region Fee Client + EndpointOptions IFeeRestClient.GetFeeOptions { get; } = new EndpointOptions(true); + + async Task> IFeeRestClient.GetFeesAsync(GetFeeRequest request, CancellationToken ct) + { + var validationError = ((IFeeRestClient)this).GetFeeOptions.ValidateRequest(Exchange, request, request.Symbol.TradingMode, SupportedTradingModes); + if (validationError != null) + return new ExchangeWebResult(Exchange, validationError); + + // Get data + var result = await Account.Get30DaySummaryAndFeesAsync(ct: ct).ConfigureAwait(false); + if (!result) + return result.AsExchangeResult(Exchange, null, default); + + // Return + return result.AsExchangeResult(Exchange, TradingMode.Spot, new SharedFee(result.Data.Fees.MakerFees.MakerFee * 100, result.Data.Fees.TakerFees.TakerFeeCrypto * 100)); + } + #endregion } } diff --git a/Bitfinex.Net/Interfaces/Clients/SpotApi/IBitfinexRestClientSpotApiShared.cs b/Bitfinex.Net/Interfaces/Clients/SpotApi/IBitfinexRestClientSpotApiShared.cs index bcdcd70..e5d046f 100644 --- a/Bitfinex.Net/Interfaces/Clients/SpotApi/IBitfinexRestClientSpotApiShared.cs +++ b/Bitfinex.Net/Interfaces/Clients/SpotApi/IBitfinexRestClientSpotApiShared.cs @@ -17,7 +17,8 @@ public interface IBitfinexRestClientSpotApiShared : ISpotTickerRestClient, ITradeHistoryRestClient, IWithdrawalRestClient, - IWithdrawRestClient + IWithdrawRestClient, + IFeeRestClient { } } diff --git a/Bitfinex.Net/Objects/Options/BitfinexOptions.cs b/Bitfinex.Net/Objects/Options/BitfinexOptions.cs index 43a3d23..0def048 100644 --- a/Bitfinex.Net/Objects/Options/BitfinexOptions.cs +++ b/Bitfinex.Net/Objects/Options/BitfinexOptions.cs @@ -1,4 +1,5 @@ using CryptoExchange.Net.Authentication; +using CryptoExchange.Net.Objects.Options; using Microsoft.Extensions.DependencyInjection; using System; using System.Collections.Generic; @@ -9,31 +10,7 @@ namespace Bitfinex.Net.Objects.Options /// /// Bitfinex options /// - public class BitfinexOptions + public class BitfinexOptions : LibraryOptions { - /// - /// Rest client options - /// - public BitfinexRestOptions Rest { get; set; } = new BitfinexRestOptions(); - - /// - /// Socket client options - /// - public BitfinexSocketOptions Socket { get; set; } = new BitfinexSocketOptions(); - - /// - /// Trade environment. Contains info about URL's to use to connect to the API. Use `BitfinexEnvironment` to swap environment, for example `Environment = BitfinexEnvironment.Live` - /// - public BitfinexEnvironment? Environment { get; set; } - - /// - /// The api credentials used for signing requests. - /// - public ApiCredentials? ApiCredentials { get; set; } - - /// - /// The DI service lifetime for the IBinanceSocketClient - /// - public ServiceLifetime? SocketClientLifeTime { get; set; } } }