Skip to content

Commit 811799d

Browse files
authored
CryptoExchange.Net update (#93)
Updated CryptoExchange.Net to version 10.7.0 Added additional Http settings to client options Added startTime, endTime parameters to restClient.FuturesApi.ExchangeData.GetKlinesAsync endpoint Added startTime, endTime parameters to restClient.SpotApi.ExchangeData.GetKlinesAsync endpoint Updated Shared REST interfaces pagination logic Updated HttpClient registration, fixing issue of DNS changes not getting processed Fixed UserClientProvider using unconfigured HttpClient
1 parent 12ce767 commit 811799d

10 files changed

Lines changed: 487 additions & 326 deletions

CoinEx.Net/Clients/CoinExUserClientProvider.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -44,6 +44,7 @@ public CoinExUserClientProvider(
4444
IOptions<CoinExSocketOptions> socketOptions)
4545
{
4646
_httpClient = httpClient ?? new HttpClient();
47+
_httpClient.Timeout = restOptions.Value.RequestTimeout;
4748
_loggerFactory = loggerFactory;
4849
_restOptions = restOptions;
4950
_socketOptions = socketOptions;

CoinEx.Net/Clients/FuturesApi/CoinExRestClientFuturesApiExchangeData.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -74,7 +74,14 @@ public async Task<WebCallResult<CoinExTrade[]>> GetTradeHistoryAsync(string symb
7474
}
7575

7676
/// <inheritdoc />
77-
public async Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol, KlineInterval interval, int? limit = null, PriceType? priceType = null, CancellationToken ct = default)
77+
public async Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(
78+
string symbol,
79+
KlineInterval interval,
80+
int? limit = null,
81+
PriceType? priceType = null,
82+
DateTime? startTime = null,
83+
DateTime? endTime = null,
84+
CancellationToken ct = default)
7885
{
7986
var parameters = new ParameterCollection()
8087
{
@@ -83,6 +90,8 @@ public async Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol, Kl
8390
parameters.AddEnum("period", interval);
8491
parameters.AddOptionalEnum("price_type", priceType);
8592
parameters.AddOptional("limit", limit);
93+
parameters.AddOptionalMilliseconds("start_time", startTime);
94+
parameters.AddOptionalMilliseconds("end_time", endTime);
8695
var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/futures/kline", CoinExExchange.RateLimiter.CoinExRestPublic, 1, false);
8796
return await _baseClient.SendAsync<CoinExKline[]>(request, parameters, ct).ConfigureAwait(false);
8897
}

CoinEx.Net/Clients/FuturesApi/CoinExRestClientFuturesApiShared.cs

Lines changed: 242 additions & 148 deletions
Large diffs are not rendered by default.

CoinEx.Net/Clients/SpotApiV2/CoinExRestClientSpotApiExchangeData.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -87,7 +87,14 @@ public async Task<WebCallResult<CoinExTrade[]>> GetTradeHistoryAsync(string symb
8787
}
8888

8989
/// <inheritdoc />
90-
public async Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol, KlineInterval interval, int? limit = null, PriceType? priceType = null, CancellationToken ct = default)
90+
public async Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(
91+
string symbol,
92+
KlineInterval interval,
93+
int? limit = null,
94+
PriceType? priceType = null,
95+
DateTime? startTime = null,
96+
DateTime? endTime = null,
97+
CancellationToken ct = default)
9198
{
9299
var parameters = new ParameterCollection()
93100
{
@@ -96,6 +103,8 @@ public async Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol, Kl
96103
parameters.AddEnum("period", interval);
97104
parameters.AddOptionalEnum("price_type", priceType);
98105
parameters.AddOptional("limit", limit);
106+
parameters.AddOptionalMilliseconds("start_time", startTime);
107+
parameters.AddOptionalMilliseconds("end_time", endTime);
99108
var request = _definitions.GetOrCreate(HttpMethod.Get, "v2/spot/kline", CoinExExchange.RateLimiter.CoinExRestPublic);
100109
return await _baseClient.SendAsync<CoinExKline[]>(request, parameters, ct).ConfigureAwait(false);
101110
}

CoinEx.Net/Clients/SpotApiV2/CoinExRestClientSpotApiShared.cs

Lines changed: 192 additions & 166 deletions
Large diffs are not rendered by default.

CoinEx.Net/CoinEx.Net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -53,8 +53,8 @@
5353
<PrivateAssets>all</PrivateAssets>
5454
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5555
</PackageReference>
56-
<PackageReference Include="CryptoExchange.Net" Version="10.6.0" />
5756
<PackageReference Include="Crc32.NET" Version="1.2.0" />
57+
<PackageReference Include="CryptoExchange.Net" Version="10.7.0" />
5858
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="10.0.101">
5959
<PrivateAssets>all</PrivateAssets>
6060
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

CoinEx.Net/CoinEx.Net.xml

Lines changed: 8 additions & 4 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

CoinEx.Net/ExtensionMethods/ServiceCollectionExtensions.cs

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
using System;
1515
using System.Net;
1616
using System.Net.Http;
17+
using System.Threading;
1718

1819
namespace Microsoft.Extensions.DependencyInjection
1920
{
@@ -96,8 +97,8 @@ private static IServiceCollection AddCoinExCore(
9697
return new CoinExRestClient(client, serviceProvider.GetRequiredService<ILoggerFactory>(), serviceProvider.GetRequiredService<IOptions<CoinExRestOptions>>());
9798
}).ConfigurePrimaryHttpMessageHandler((serviceProvider) => {
9899
var options = serviceProvider.GetRequiredService<IOptions<CoinExRestOptions>>().Value;
99-
return LibraryHelpers.CreateHttpClientMessageHandler(options.Proxy, options.HttpKeepAliveInterval);
100-
});
100+
return LibraryHelpers.CreateHttpClientMessageHandler(options);
101+
}).SetHandlerLifetime(Timeout.InfiniteTimeSpan);
101102
services.Add(new ServiceDescriptor(typeof(ICoinExSocketClient), x => { return new CoinExSocketClient(x.GetRequiredService<IOptions<CoinExSocketOptions>>(), x.GetRequiredService<ILoggerFactory>()); }, socketClientLifeTime ?? ServiceLifetime.Singleton));
102103

