17 using System.Collections.Generic;
27 private readonly Dictionary<string, EquityFee> _equityFee =
28 new Dictionary<string, EquityFee> {
29 {
Market.
USA,
new EquityFee(
"USD", feePerShare: 0.005m, minimumFee: 1, maximumFeeRate: 0.005m) }
32 private readonly IDictionary<SecurityType, decimal> _feeRates =
new Dictionary<SecurityType, decimal>
43 private const decimal _makerFee = 0.001m;
44 private const decimal _takerFee = 0.002m;
55 var order = parameters.
Order;
59 if (order.Type ==
OrderType.OptionExercise)
64 var market = security.Symbol.ID.Market;
67 switch (security.Type)
73 _feeRates.TryGetValue(security.Type, out feeRate);
77 _feeRates.TryGetValue(security.Type, out feeRate);
81 decimal fee = _takerFee;
85 props?.Hidden !=
true &&
86 (props?.PostOnly ==
true || !order.IsMarketable))
93 var unitPrice = order.Direction ==
OrderDirection.Buy ? security.AskPrice : security.BidPrice;
100 unitPrice *= security.SymbolProperties.ContractMultiplier;
104 unitPrice * order.AbsoluteQuantity * fee,
105 security.QuoteCurrency.Symbol));
110 if (!_equityFee.TryGetValue(market, out equityFee))
114 var tradeValue = Math.Abs(order.GetValue(security));
117 var tradeFee = equityFee.FeePerShare * order.AbsoluteQuantity;
121 var maximumPerOrder = equityFee.MaximumFeeRate * tradeValue;
122 if (tradeFee < equityFee.MinimumFee)
124 tradeFee = equityFee.MinimumFee;
126 else if (tradeFee > maximumPerOrder)
128 tradeFee = maximumPerOrder;
142 private class EquityFee
144 public string Currency {
get; }
145 public decimal FeePerShare {
get; }
146 public decimal MinimumFee {
get; }
147 public decimal MaximumFeeRate {
get; }
149 public EquityFee(
string currency,
152 decimal maximumFeeRate)
155 FeePerShare = feePerShare;
156 MinimumFee = minimumFee;
157 MaximumFeeRate = maximumFeeRate;