@@ -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 {
0 commit comments