17 using System.Collections.Generic;
38 public new static readonly IReadOnlyDictionary<SecurityType, string>
DefaultMarketMap =
new Dictionary<SecurityType, string>
49 }.ToReadOnlyDictionary();
51 private readonly Type[] _supportedTimeInForces =
58 private readonly HashSet<OrderType> _supportedOrderTypes =
new HashSet<OrderType>
122 return security.
Type ==
SecurityType.Cfd ? 10m : base.GetLeverage(security);
141 if (!_supportedOrderTypes.Contains(order.
Type))
151 "InteractiveBrokers does not support Market-on-Close orders for other security types different than Future and Equity.");
157 "InteractiveBrokers does not support Market-on-Open orders for other security types different than Option and Equity.");
186 if (!_supportedTimeInForces.Contains(order.
TimeInForce.GetType()))
222 return IsForexWithinOrderSizeLimits(order.
Symbol.
Value, request.
Quantity.Value, out message);
246 private bool IsForexWithinOrderSizeLimits(
string currencyPair, decimal quantity, out
BrokerageMessageEvent message)
279 ForexCurrencyLimits.TryGetValue(baseCurrency, out var limits);
280 var min = limits?.Item1 ?? 0m;
281 var max = limits?.Item2 ?? 0m;
283 var absoluteQuantity = Math.Abs(quantity);
284 var orderIsWithinForexSizeLimits = ((min == 0 && absoluteQuantity > min) || (min > 0 && absoluteQuantity >= min)) && absoluteQuantity <= max;
285 if (!orderIsWithinForexSizeLimits)
290 return orderIsWithinForexSizeLimits;
294 private static readonly IReadOnlyDictionary<string, Tuple<decimal, decimal>> ForexCurrencyLimits =
295 new Dictionary<string, Tuple<decimal, decimal>>()
297 {
"USD", Tuple.Create(25000m, 7000000m)},
298 {
"AUD", Tuple.Create(25000m, 6000000m)},
299 {
"CAD", Tuple.Create(25000m, 6000000m)},
300 {
"CHF", Tuple.Create(25000m, 6000000m)},
301 {
"CNH", Tuple.Create(150000m, 40000000m)},
302 {
"CZK", Tuple.Create(0m, 0m)},
303 {
"DKK", Tuple.Create(150000m, 35000000m)},
304 {
"EUR", Tuple.Create(20000m, 6000000m)},
305 {
"GBP", Tuple.Create(20000m, 5000000m)},
306 {
"HKD", Tuple.Create(200000m, 50000000m)},
307 {
"HUF", Tuple.Create(0m, 0m)},
308 {
"ILS", Tuple.Create(0m, 0m)},
309 {
"KRW", Tuple.Create(0m, 200000000m)},
310 {
"JPY", Tuple.Create(2500000m, 550000000m)},
311 {
"MXN", Tuple.Create(300000m, 70000000m)},
312 {
"NOK", Tuple.Create(150000m, 35000000m)},
313 {
"NZD", Tuple.Create(35000m, 8000000m)},
314 {
"PLN", Tuple.Create(0m, 0m)},
315 {
"RUB", Tuple.Create(750000m, 30000000m)},
316 {
"SEK", Tuple.Create(175000m, 40000000m)},
317 {
"SGD", Tuple.Create(35000m, 8000000m)},
318 {
"ZAR", Tuple.Create(350000m, 100000000m)}