103104
services.AddTransient<ICryptoRestClient, CryptoRestClient>();
@@ -107,7 +108,7 @@ private static IServiceCollection AddCoinExCore(
107108
services.AddTransient<ITrackerFactory, CoinExTrackerFactory>();
108109
services.AddSingleton<ICoinExUserClientProvider, CoinExUserClientProvider>(x =>
109110
new CoinExUserClientProvider(
110-
x.GetRequiredService<HttpClient>(),
111+
x.GetRequiredService<IHttpClientFactory>().CreateClient(typeof(ICoinExRestClient).Name),
111112
x.GetRequiredService<ILoggerFactory>(),
112113
x.GetRequiredService<IOptions<CoinExRestOptions>>(),
113114
x.GetRequiredService<IOptions<CoinExSocketOptions>>()));

CoinEx.Net/Interfaces/Clients/FuturesApi/ICoinExRestClientFuturesApiExchangeData.cs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -69,9 +69,17 @@ public interface ICoinExRestClientFuturesApiExchangeData
6969
/// <param name="interval">Kline interval</param>
7070
/// <param name="limit">Max amount of results</param>
7171
/// <param name="priceType">Price type, either LastPrice(default) or IndexPrice</param>
72+
/// <param name="startTime">Filter by start time</param>
73+
/// <param name="endTime">Filter by end time</param>
7274
/// <param name="ct">Cancelation Token</param>
7375
/// <returns></returns>
74-
Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol, KlineInterval interval, int? limit = null, PriceType? priceType = null, CancellationToken ct = default);
76+
Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol,
77+
KlineInterval interval,
78+
int? limit = null,
79+
PriceType? priceType = null,
80+
DateTime? startTime = null,
81+
DateTime? endTime = null,
82+
CancellationToken ct = default);
7583

7684
/// <summary>
7785
/// Get index prices

CoinEx.Net/Interfaces/Clients/SpotApiV2/ICoinExRestClientSpotApiExchangeData.cs

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -85,9 +85,18 @@ public interface ICoinExRestClientSpotApiExchangeData
8585
/// <param name="interval">Kline interval</param>
8686
/// <param name="limit">Max amount of results</param>
8787
/// <param name="priceType">Price type, either LastPrice(default) or IndexPrice</param>
88+
/// <param name="startTime">Filter by start time</param>
89+
/// <param name="endTime">Filter by end time</param>
8890
/// <param name="ct">Cancelation Token</param>
8991
/// <returns></returns>
90-
Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(string symbol, KlineInterval interval, int? limit = null, PriceType? priceType = null, CancellationToken ct = default);
92+
Task<WebCallResult<CoinExKline[]>> GetKlinesAsync(
93+
string symbol,
94+
KlineInterval interval,
95+
int? limit = null,
96+
PriceType? priceType = null,
97+
DateTime? startTime = null,
98+
DateTime? endTime = null,
99+
CancellationToken ct = default);
91100

92101
/// <summary>
93102
/// Get index prices

0 commit comments

Comments
 (0)