Skip to content

Commit 915ca03

Browse files
committed
Updated CryptoExchange.Net to version 9.11.0
1 parent f09bd79 commit 915ca03

File tree

9 files changed

+101
-27
lines changed

9 files changed

+101
-27
lines changed

HTX.Net/Clients/SpotApi/HTXRestClientSpotApiTrading.cs

Lines changed: 49 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,11 @@ public async Task<WebCallResult<long>> PlaceOrderAsync(
4444
};
4545
parameters.AddString("amount", quantity);
4646

47-
clientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId);
47+
clientOrderId = LibraryHelpers.ApplyBrokerId(
48+
clientOrderId,
49+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
50+
64,
51+
_baseClient.ClientOptions.AllowAppendingClientOrderId);
4852

4953
parameters.AddOptionalParameter("client-order-id", clientOrderId);
5054
parameters.AddOptionalString("stop-price", stopPrice);
@@ -79,8 +83,12 @@ public async Task<WebCallResult<CallResult<HTXBatchPlaceResult>[]>> PlaceMultipl
7983
{ "type", orderType }
8084
};
8185
parameters.AddString("amount", order.Quantity);
82-
order.ClientOrderId = LibraryHelpers.ApplyBrokerId(order.ClientOrderId, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId);
83-
86+
order.ClientOrderId = LibraryHelpers.ApplyBrokerId(
87+
order.ClientOrderId,
88+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
89+
64,
90+
_baseClient.ClientOptions.AllowAppendingClientOrderId);
91+
8492
parameters.AddOptionalParameter("client-order-id", order.ClientOrderId);
8593
parameters.AddOptionalString("stop-price", order.StopPrice);
8694
parameters.AddOptionalEnum("source", order.Source);
@@ -181,7 +189,11 @@ public async Task<WebCallResult<long>> CancelOrderAsync(long orderId, Cancellati
181189
/// <inheritdoc />
182190
public async Task<WebCallResult<long>> CancelOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default)
183191
{
184-
clientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId);
192+
clientOrderId = LibraryHelpers.ApplyBrokerId(
193+
clientOrderId,
194+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
195+
64,
196+
_baseClient.ClientOptions.AllowAppendingClientOrderId);
185197

