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),
77 foreach (var market
in HardcodedMarkets)
79 Markets[market.Item1] = market.Item2;
80 ReverseMarkets[market.Item2] = market.Item1;
87 public const string USA =
"usa";
92 public const string Oanda =
"oanda";
97 public const string FXCM =
"fxcm";
114 public const string Globex =
"cmeglobex";
119 public const string NYMEX =
"nymex";
124 public const string CBOT =
"cbot";
129 public const string ICE =
"ice";
134 public const string CBOE =
"cboe";
139 public const string CFE =
"cfe";
144 public const string India =
"india";
149 public const string COMEX =
"comex";
154 public const string CME =
"cme";
159 public const string SGX =
"sgx";
164 public const string HKFE =
"hkfe";
174 [Obsolete(
"The GDAX constant is deprecated. Please use Coinbase instead.")]
225 public const string FTX =
"ftx";
230 public const string FTXUS =
"ftxus";
240 public const string Bybit =
"bybit";
257 public static void Add(
string market,
int identifier)
259 if (identifier >= MaxMarketIdentifier)
261 throw new ArgumentOutOfRangeException(nameof(identifier),
Messages.
Market.InvalidMarketIdentifier(MaxMarketIdentifier));
264 market = market.ToLowerInvariant();
266 int marketIdentifier;
267 if (Markets.TryGetValue(market, out marketIdentifier) && identifier != marketIdentifier)
269 throw new ArgumentException(
Messages.
Market.TriedToAddExistingMarketWithDifferentIdentifier(market));
272 string existingMarket;
273 if (ReverseMarkets.TryGetValue(identifier, out existingMarket))
275 throw new ArgumentException(
Messages.
Market.TriedToAddExistingMarketIdentifier(market, existingMarket));
280 var newMarketDictionary = Markets.ToDictionary(entry => entry.Key,
281 entry => entry.Value);
282 newMarketDictionary[market] = identifier;
284 var newReverseMarketDictionary = ReverseMarkets.ToDictionary(entry => entry.Key,
285 entry => entry.Value);
286 newReverseMarketDictionary[identifier] = market;
288 Markets = newMarketDictionary;
289 ReverseMarkets = newReverseMarketDictionary;
299 return !Markets.TryGetValue(market, out var code) ? null : code;
309 return !ReverseMarkets.TryGetValue(code, out var market) ? null : market;
317 return Markets.Keys.ToList();