MarginController
Standardimplementierung von IMarginController. Leverage wird von Leverage übernommen (Standard 1). Margin Call / Stop-Out Levels werden von IPortfolio übernommen.
Implementiert: IMarginController
Methoden
public decimal CheckMarginLevel(EmulatedPortfolio portfolio, decimal unrealizedPnL)
result = marginController.CheckMarginLevel(portfolio, unrealizedPnL)
Calculate current margin level for a portfolio.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
Rückgabe: Margin level ratio (equity / blocked). Returns MaxValue if no blocked money.
public decimal GetRequiredMargin(decimal price, decimal volume, PositionInfo position)
result = marginController.GetRequiredMargin(price, volume, position)
Berechnen Sie die erforderliche Margin für einen Auftrag unter Verwendung von Positionshebel.
- price
- Bestellpreis.
- volume
- Auftragsvolumen.
- position
- Positionsinformationen (für Hebelwirkung) können null sein (verwendet Standardhebelwirkung 1).
Rückgabe: Erforderlicher Margin-Betrag.
public bool IsMarginCall(EmulatedPortfolio portfolio, decimal unrealizedPnL)
result = marginController.IsMarginCall(portfolio, unrealizedPnL)
Check if portfolio is in margin call state. Uses MarginCallLevel.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
Rückgabe: True if margin level is at or below margin call threshold.
public bool IsStopOut(EmulatedPortfolio portfolio, decimal unrealizedPnL)
result = marginController.IsStopOut(portfolio, unrealizedPnL)
Check if portfolio is in stop-out state. Uses EnableStopOut and StopOutLevel.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
Rückgabe: True if stop-out is enabled and margin level is at or below stop-out threshold.
public InvalidOperationException ValidateOrder(EmulatedPortfolio portfolio, decimal price, decimal volume, PositionInfo position)
result = marginController.ValidateOrder(portfolio, price, volume, position)
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.
Rückgabe: Error if insufficient funds, null otherwise.