18 using System.Collections.Generic;
28 private const int MaxMarketIdentifier = 1000;
30 private static Dictionary<string, int> Markets =
new Dictionary<string, int>();
31 private static Dictionary<int, string> ReverseMarkets =
new Dictionary<int, string>();
32 private static readonly IEnumerable<Tuple<string, int>> HardcodedMarkets =
new List<Tuple<string, int>>
34 Tuple.Create(
"empty", 0),
36 Tuple.Create(
FXCM, 2),
37 Tuple.Create(
Oanda, 3),
42 Tuple.Create(
NYMEX, 7),
43 Tuple.Create(
CBOT, 8),
45 Tuple.Create(
CBOE, 10),
46 Tuple.Create(
India, 11),
48 Tuple.Create(
GDAX, 12),
59 Tuple.Create(
COMEX, 22),
60 Tuple.Create(
CME, 23),
61 Tuple.Create(
SGX, 24),
62 Tuple.Create(
HKFE, 25),
65 Tuple.Create(
CFE, 33),
66 Tuple.Create(
FTX, 34),
67 Tuple.Create(
FTXUS, 35),
69 Tuple.Create(
Bybit, 37),
72 Tuple.Create(
EUREX, 40)
78 foreach (var market
in HardcodedMarkets)
80 Markets[market.Item1] = market.Item2;
81 ReverseMarkets[market.Item2] = market.Item1;
88 public const string USA =
"usa";
93 public const string Oanda =
"oanda";
98 public const string FXCM =
"fxcm";
115 public const string Globex =
"cmeglobex";
120 public const string NYMEX =
"nymex";
125 public const string CBOT =
"cbot";
130 public const string ICE =
"ice";
135 public const string CBOE =
"cboe";
140 public const string CFE =
"cfe";
145 public const string India =
"india";
150 public const string COMEX =
"comex";
155 public const string CME =
"cme";
160 public const string EUREX =
"eurex";
165 public const string SGX =
"sgx";
170 public const string HKFE =
"hkfe";
180 [Obsolete(
"The GDAX constant is deprecated. Please use Coinbase instead.")]
231 public const string FTX =
"ftx";
236 public const string FTXUS =
"ftxus";
246 public const string Bybit =
"bybit";
263 public static void Add(
string market,
int identifier)
265 if (identifier >= MaxMarketIdentifier)
270 market = market.ToLowerInvariant();
272 int marketIdentifier;
273 if (Markets.TryGetValue(market, out marketIdentifier) && identifier != marketIdentifier)
278 string existingMarket;
279 if (ReverseMarkets.TryGetValue(identifier, out existingMarket))
286 var newMarketDictionary = Markets.ToDictionary(entry => entry.Key,
287 entry => entry.Value);
288 newMarketDictionary[market] = identifier;
290 var newReverseMarketDictionary = ReverseMarkets.ToDictionary(entry => entry.Key,
291 entry => entry.Value);
292 newReverseMarketDictionary[identifier] = market;
294 Markets = newMarketDictionary;
295 ReverseMarkets = newReverseMarketDictionary;
305 return !Markets.TryGetValue(market, out var code) ? null : code;
315 return !ReverseMarkets.TryGetValue(code, out var market) ? null : market;
323 return Markets.Keys.ToList();