Skip to content

Commit

Permalink
CryptoExchange update
Browse files Browse the repository at this point in the history
  • Loading branch information
JKorf committed Nov 28, 2024
1 parent ea98970 commit ea72ba6
Show file tree
Hide file tree
Showing 6 changed files with 35 additions and 66 deletions.
8 changes: 4 additions & 4 deletions Bitfinex.Net.UnitTests/Bitfinex.Net.UnitTests.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
</PropertyGroup>

<ItemGroup>
<packagereference Include="Microsoft.NET.Test.Sdk" Version="17.9.0"></packagereference>
<PackageReference Include="Moq" Version="4.20.70" />
<packagereference Include="NUnit" Version="4.1.0"></packagereference>
<packagereference Include="NUnit3TestAdapter" Version="4.5.0"></packagereference>
<packagereference Include="Microsoft.NET.Test.Sdk" Version="17.12.0"></packagereference>
<PackageReference Include="Moq" Version="4.20.72" />
<packagereference Include="NUnit" Version="4.2.2"></packagereference>
<packagereference Include="NUnit3TestAdapter" Version="4.6.0"></packagereference>
</ItemGroup>

<ItemGroup>
Expand Down
4 changes: 2 additions & 2 deletions Bitfinex.Net/Bitfinex.Net.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -51,8 +51,8 @@
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
<PackageReference Include="CryptoExchange.Net" Version="8.3.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="8.0.0">
<PackageReference Include="CryptoExchange.Net" Version="8.4.0" />
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
</PackageReference>
Expand Down
25 changes: 0 additions & 25 deletions Bitfinex.Net/Bitfinex.Net.xml

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

34 changes: 25 additions & 9 deletions Bitfinex.Net/Clients/SpotApi/BitfinexRestClientSpotApiShared.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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<ExchangeWebResult<IEnumerable<SharedKline>>> IKlineRestClient.GetKlinesAsync(GetKlinesRequest request, INextPageToken? pageToken, CancellationToken ct)
{
Expand Down Expand Up @@ -407,7 +404,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedSpotOrder>>> ISpotOrderRestClient
}).ToArray());
}

PaginatedEndpointOptions<GetClosedOrdersRequest> ISpotOrderRestClient.GetClosedSpotOrdersOptions { get; } = new PaginatedEndpointOptions<GetClosedOrdersRequest>(SharedPaginationSupport.Descending, true);
PaginatedEndpointOptions<GetClosedOrdersRequest> ISpotOrderRestClient.GetClosedSpotOrdersOptions { get; } = new PaginatedEndpointOptions<GetClosedOrdersRequest>(SharedPaginationSupport.Descending, true, 2500, true);

async Task<ExchangeWebResult<IEnumerable<SharedSpotOrder>>> ISpotOrderRestClient.GetClosedSpotOrdersAsync(GetClosedOrdersRequest request, INextPageToken? pageToken, CancellationToken ct)
{
Expand Down Expand Up @@ -483,7 +480,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedUserTrade>>> ISpotOrderRestClient
}).ToArray());
}

PaginatedEndpointOptions<GetUserTradesRequest> ISpotOrderRestClient.GetSpotUserTradesOptions { get; } = new PaginatedEndpointOptions<GetUserTradesRequest>(SharedPaginationSupport.Descending, true);
PaginatedEndpointOptions<GetUserTradesRequest> ISpotOrderRestClient.GetSpotUserTradesOptions { get; } = new PaginatedEndpointOptions<GetUserTradesRequest>(SharedPaginationSupport.Descending, true, 2500, true);
async Task<ExchangeWebResult<IEnumerable<SharedUserTrade>>> ISpotOrderRestClient.GetSpotUserTradesAsync(GetUserTradesRequest request, INextPageToken? pageToken, CancellationToken ct)
{
var validationError = ((ISpotOrderRestClient)this).GetSpotUserTradesOptions.ValidateRequest(Exchange, request, request.Symbol.TradingMode, SupportedTradingModes);
Expand Down Expand Up @@ -609,7 +606,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedDepositAddress>>> IDepositRestCli
});
}

