IMarginController
Интерфейс для управления логикой маржинальной торговли. Кредитное плечо рассчитывается по позициям (кредитное плечо). Уровни маржинального колл/стоп-аута указаны для каждого портфеля (MarginCallLevel, StopOutLevel).
Методы
public decimal CheckMarginLevel(EmulatedPortfolio portfolio, decimal unrealizedPnL)
result = iMarginController.CheckMarginLevel(portfolio, unrealizedPnL)
Calculate current margin level for a portfolio.
- portfolio
- Portfolio.
- unrealizedPnL
- Current unrealized PnL.
Возвращает: Margin level ratio (equity / blocked). Returns MaxValue if no blocked money.
public decimal GetRequiredMargin(decimal price, decimal volume, PositionInfo position)
result = iMarginController.GetRequiredMargin(price, volume, position)
Рассчитайте необходимую маржу для ордера, используя кредитное плечо на уровне позиции.
- price
- Цена заказа.
- volume
- Объем заказа.
- position
- Информация о позиции (для кредитного плеча). Может быть нулевым (используется кредитное плечо по умолчанию 1).
Возвращает: Требуемая сумма маржи.
public bool IsMarginCall(EmulatedPortfolio portfolio, decimal unrealizedPnL)
result = iMarginController.IsMarginCall(portfolio, unrealizedPnL)
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.
public bool IsStopOut(EmulatedPortfolio portfolio, decimal unrealizedPnL)
result = iMarginController.IsStopOut(portfolio, unrealizedPnL)
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.
public InvalidOperationException ValidateOrder(EmulatedPortfolio portfolio, decimal price, decimal volume, PositionInfo position)
result = iMarginController.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.
Возвращает: Error if insufficient funds, null otherwise.