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),
79 foreach (var market
in HardcodedMarkets)
81 Markets[market.Item1] = market.Item2;
82 ReverseMarkets[market.Item2] = market.Item1;
89 public const string USA =
"usa";
94 public const string Oanda =
"oanda";
99 public const string FXCM =
"fxcm";
116 public const string Globex =
"cmeglobex";
121 public const string NYMEX =
"nymex";
126 public const string CBOT =
"cbot";
131 public const string ICE =
"ice";
136 public const string CBOE =
"cboe";
141 public const string CFE =
"cfe";
146 public const string India =
"india";
151 public const string COMEX =
"comex";
156 public const string CME =
"cme";
161 public const string EUREX =
"eurex";
166 public const string SGX =
"sgx";
171 public const string HKFE =
"hkfe";
176 public const string OSE =
"ose";
186 [Obsolete(
"The GDAX constant is deprecated. Please use Coinbase instead.")]
237 public const string FTX =
"ftx";
242 public const string FTXUS =
"ftxus";
252 public const string Bybit =
"bybit";
269 public static void Add(
string market,
int identifier)
271 if (identifier >= MaxMarketIdentifier)
276 market = market.ToLowerInvariant();
278 int marketIdentifier;
279 if (Markets.TryGetValue(market, out marketIdentifier) && identifier != marketIdentifier)
284 string existingMarket;
285 if (ReverseMarkets.TryGetValue(identifier, out existingMarket))
292 var newMarketDictionary = Markets.ToDictionary(entry => entry.Key,
293 entry => entry.Value);
294 newMarketDictionary[market] = identifier;
296 var newReverseMarketDictionary = ReverseMarkets.ToDictionary(entry => entry.Key,
297 entry => entry.Value);
298 newReverseMarketDictionary[identifier] = market;
300 Markets = newMarketDictionary;
301 ReverseMarkets = newReverseMarketDictionary;
311 return !Markets.TryGetValue(market, out var code) ? null : code;
321 return !ReverseMarkets.TryGetValue(code, out var market) ? null : market;
329 return Markets.Keys.ToList();