EmulatedPortfolio
模拟投资组合的执行,跟踪职位和货币内幕。
构造函数
public EmulatedPortfolio(string name, IMarkPrices markPrices)
emulatedPortfolio = EmulatedPortfolio(name, markPrices)
Initializes a new instance.
- name
- Portfolio name.
- markPrices
- Where the prices to revalue open positions come from.
属性
public decimal AvailableMoney { get; }
value = emulatedPortfolio.AvailableMoney
可用资金(现款-被冻结).
public decimal CurrentMoney { get; }
value = emulatedPortfolio.CurrentMoney
现用货币(开始+PnL).
public bool EnableStopOut { get; set; }
value = emulatedPortfolio.EnableStopOut
emulatedPortfolio.EnableStopOut = value
停止时启用自动位置清算 。
public decimal MarginCallLevel { get; set; }
value = emulatedPortfolio.MarginCallLevel
emulatedPortfolio.MarginCallLevel = value
边际呼叫级别阈值。 当边际级别降入此值时, 将触发警告 。
public decimal StopOutLevel { get; set; }
value = emulatedPortfolio.StopOutLevel
emulatedPortfolio.StopOutLevel = value
停止关闭的临界值。当差值降至这一值时,将清理职位。
public decimal UnrealizedPnL { get; }
value = emulatedPortfolio.UnrealizedPnL
What the open positions have gained or lost since they were taken, at the prices they could be closed at now. A position the market has not priced counts for nothing.
public long Version { get; private set; }
value = emulatedPortfolio.Version
emulatedPortfolio.Version = value
Changes whenever an order, a fill or the opening state changes the account, so a report on it can be told from a newer one.
方法
public decimal CalculateUnrealizedPnL(Func<SecurityId, decimal?> getCurrentPrice)
result = emulatedPortfolio.CalculateUnrealizedPnL(getCurrentPrice)
计算所有职位未实现的PnL。
- getCurrentPrice
- 获取金融工具当前市场价格的功能。 如果价格无法使用, 则返回无效 。
返回值: Total unrealized PnL.
public IEnumerable<PositionInfo> GetAllPositions()
result = emulatedPortfolio.GetAllPositions()
获取所有位置信息对象 。
public PositionInfo GetPosition(SecurityId securityId)
result = emulatedPortfolio.GetPosition(securityId)
获得金融工具的地位。
- securityId
- 金融工具标识。
返回值: 位置信息或无效 。
public IEnumerable<ValueTuple<SecurityId, decimal, decimal>> GetPositions()
result = emulatedPortfolio.GetPositions()
都给我准备好
返回值: 数取所位.
public decimal? GetUnrealizedPnL(PositionInfo position)
result = emulatedPortfolio.GetUnrealizedPnL(position)
What one position has gained or lost since it was taken, at the price it could be closed at now.
- position
- A position of this portfolio.
返回值: The floating profit, zero for a flat position, or when the market has not priced an open one.
public decimal? GetUnrealizedPnL(SecurityId securityId)
result = emulatedPortfolio.GetUnrealizedPnL(securityId)
What one position has gained or lost since it was taken, at the price it could be closed at now.
- securityId
- Security ID.
返回值: The floating profit, zero for a flat position, or when the market has not priced an open one.
public void ProcessOrderCancellation(SecurityId securityId, Sides side, decimal volume, decimal price)
emulatedPortfolio.ProcessOrderCancellation(securityId, side, volume, price)
流程订单取消(解冻资金).
- securityId
- 金融工具标识。
- side
- 秩序一边.
- volume
- 已取消的音量 。
- price
- 用于比值计算的价格。
public void ProcessOrderRegistration(SecurityId securityId, Sides side, decimal volume, decimal price)
emulatedPortfolio.ProcessOrderRegistration(securityId, side, volume, price)
流程订单登记(区块基金)。
- securityId
- 金融工具标识。
- side
- 秩序一边.
- volume
- 序卷出. 师曰.
- price
- 差值计算定出价.
public TradeProcessingResult ProcessTrade(SecurityId securityId, Sides side, decimal price, decimal volume, decimal? commission, decimal? marginPrice)
result = emulatedPortfolio.ProcessTrade(securityId, side, price, volume, commission, marginPrice)
Process a trade execution.
- securityId
- Security ID.
- side
- Trade side.
- price
- Trade price.
- volume
- Trade volume.
- commission
- Commission amount.
- marginPrice
- Price at which the filled order reserved funds.
返回值: Trade processing result.
public void SetPosition(SecurityId securityId, decimal volume, decimal avgPrice)
emulatedPortfolio.SetPosition(securityId, volume, avgPrice)
设起起起入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入入..
- securityId
- 金融工具标识。
- volume
- 位置音量.
- avgPrice
- 入场价格平均.