IMarginController
Interface for controlling margin trading logic. Leverage is per-position (Leverage). Margin call/stop-out levels are per-portfolio (MarginCallLevel, StopOutLevel).
メソッド
CheckMarginLevel(IPortfolio, decimal) : decimal
Calculate current margin level for a portfolio.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
戻り値: Margin level ratio (equity / blocked). Returns MaxValue if no blocked money.
GetRequiredMargin(decimal, decimal, PositionInfo) : decimal
Calculate required margin for an order, using position-level leverage.
- price
- Order price.
- volume
- Order volume.
- position
- Position info (for leverage). Can be null (uses default leverage 1).
戻り値: Required margin amount.
IsMarginCall(IPortfolio, decimal) : bool
Check if portfolio is in margin call state. Uses MarginCallLevel.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
戻り値: True if margin level is at or below margin call threshold.
IsStopOut(IPortfolio, decimal) : bool
Check if portfolio is in stop-out state. Uses EnableStopOut and StopOutLevel.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
戻り値: True if stop-out is enabled and margin level is at or below stop-out threshold.
ValidateOrder(IPortfolio, decimal, decimal, PositionInfo) : InvalidOperationException
Validate that portfolio has sufficient funds for order.
- portfolio
- Portfolio to check.
- price
- Order price.
- volume
- Order volume.
- position
- Position info (for leverage). Can be null.
戻り値: Error if insufficient funds, null otherwise.