Lean  $LEAN_TAG$
BinanceFuturesFeeModel.cs
1 /*
2 * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3 * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License");
6 * you may not use this file except in compliance with the License.
7 * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8 *
9 * Unless required by applicable law or agreed to in writing, software
10 * distributed under the License is distributed on an "AS IS" BASIS,
11 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12 * See the License for the specific language governing permissions and
13 * limitations under the License.
14 */
15 
16 using QuantConnect.Util;
17 
19 {
20  /// <summary>
21  /// Provides an implementation of <see cref="FeeModel"/> that models Binance Futures order fees
22  /// </summary>
24  {
25  /// <summary>
26  /// Tier 1 USDT maker fees
27  /// https://www.binance.com/en/fee/futureFee
28  /// </summary>
29  public const decimal MakerTier1USDTFee = 0.0002m;
30 
31  /// <summary>
32  /// Tier 1 USDT taker fees
33  /// https://www.binance.com/en/fee/futureFee
34  /// </summary>
35  public const decimal TakerTier1USDTFee = 0.0004m;
36 
37  /// <summary>
38  /// Tier 1 BUSD maker fees
39  /// https://www.binance.com/en/fee/futureFee
40  /// </summary>
41  public const decimal MakerTier1BUSDFee = 0.00012m;
42 
43  /// <summary>
44  /// Tier 1 BUSD taker fees
45  /// https://www.binance.com/en/fee/futureFee
46  /// </summary>
47  public const decimal TakerTier1BUSDFee = 0.00036m;
48 
49  private decimal _makerUsdtFee;
50  private decimal _takerUsdtFee;
51  private decimal _makerBusdFee;
52  private decimal _takerBusdFee;
53 
54  /// <summary>
55  /// Creates Binance Futures fee model setting fees values
56  /// </summary>
57  /// <param name="mUsdtFee">Maker fee value for USDT pair contracts</param>
58  /// <param name="tUsdtFee">Taker fee value for USDT pair contracts</param>
59  /// <param name="mBusdFee">Maker fee value for BUSD pair contracts</param>
60  /// <param name="tBusdFee">Taker fee value for BUSD pair contracts</param>
61  public BinanceFuturesFeeModel(decimal mUsdtFee = MakerTier1USDTFee, decimal tUsdtFee = TakerTier1USDTFee,
62  decimal mBusdFee = MakerTier1BUSDFee, decimal tBusdFee = TakerTier1BUSDFee)
63  : base(-1, -1)
64  {
65  _makerUsdtFee = mUsdtFee;
66  _takerUsdtFee = tUsdtFee;
67  _makerBusdFee = mBusdFee;
68  _takerBusdFee = tBusdFee;
69  }
70 
71  /// <summary>
72  /// Gets the fee for the given order
73  /// </summary>
74  protected override decimal GetFee(Order order)
75  {
76  CurrencyPairUtil.DecomposeCurrencyPair(order.Symbol, out var _, out var quoteCurrency);
77  var makerFee = _makerUsdtFee;
78  var takerFee = _takerUsdtFee;
79  if (quoteCurrency == "BUSD")
80  {
81  makerFee = _makerBusdFee;
82  takerFee = _takerBusdFee;
83  }
84 
85  return GetFee(order, makerFee, takerFee);
86  }
87  }
88 }