Lean
$LEAN_TAG$
IPositionGroupBuyingPowerModel.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;
17
18
namespace
QuantConnect.Securities.Positions
19
{
20
/// <summary>
21
/// Represents a position group's model of buying power
22
/// </summary>
23
public
interface
IPositionGroupBuyingPowerModel
: IEquatable<IPositionGroupBuyingPowerModel>
24
{
25
/// <summary>
26
/// Gets the margin currently allocated to the specified holding
27
/// </summary>
28
/// <param name="parameters">An object containing the security</param>
29
/// <returns>The maintenance margin required for the </returns>
30
MaintenanceMargin
GetMaintenanceMargin
(
PositionGroupMaintenanceMarginParameters
parameters);
31
32
/// <summary>
33
/// The margin that must be held in order to increase the position by the provided quantity
34
/// </summary>
35
/// <param name="parameters">An object containing the security and quantity</param>
36
InitialMargin
GetInitialMarginRequirement
(
PositionGroupInitialMarginParameters
parameters);
37
38
/// <summary>
39
/// Gets the total margin required to execute the specified order in units of the account currency including fees
40
/// </summary>
41
/// <param name="parameters">An object containing the portfolio, the security and the order</param>
42
/// <returns>The total margin in terms of the currency quoted in the order</returns>
43
InitialMargin
GetInitialMarginRequiredForOrder
(
PositionGroupInitialMarginForOrderParameters
parameters);
44
45
/// <summary>
46
/// Computes the impact on the portfolio's buying power from adding the position group to the portfolio. This is
47
/// a 'what if' analysis to determine what the state of the portfolio would be if these changes were applied. The
48
/// delta (before - after) is the margin requirement for adding the positions and if the margin used after the changes
49
/// are applied is less than the total portfolio value, this indicates sufficient capital.
50
/// </summary>
51
/// <param name="parameters">An object containing the portfolio and a position group containing the contemplated
52
/// changes to the portfolio</param>
53
/// <returns>Returns the portfolio's total portfolio value and margin used before and after the position changes are applied</returns>
54
ReservedBuyingPowerImpact
GetReservedBuyingPowerImpact
(
55
ReservedBuyingPowerImpactParameters
parameters
56
);
57
58
/// <summary>
59
/// Check if there is sufficient buying power for the position group to execute this order.
60
/// </summary>
61
/// <param name="parameters">An object containing the portfolio, the position group and the order</param>
62
/// <returns>Returns buying power information for an order against a position group</returns>
63
HasSufficientBuyingPowerForOrderResult
HasSufficientBuyingPowerForOrder
(
64
HasSufficientPositionGroupBuyingPowerForOrderParameters
parameters
65
);
66
67
/// <summary>
68
/// Computes the amount of buying power reserved by the provided position group
69
/// </summary>
70
ReservedBuyingPowerForPositionGroup
GetReservedBuyingPowerForPositionGroup
(
71
ReservedBuyingPowerForPositionGroupParameters
parameters
72
);
73
74
/// <summary>
75
/// Get the maximum position group order quantity to obtain a position with a given buying power
76
/// percentage. Will not take into account free buying power.
77
/// </summary>
78
/// <param name="parameters">An object containing the portfolio, the position group and the target
79
/// signed buying power percentage</param>
80
/// <returns>Returns the maximum allowed market order quantity and if zero, also the reason</returns>
81
GetMaximumLotsResult
GetMaximumLotsForTargetBuyingPower
(
82
GetMaximumLotsForTargetBuyingPowerParameters
parameters
83
);
84
85
/// <summary>
86
/// Get the maximum market position group order quantity to obtain a delta in the buying power used by a position group.
87
/// The deltas sign defines the position side to apply it to, positive long, negative short.
88
/// </summary>
89
/// <param name="parameters">An object containing the portfolio, the position group and the delta buying power</param>
90
/// <returns>Returns the maximum allowed market order quantity and if zero, also the reason</returns>
91
/// <remarks>Used by the margin call model to reduce the position by a delta percent.</remarks>
92
GetMaximumLotsResult
GetMaximumLotsForDeltaBuyingPower
(
93
GetMaximumLotsForDeltaBuyingPowerParameters
parameters
94
);
95
96
/// <summary>
97
/// Gets the buying power available for a position group trade
98
/// </summary>
99
/// <param name="parameters">A parameters object containing the algorithm's portfolio, security, and order direction</param>
100
/// <returns>The buying power available for the trade</returns>
101
PositionGroupBuyingPower
GetPositionGroupBuyingPower
(
PositionGroupBuyingPowerParameters
parameters);
102
}
103
}
Common
Securities
Positions
IPositionGroupBuyingPowerModel.cs
Generated by
1.8.17