186198
var parameters = new ParameterCollection()
187199
{
@@ -254,7 +266,12 @@ public async Task<WebCallResult<HTXBatchCancelResult>> CancelOrdersAsync(IEnumer
254266

255267
var parameters = new ParameterCollection();
256268
parameters.AddOptionalParameter("order-ids", orderIds?.Select(s => s.ToString(CultureInfo.InvariantCulture)).ToArray());
257-
parameters.AddOptionalParameter("client-order-ids", clientOrderIds?.Select(s => LibraryHelpers.ApplyBrokerId(s, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId).ToString(CultureInfo.InvariantCulture)).ToArray());
269+
parameters.AddOptionalParameter("client-order-ids", clientOrderIds?.Select(s =>
270+
LibraryHelpers.ApplyBrokerId(
271+
s,
272+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
273+
64,
274+
_baseClient.ClientOptions.AllowAppendingClientOrderId)).ToArray());
258275

259276
var request = _definitions.GetOrCreate(HttpMethod.Post, "v1/order/orders/batchcancel", HTXExchange.RateLimiter.EndpointLimit, 1, true,
260277
new SingleLimitGuard(50, TimeSpan.FromSeconds(2), RateLimitWindowType.Sliding, keySelector: SingleLimitGuard.PerApiKey));
@@ -299,7 +316,11 @@ public async Task<WebCallResult<HTXOrder>> GetOrderAsync(long orderId, Cancellat
299316
/// <inheritdoc />
300317
public async Task<WebCallResult<HTXOrder>> GetOrderByClientOrderIdAsync(string clientOrderId, CancellationToken ct = default)
301318
{
302-
clientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId);
319+
clientOrderId = LibraryHelpers.ApplyBrokerId(
320+
clientOrderId,
321+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
322+
64,
323+
_baseClient.ClientOptions.AllowAppendingClientOrderId);
303324

304325
var parameters = new ParameterCollection()
305326
{
@@ -414,15 +435,23 @@ public async Task<WebCallResult<HTXPlacedConditionalOrder>> PlaceConditionalOrde
414435
{
415436
symbol = symbol.ToLowerInvariant();
416437

417-
clientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId);
438+
if (clientOrderId != null)
439+
{
440+
clientOrderId = LibraryHelpers.ApplyBrokerId(
441+
clientOrderId,
442+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
443+
64,
444+
_baseClient.ClientOptions.AllowAppendingClientOrderId);
445+
}
446+
418447
var parameters = new ParameterCollection()
419448
{
420449
{ "accountId", accountId },
421450
{ "symbol", symbol },
422451
{ "orderSide", EnumConverter.GetString(side) },
423-
{ "orderType", EnumConverter.GetString(type) },
424-
{ "clientOrderId", clientOrderId }
452+
{ "orderType", EnumConverter.GetString(type) }
425453
};
454+
parameters.AddOptional("clientOrderId", clientOrderId);
426455
parameters.AddString("stopPrice", stopPrice);
427456

428457
parameters.AddOptionalString("orderPrice", price);
@@ -445,7 +474,12 @@ public async Task<WebCallResult<HTXConditionalOrderCancelResult>> CancelConditio
445474
{
446475
var parameters = new ParameterCollection()
447476
{
448-
{ "clientOrderIds", clientOrderIds.Select(x => LibraryHelpers.ApplyBrokerId(x, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId)).ToArray() }
477+
{ "clientOrderIds", clientOrderIds.Select(x =>
478+
LibraryHelpers.ApplyBrokerId(
479+
x,
480+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
481+
64,
482+
_baseClient.ClientOptions.AllowAppendingClientOrderId)).ToArray() }
449483
};
450484

451485
var request = _definitions.GetOrCreate(HttpMethod.Post, $"v2/algo-orders/cancellation", HTXExchange.RateLimiter.EndpointLimit, 1, true,
@@ -522,7 +556,11 @@ public async Task<WebCallResult<HTXConditionalOrder[]>> GetClosedConditionalOrde
522556
/// <inheritdoc />
523557
public async Task<WebCallResult<HTXConditionalOrder>> GetConditionalOrderAsync(string clientOrderId, CancellationToken ct = default)
524558
{
525-
clientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, _baseClient.ClientOptions.AllowAppendingClientOrderId);
559+
clientOrderId = LibraryHelpers.ApplyBrokerId(
560+
clientOrderId,
561+
LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange),
562+
64,
563+
_baseClient.ClientOptions.AllowAppendingClientOrderId);
526564

527565
var parameters = new ParameterCollection()
528566
{

HTX.Net/Clients/SpotApi/HTXSocketClientSpotApi.cs

Lines changed: 22 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -307,7 +307,11 @@ public async Task<CallResult<string>> PlaceOrderAsync(
307307
var request = new HTXSocketPlaceOrderRequest()
308308
{
309309
AccountId = accountId,
310-
ClientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, ClientOptions.AllowAppendingClientOrderId),
310+
ClientOrderId = LibraryHelpers.ApplyBrokerId(
311+
clientOrderId,
312+
LibraryHelpers.GetClientReference(() => ClientOptions.BrokerId, Exchange),
313+
64,
314+
ClientOptions.AllowAppendingClientOrderId),
311315
Price = price,
312316
Type = orderType,
313317
Quantity = quantity,
@@ -344,7 +348,11 @@ public async Task<CallResult<CallResult<HTXBatchPlaceResult>[]>> PlaceMultipleOr
344348
var parameters = new HTXSocketPlaceOrderRequest()
345349
{
346350
AccountId = accountId,
347-
ClientOrderId = LibraryHelpers.ApplyBrokerId(order.ClientOrderId, HTXExchange.ClientOrderId, 64, ClientOptions.AllowAppendingClientOrderId),
351+
ClientOrderId = LibraryHelpers.ApplyBrokerId(
352+
order.ClientOrderId,
353+
LibraryHelpers.GetClientReference(() => ClientOptions.BrokerId, Exchange),
354+
64,
355+
ClientOptions.AllowAppendingClientOrderId),
348356
Price = order.Price,
349357
Type = orderType,
350358
Quantity = order.Quantity,
@@ -458,8 +466,13 @@ public async Task<CallResult> CancelOrderAsync(
458466
string? clientOrderId = null,
459467
CancellationToken ct = default)
460468
{
461-
if (clientOrderId != null)
462-
clientOrderId = LibraryHelpers.ApplyBrokerId(clientOrderId, HTXExchange.ClientOrderId, 64, ClientOptions.AllowAppendingClientOrderId);
469+
if (clientOrderId != null) {
470+
clientOrderId = LibraryHelpers.ApplyBrokerId(
471+
clientOrderId,
472+
LibraryHelpers.GetClientReference(() => ClientOptions.BrokerId, Exchange),
473+
64,
474+
ClientOptions.AllowAppendingClientOrderId);
475+
}
463476

464477
var result = await CancelOrdersAsync(orderId == null ? null : [orderId], clientOrderId == null ? null : [clientOrderId], ct).ConfigureAwait(false);
465478
if (!result)
@@ -480,7 +493,11 @@ public async Task<CallResult<HTXBatchCancelResult>> CancelOrdersAsync(
480493

481494
var parameters = new ParameterCollection();
482495
parameters.AddOptional("order-ids", orderIds?.ToArray());
483-
parameters.AddOptional("client-order-ids", clientOrderIds?.Select(x => LibraryHelpers.ApplyBrokerId(x, HTXExchange.ClientOrderId, 64, ClientOptions.AllowAppendingClientOrderId)).ToArray());
496+
parameters.AddOptional("client-order-ids", clientOrderIds?.Select(x => LibraryHelpers.ApplyBrokerId(
497+
x,
498+
LibraryHelpers.GetClientReference(() => ClientOptions.BrokerId, Exchange),
499+
64,
500+
ClientOptions.AllowAppendingClientOrderId)).ToArray());
484501

485502
var query = new HTXOrderQuery<ParameterCollection, HTXBatchCancelResult>(this, new HTXSocketOrderRequest<ParameterCollection>
486503
{

HTX.Net/Clients/UsdtFutures/HTXRestClientUsdtFuturesApiTrading.cs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -57,7 +57,7 @@ public async Task<WebCallResult<HTXOrderIds>> PlaceIsolatedMarginOrderAsync(
5757
{ "volume", quantity },
5858
{ "direction", EnumConverter.GetString(side) },
5959
{ "lever_rate", leverageRate },
60-
{ "channel_code", HTXExchange.ClientOrderId },
60+
{ "channel_code", LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange) },
6161
{ "order_price_type", EnumConverter.GetString(orderPriceType) }
6262
};
6363
parameters.AddOptionalParameter("price", price?.ToString(CultureInfo.InvariantCulture));
@@ -105,7 +105,7 @@ public async Task<WebCallResult<HTXOrderIds>> PlaceCrossMarginOrderAsync(
105105
{ "volume", quantity },
106106
{ "direction", EnumConverter.GetString(side) },
107107
{ "lever_rate", leverageRate },
108-
{ "channel_code", HTXExchange.ClientOrderId },
108+
{ "channel_code", LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange) },
109109
{ "order_price_type", EnumConverter.GetString(orderPriceType) }
110110
};
111111
parameters.AddOptionalParameter("contract_code", contractCode);
@@ -555,7 +555,7 @@ public async Task<WebCallResult<HTXOrderIds>> PlaceIsolatedMarginTriggerOrderAsy
555555
{
556556
var parameters = new ParameterCollection()
557557
{
558-
{ "channel_code", HTXExchange.ClientOrderId }
558+
{ "channel_code", LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange) }
559559
};
560560
parameters.Add("contract_code", contractCode);
561561
parameters.AddEnum("trigger_type", triggerType);
@@ -581,7 +581,7 @@ public async Task<WebCallResult<HTXOrderIds>> PlaceCrossMarginTriggerOrderAsync(
581581
{
582582
var parameters = new ParameterCollection()
583583
{
584-
{ "channel_code", HTXExchange.ClientOrderId }
584+
{ "channel_code", LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange) }
585585
};
586586
parameters.AddOptional("contract_code", contractCode);
587587
parameters.AddEnum("trigger_type", triggerType);
@@ -985,7 +985,7 @@ public async Task<WebCallResult<HTXOrderIds>> PlaceIsolatedMarginTrailingOrderAs
985985
{
986986
var parameters = new ParameterCollection()
987987
{
988-
{ "channel_code", HTXExchange.ClientOrderId }
988+
{ "channel_code", LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange) }
989989
};
990990
parameters.Add("contract_code", contractCode);
991991
parameters.Add("reduce_only", reduceOnly ? 1 : 0);
@@ -1010,7 +1010,7 @@ public async Task<WebCallResult<HTXOrderIds>> PlaceCrossMarginTrailingOrderAsync
10101010
{
10111011
var parameters = new ParameterCollection()
10121012
{
1013-
{ "channel_code", HTXExchange.ClientOrderId }
1013+
{ "channel_code", LibraryHelpers.GetClientReference(() => _baseClient.ClientOptions.BrokerId, _baseClient.Exchange) }
10141014
};
10151015
parameters.AddOptional("contract_code", contractCode);
10161016
parameters.AddOptional("pair", pair);

HTX.Net/Converters/ClientIdConverter.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,6 @@ namespace HTX.Net.Converters
66
{
77
internal class ClientIdConverter : ReplaceConverter
88
{
9-
public ClientIdConverter() : base($"{HTXExchange.ClientOrderIdPrefix}->") { }
9+
public ClientIdConverter() : base($"{LibraryHelpers.GetClientReference(() => null, "HTX")}{LibraryHelpers.ClientOrderIdSeparator}->") { }
1010
}
1111
}

HTX.Net/HTX.Net.csproj

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@
5252
<PrivateAssets>all</PrivateAssets>
5353
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>
5454
</PackageReference>
55-
<PackageReference Include="CryptoExchange.Net" Version="9.10.0" />
55+
<PackageReference Include="CryptoExchange.Net" Version="9.11.0" />
5656
<PackageReference Include="Microsoft.CodeAnalysis.NetAnalyzers" Version="9.0.0">
5757
<PrivateAssets>all</PrivateAssets>
5858
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

HTX.Net/HTX.Net.xml

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22184,6 +22184,11 @@
2218422184
* Toggling this option might fail operations using a clientOrderId parameter for pre-existing orders which were placed before the toggle. Operations on orders placed after the toggle will work as expected. It's adviced to toggle when there are no open orders
2218522185
</summary>
2218622186
</member>
22187+
<member name="P:HTX.Net.Objects.Options.HTXRestOptions.BrokerId">
22188+
<summary>
22189+
Broker id
22190+
</summary>
22191+
</member>
2218722192
<member name="P:HTX.Net.Objects.Options.HTXRestOptions.SignPublicRequests">
2218822193
<summary>
2218922194
Whether public requests should be signed if ApiCredentials are provided. Needed for accurate rate limiting.
@@ -22224,6 +22229,11 @@
2222422229
* Toggling this option might fail operations using a clientOrderId parameter for pre-existing orders which were placed before the toggle. Operations on orders placed after the toggle will work as expected. It's adviced to toggle when there are no open orders
2222522230
</summary>
2222622231
</member>
22232+
<member name="P:HTX.Net.Objects.Options.HTXSocketOptions.BrokerId">
22233+
<summary>
22234+
Broker id
22235+
</summary>
22236+
</member>
2222722237
<member name="P:HTX.Net.Objects.Options.HTXSocketOptions.SpotOptions">
2222822238
<summary>
2222922239
Spot API options

HTX.Net/HTXExchange.cs

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,6 @@ public static class HTXExchange
4545
/// </summary>
4646
public static ExchangeType Type { get; } = ExchangeType.CEX;
4747

48-
internal const string ClientOrderId = "AA1ef14811";
49-
internal const string ClientOrderIdPrefix = ClientOrderId + LibraryHelpers.ClientOrderIdSeparator;
50-
5148
internal static JsonSerializerContext _serializerContext = JsonSerializerContextCache.GetOrCreate<HTXSourceGenerationContext>();
5249

5350
/// <summary>

HTX.Net/Objects/Options/HTXRestOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,11 @@ public HTXRestOptions()
3333
/// </summary>
3434
public bool AllowAppendingClientOrderId { get; set; } = false;
3535

36+
/// <summary>
37+
/// Broker id
38+
/// </summary>
39+
public string? BrokerId { get; set; }
40+
3641
/// <summary>
3742
/// Whether public requests should be signed if ApiCredentials are provided. Needed for accurate rate limiting.
3843
/// </summary>
@@ -53,6 +58,7 @@ internal HTXRestOptions Set(HTXRestOptions targetOptions)
5358
targetOptions = base.Set<HTXRestOptions>(targetOptions);
5459
targetOptions.AllowAppendingClientOrderId = AllowAppendingClientOrderId;
5560
targetOptions.SignPublicRequests = SignPublicRequests;
61+
targetOptions.BrokerId = BrokerId;
5662
targetOptions.SpotOptions = SpotOptions.Set(targetOptions.SpotOptions);
5763
targetOptions.UsdtMarginSwapOptions = UsdtMarginSwapOptions.Set(targetOptions.UsdtMarginSwapOptions);
5864
return targetOptions;

HTX.Net/Objects/Options/HTXSocketOptions.cs

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,11 @@ public HTXSocketOptions()
3535
/// </summary>
3636
public bool AllowAppendingClientOrderId { get; set; } = false;
3737

38+
/// <summary>
39+
/// Broker id
40+
/// </summary>
41+
public string? BrokerId { get; set; }
42+
3843
/// <summary>
3944
/// Spot API options
4045
/// </summary>
@@ -49,6 +54,7 @@ internal HTXSocketOptions Set(HTXSocketOptions targetOptions)
4954
{
5055
targetOptions = base.Set<HTXSocketOptions>(targetOptions);
5156
targetOptions.AllowAppendingClientOrderId = AllowAppendingClientOrderId;
57+
targetOptions.BrokerId = BrokerId;
5258
targetOptions.SpotOptions = SpotOptions.Set(targetOptions.SpotOptions);
5359
targetOptions.UsdtMarginSwapOptions = UsdtMarginSwapOptions.Set(targetOptions.UsdtMarginSwapOptions);
5460
return targetOptions;

0 commit comments

Comments
 (0)