Skip to content

Commit 7f4f52a

Browse files
committed
Added GetSymbolName helper method on clients.
1 parent 33da8c3 commit 7f4f52a

File tree

5 files changed

+58
-0
lines changed

5 files changed

+58
-0
lines changed

CryptoClients.Net/CryptoClients.Net.xml

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

CryptoClients.Net/ExchangeRestClient.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -555,6 +555,16 @@ public void SetApiCredentials(string exchange, string apiKey, string apiSecret,
555555
}
556556
}
557557

558+
/// <inheritdoc />
559+
public string? GetSymbolName(string exchange, SharedSymbol symbol)
560+
{
561+
var client = _sharedClients.FirstOrDefault(x => x.Exchange == exchange && x.SupportedTradingModes.Contains(symbol.TradingMode));
562+
if (client == null)
563+
return null;
564+
565+
return symbol.GetSymbol(client.FormatSymbol);
566+
}
567+
558568
#region Get Spot Tickers
559569

560570
/// <inheritdoc />

CryptoClients.Net/ExchangeSocketClient.cs

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,16 @@ public void SetApiCredentials(string exchange, string apiKey, string apiSecret,
439439
}
440440
}
441441

442+
/// <inheritdoc />
443+
public string? GetSymbolName(string exchange, SharedSymbol symbol)
444+
{
445+
var client = _sharedClients.FirstOrDefault(x => x.Exchange == exchange && x.SupportedTradingModes.Contains(symbol.TradingMode));
446+
if (client == null)
447+
return null;
448+
449+
return symbol.GetSymbol(client.FormatSymbol);
450+
}
451+
442452
#region Subscribe All Ticker
443453

444454
/// <inheritdoc />

CryptoClients.Net/Interfaces/IExchangeRestClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -133,6 +133,14 @@ public interface IExchangeRestClient
133133
/// <param name="apiPass">API passphrase</param>
134134
void SetApiCredentials(string exchange, string apiKey, string apiSecret, string? apiPass = null);
135135

136+
/// <summary>
137+
/// Return the exchange symbol name
138+
/// </summary>
139+
/// <param name="exchange">Exchange</param>
140+
/// <param name="symbol">Symbol</param>
141+
/// <returns></returns>
142+
string? GetSymbolName(string exchange, SharedSymbol symbol);
143+
136144
/// <summary>
137145
/// Get the <see cref="IAssetsRestClient"/> clients for all exchanges
138146
/// </summary>

CryptoClients.Net/Interfaces/IExchangeSocketClient.cs

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -117,6 +117,14 @@ public interface IExchangeSocketClient
117117
/// <param name="apiPass">API passphrase</param>
118118
void SetApiCredentials(string exchange, string apiKey, string apiSecret, string? apiPass = null);
119119

120+
/// <summary>
121+
/// Return the exchange symbol name
122+
/// </summary>
123+
/// <param name="exchange">Exchange</param>
124+
/// <param name="symbol">Symbol</param>
125+
/// <returns></returns>
126+
string? GetSymbolName(string exchange, SharedSymbol symbol);
127+
120128
/// <summary>
121129
/// Get all ISharedClient Socket Api interfaces supported for the specified exchange
122130
/// </summary>

0 commit comments

Comments
 (0)