From 7413d03d3110e6cebe62b0901c00eb0b881e9dc1 Mon Sep 17 00:00:00 2001 From: Jkorf Date: Thu, 30 Oct 2025 11:25:27 +0100 Subject: [PATCH] Added client reference helper to LibraryHelpers --- CryptoExchange.Net/LibraryHelpers.cs | 39 ++++++++++++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/CryptoExchange.Net/LibraryHelpers.cs b/CryptoExchange.Net/LibraryHelpers.cs index 2a07dcb..64491cd 100644 --- a/CryptoExchange.Net/LibraryHelpers.cs +++ b/CryptoExchange.Net/LibraryHelpers.cs @@ -17,6 +17,29 @@ namespace CryptoExchange.Net /// public const string ClientOrderIdSeparator = "JK"; + private static Dictionary _defaultClientReferences = new Dictionary() + { + { "Binance.Spot", "x-VICEW9VV" }, + { "Binance.Futures", "x-d63tKbx3" }, + { "BingX", "easytrading" }, + { "Bitfinex", "kCCe-CNBO" }, + { "Bitget", "6x21p" }, + { "BitMart", "EASYTRADING0001" }, + { "BitMEX", "Sent from JKorf" }, + { "BloFin", "5c07cf695885c282" }, + { "Bybit", "Zx000356" }, + { "CoinEx", "x-147866029-" }, + { "GateIo", "copytraderpw" }, + { "HTX", "AA1ef14811" }, + { "Kucoin.FuturesName", "Easytradingfutures" }, + { "Kucoin.FuturesKey", "9e08c05f-454d-4580-82af-2f4c7027fd00" }, + { "Kucoin.SpotName", "Easytrading" }, + { "Kucoin.SpotKey", "f8ae62cb-2b3d-420c-8c98-e1c17dd4e30a" }, + { "Mexc", "EASYT" }, + { "OKX", "1425d83a94fbBCDE" }, + { "XT", "4XWeqN10M1fcoI5L" }, + }; + /// /// Apply broker id to a client order id /// @@ -47,6 +70,22 @@ namespace CryptoExchange.Net return clientOrderId; } + /// + /// Get the client reference for an exchange if available + /// + public static string GetClientReference(Func optionsReference, string exchange, string? topic = null) + { + var optionsValue = optionsReference(); + if (!string.IsNullOrEmpty(optionsValue)) + return optionsValue!; + + var key = exchange; + if (topic != null) + key += "." + topic; + + return _defaultClientReferences.TryGetValue(key, out var id) ? id : throw new KeyNotFoundException($"{exchange} not found in configuration"); + } + /// /// Create a new HttpMessageHandler instance ///