30 new Lazy<SymbolPropertiesDatabase>(Securities.SymbolPropertiesDatabase.FromDataFolder);
32 private static readonly
int[][] PotentialStableCoins = { [1, 3], [1, 2], [0, 3], [0, 2] };
46 if (!IsValidSecurityType(currencyPair?.
SecurityType, throwException:
false))
73 IsValidSecurityType(currencyPair?.
SecurityType, throwException:
true);
86 defaultQuoteCurrency);
105 return !
string.IsNullOrEmpty(currencyPair) && currencyPair.Length == 6;
115 if (currencyPair ==
null)
122 return currencyPair.
Value.Length == 6;
133 return currencyPair.
Value.EndsWith(symbolProperties.QuoteCurrency);
148 string quoteCurrency;
162 public static string CurrencyPairDual(
string baseCurrency,
string quoteCurrency,
string knownSymbol)
164 if (baseCurrency == knownSymbol)
166 return quoteCurrency;
169 if (quoteCurrency == knownSymbol)
209 return Match.NoMatch;
213 var currencies =
new string[] { baseCurrencyA, quoteCurrencyA, baseCurrencyB, quoteCurrencyB };
214 var isThereAnyMatch =
false;
217 foreach (var pair
in PotentialStableCoins)
224 currencies[pair[0]] = currencies[pair[1]];
225 isThereAnyMatch =
true;
229 string pairAValue = isThereAnyMatch ?
string.Concat(currencies[0],
"||", currencies[1]) :
string.Concat(baseCurrencyA,
"||", quoteCurrencyA);
231 var directPair =
string.Concat(baseCurrencyB,
"||", quoteCurrencyB);
232 if (pairAValue == directPair)
234 return Match.ExactMatch;
237 var inversePair =
string.Concat(quoteCurrencyB,
"||", baseCurrencyB);
238 if (pairAValue == inversePair)
240 return Match.InverseMatch;
243 return Match.NoMatch;
246 public static bool IsValidSecurityType(
SecurityType? securityType,
bool throwException)
248 if (securityType ==
null)
252 throw new ArgumentException(
"Currency pair must not be null");
264 throw new ArgumentException($
"Unsupported security type: {securityType}");