Lean  $LEAN_TAG$
BinanceFuturesBrokerageModel.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 System;
21 
23 {
24  /// <summary>
25  /// Provides Binance Futures specific properties
26  /// </summary>
28  {
29  /// <summary>
30  /// Creates a new instance
31  /// </summary>
32  public BinanceFuturesBrokerageModel(AccountType accountType) : base(accountType)
33  {
34  if (accountType == AccountType.Cash)
35  {
36  throw new InvalidOperationException($"{SecurityType.CryptoFuture} can only be traded using a {AccountType.Margin} account type");
37  }
38  }
39 
40  /// <summary>
41  /// Get the benchmark for this model
42  /// </summary>
43  /// <param name="securities">SecurityService to create the security with if needed</param>
44  /// <returns>The benchmark for this brokerage</returns>
45  public override IBenchmark GetBenchmark(SecurityManager securities)
46  {
47  var symbol = Symbol.Create("BTCUSDT", SecurityType.CryptoFuture, MarketName);
48  return SecurityBenchmark.CreateInstance(securities, symbol);
49  }
50 
51  /// <summary>
52  /// Provides Binance Futures fee model
53  /// </summary>
54  /// <param name="security">The security to get a fee model for</param>
55  /// <returns>The new fee model for this brokerage</returns>
56  public override IFeeModel GetFeeModel(Security security)
57  {
58  return new BinanceFuturesFeeModel();
59  }
60 
61  /// <summary>
62  /// Gets a new margin interest rate model for the security
63  /// </summary>
64  /// <param name="security">The security to get a margin interest rate model for</param>
65  /// <returns>The margin interest rate model for this brokerage</returns>
67  {
68  // only applies for perpetual futures
69  if (security.Symbol.SecurityType == SecurityType.CryptoFuture && security.Symbol.ID.Date == SecurityIdentifier.DefaultDate)
70  {
72  }
73  return base.GetMarginInterestRateModel(security);
74  }
75  }
76 }