Lean  $LEAN_TAG$
IBuyingPowerModel.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 
17 {
18  /// <summary>
19  /// Represents a security's model of buying power
20  /// </summary>
21  public interface IBuyingPowerModel
22  {
23  /// <summary>
24  /// Gets the current leverage of the security
25  /// </summary>
26  /// <param name="security">The security to get leverage for</param>
27  /// <returns>The current leverage in the security</returns>
28  decimal GetLeverage(Security security);
29 
30  /// <summary>
31  /// Sets the leverage for the applicable securities, i.e, equities
32  /// </summary>
33  /// <remarks>
34  /// This is added to maintain backwards compatibility with the old margin/leverage system
35  /// </remarks>
36  /// <param name="security">The security to set leverage for</param>
37  /// <param name="leverage">The new leverage</param>
38  void SetLeverage(Security security, decimal leverage);
39 
40  /// <summary>
41  /// Gets the margin currently allocated to the specified holding
42  /// </summary>
43  /// <param name="parameters">An object containing the security and holdings quantity/cost/value</param>
44  /// <returns>The maintenance margin required for the provided holdings quantity/cost/value</returns>
46 
47  /// <summary>
48  /// The margin that must be held in order to increase the position by the provided quantity
49  /// </summary>
50  /// <param name="parameters">An object containing the security and quantity</param>
51  /// <returns>The initial margin required for the provided security and quantity</returns>
53 
54  /// <summary>
55  /// Gets the total margin required to execute the specified order in units of the account currency including fees
56  /// </summary>
57  /// <param name="parameters">An object containing the portfolio, the security and the order</param>
58  /// <returns>The total margin in terms of the currency quoted in the order</returns>
60 
61  /// <summary>
62  /// Check if there is sufficient buying power to execute this order.
63  /// </summary>
64  /// <param name="parameters">An object containing the portfolio, the security and the order</param>
65  /// <returns>Returns buying power information for an order</returns>
67 
68  /// <summary>
69  /// Get the maximum market order quantity to obtain a position with a given buying power percentage.
70  /// Will not take into account free buying power.
71  /// </summary>
72  /// <param name="parameters">An object containing the portfolio, the security and the target signed buying power percentage</param>
73  /// <returns>Returns the maximum allowed market order quantity and if zero, also the reason</returns>
75 
76  /// <summary>
77  /// Get the maximum market order quantity to obtain a delta in the buying power used by a security.
78  /// The deltas sign defines the position side to apply it to, positive long, negative short.
79  /// </summary>
80  /// <param name="parameters">An object containing the portfolio, the security and the delta buying power</param>
81  /// <returns>Returns the maximum allowed market order quantity and if zero, also the reason</returns>
82  /// <remarks>Used by the margin call model to reduce the position by a delta percent.</remarks>
84 
85  /// <summary>
86  /// Gets the amount of buying power reserved to maintain the specified position
87  /// </summary>
88  /// <param name="parameters">A parameters object containing the security</param>
89  /// <returns>The reserved buying power in account currency</returns>
91 
92  /// <summary>
93  /// Gets the buying power available for a trade
94  /// </summary>
95  /// <param name="parameters">A parameters object containing the algorithm's portfolio, security, and order direction</param>
96  /// <returns>The buying power available for the trade</returns>
98  }
99 }