GetDepositsOptions IDepositRestClient.GetDepositsOptions { get; } = new GetDepositsOptions(SharedPaginationSupport.Descending, true);
GetDepositsOptions IDepositRestClient.GetDepositsOptions { get; } = new GetDepositsOptions(SharedPaginationSupport.Descending, true, 1000);
async Task<ExchangeWebResult<IEnumerable<SharedDeposit>>> IDepositRestClient.GetDepositsAsync(GetDepositsRequest request, INextPageToken? pageToken, CancellationToken ct)
{
var validationError = ((IDepositRestClient)this).GetDepositsOptions.ValidateRequest(Exchange, request, TradingMode.Spot, SupportedTradingModes);
Expand Down Expand Up @@ -670,7 +667,7 @@ async Task<ExchangeWebResult<SharedOrderBook>> 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<ExchangeWebResult<IEnumerable<SharedTrade>>> ITradeHistoryRestClient.GetTradeHistoryAsync(GetTradeHistoryRequest request, INextPageToken? pageToken, CancellationToken ct)
{
var validationError = ((ITradeHistoryRestClient)this).GetTradeHistoryOptions.ValidateRequest(Exchange, request, request.Symbol.TradingMode, SupportedTradingModes);
Expand Down Expand Up @@ -709,7 +706,7 @@ async Task<ExchangeWebResult<IEnumerable<SharedTrade>>> 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<ExchangeWebResult<IEnumerable<SharedWithdrawal>>> IWithdrawalRestClient.GetWithdrawalsAsync(GetWithdrawalsRequest request, INextPageToken? pageToken, CancellationToken ct)
{
var validationError = ((IWithdrawalRestClient)this).GetWithdrawalsOptions.ValidateRequest(Exchange, request, TradingMode.Spot, SupportedTradingModes);
Expand Down Expand Up @@ -776,5 +773,24 @@ async Task<ExchangeWebResult<SharedId>> IWithdrawRestClient.WithdrawAsync(Withdr
}

#endregion

#region Fee Client
EndpointOptions<GetFeeRequest> IFeeRestClient.GetFeeOptions { get; } = new EndpointOptions<GetFeeRequest>(true);

async Task<ExchangeWebResult<SharedFee>> IFeeRestClient.GetFeesAsync(GetFeeRequest request, CancellationToken ct)
{
var validationError = ((IFeeRestClient)this).GetFeeOptions.ValidateRequest(Exchange, request, request.Symbol.TradingMode, SupportedTradingModes);
if (validationError != null)
return new ExchangeWebResult<SharedFee>(Exchange, validationError);

// Get data
var result = await Account.Get30DaySummaryAndFeesAsync(ct: ct).ConfigureAwait(false);
if (!result)
return result.AsExchangeResult<SharedFee>(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
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,8 @@ public interface IBitfinexRestClientSpotApiShared :
ISpotTickerRestClient,
ITradeHistoryRestClient,
IWithdrawalRestClient,
IWithdrawRestClient
IWithdrawRestClient,
IFeeRestClient
{
}
}
27 changes: 2 additions & 25 deletions Bitfinex.Net/Objects/Options/BitfinexOptions.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
using CryptoExchange.Net.Authentication;
using CryptoExchange.Net.Objects.Options;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
Expand All @@ -9,31 +10,7 @@ namespace Bitfinex.Net.Objects.Options
/// <summary>
/// Bitfinex options
/// </summary>
public class BitfinexOptions
public class BitfinexOptions : LibraryOptions<BitfinexRestOptions, BitfinexSocketOptions, ApiCredentials, BitfinexEnvironment>
{
/// <summary>
/// Rest client options
/// </summary>
public BitfinexRestOptions Rest { get; set; } = new BitfinexRestOptions();

/// <summary>
/// Socket client options
/// </summary>
public BitfinexSocketOptions Socket { get; set; } = new BitfinexSocketOptions();

/// <summary>
/// Trade environment. Contains info about URL's to use to connect to the API. Use `BitfinexEnvironment` to swap environment, for example `Environment = BitfinexEnvironment.Live`
/// </summary>
public BitfinexEnvironment? Environment { get; set; }

/// <summary>
/// The api credentials used for signing requests.
/// </summary>
public ApiCredentials? ApiCredentials { get; set; }

/// <summary>
/// The DI service lifetime for the IBinanceSocketClient
/// </summary>
public ServiceLifetime? SocketClientLifeTime { get; set; }
}
}

0 comments on commit ea72ba6

Please sign in to comment.