MarginController
StockSharp.MatchingEngine
IMarginController 默认执行。 杠杆来自 Levarage (默认 1) 。 边缘呼叫/ 停止级别来自 IPortfolio 。
方法
CheckMarginLevel
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.
返回值: Margin level ratio (equity / blocked). Returns MaxValue if no blocked money.
GetRequiredMargin
public decimal GetRequiredMargin(decimal price, decimal volume, PositionInfo position)
result = marginController.GetRequiredMargin(price, volume, position)
使用职位级杠杆计算命令所需的比值。
- price
- 订价.
- volume
- 序卷出. 师曰.
- position
- 位置信息( 用于杠杆) 。 可无效( 使用默认杠杆 1)。
返回值: 所需差值。
IsMarginCall
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.
返回值: True if margin level is at or below margin call threshold.
IsStopOut
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.
返回值: True if stop-out is enabled and margin level is at or below stop-out threshold.
ValidateOrder
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.
返回值: Error if insufficient funds, null otherwise.