EmulatedPortfolio

StockSharp.MatchingEngine

Эмулируемая реализация портфеля, которая отслеживает позиции и деньги в памяти.

Конструкторы

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.

Свойства

AvailableMoney
public decimal AvailableMoney { get; }
value = emulatedPortfolio.AvailableMoney

Доступные деньги (текущие - заблокированы).

BeginMoney
public decimal BeginMoney { get; }
value = emulatedPortfolio.BeginMoney

Первоначальная сумма денег.

BlockedMoney
public decimal BlockedMoney { get; }
value = emulatedPortfolio.BlockedMoney

Заблокированы деньги для отложенных заказов.

Commission
public decimal Commission { get; }
value = emulatedPortfolio.Commission

Общая комиссия.

CurrentMoney
public decimal CurrentMoney { get; }
value = emulatedPortfolio.CurrentMoney

Текущие деньги (начните с + PnL).

EnableStopOut
public bool EnableStopOut { get; set; }
value = emulatedPortfolio.EnableStopOut
emulatedPortfolio.EnableStopOut = value

Включите автоматическую ликвидацию положения на остановке.

MarginCallLevel
public decimal MarginCallLevel { get; set; }
value = emulatedPortfolio.MarginCallLevel
emulatedPortfolio.MarginCallLevel = value

Когда уровень маржи падает до этого значения, срабатывает предупреждение.

Name
public string Name { get; }
value = emulatedPortfolio.Name

Имя.

RealizedPnL
public decimal RealizedPnL { get; }
value = emulatedPortfolio.RealizedPnL

Стоимость реализованной прибыли-убытка.

StopOutLevel
public decimal StopOutLevel { get; set; }
value = emulatedPortfolio.StopOutLevel
emulatedPortfolio.StopOutLevel = value

Порог уровня стоп-аута. Когда уровень маржи падает до этого значения, позиции ликвидируются.

TotalPnL
public decimal TotalPnL { get; }
value = emulatedPortfolio.TotalPnL

Total PnL (реализовано - комиссия).

UnrealizedPnL
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.

Version
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.

Методы

CalculateUnrealizedPnL
public decimal CalculateUnrealizedPnL(Func<SecurityId, decimal?> getCurrentPrice)
result = emulatedPortfolio.CalculateUnrealizedPnL(getCurrentPrice)

Рассчитайте нереализованную PnL по всем позициям.

getCurrentPrice
Функция получения текущей рыночной цены финансового инструмента. Возвращает ноль, если цена недоступна.

Возвращает: Всего нереализованных PnL.

Clear
internal void Clear()
emulatedPortfolio.Clear()

Очистить все состояние (используется при сбросе).

GetAllPositions
public IEnumerable<PositionInfo> GetAllPositions()
result = emulatedPortfolio.GetAllPositions()

Получить все объекты информации о позиции.

GetPosition
public PositionInfo GetPosition(SecurityId securityId)
result = emulatedPortfolio.GetPosition(securityId)

Получить позицию по финансовому инструменту.

securityId
идентификатор финансового инструмента.

Возвращает: Информация о позиции или ноль.

GetPositions
public IEnumerable<ValueTuple<SecurityId, decimal, decimal>> GetPositions()
result = emulatedPortfolio.GetPositions()

Получите все позиции.

Возвращает: Перечень должностей.

GetUnrealizedPnL
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.

GetUnrealizedPnL
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.

ProcessOrderCancellation
public void ProcessOrderCancellation(SecurityId securityId, Sides side, decimal volume, decimal price)
emulatedPortfolio.ProcessOrderCancellation(securityId, side, volume, price)

Обработать отмену заказа (разблокировать средства).

securityId
идентификатор финансового инструмента.
side
Сторона заказа.
volume
Отмененный том.
price
Цена, используемая для расчета маржи.
ProcessOrderRegistration
public void ProcessOrderRegistration(SecurityId securityId, Sides side, decimal volume, decimal price)
emulatedPortfolio.ProcessOrderRegistration(securityId, side, volume, price)

Оформить регистрацию заказа (блокировать средства).

securityId
идентификатор финансового инструмента.
side
Сторона заказа.
volume
Объем заказа.
price
Цена ордера для расчета маржи.
ProcessTrade
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.

SetMoney
public void SetMoney(decimal money)
emulatedPortfolio.SetMoney(money)

Установите первоначальные деньги.

money
Сумма денег.
SetPosition
public void SetPosition(SecurityId securityId, decimal volume, decimal avgPrice)
emulatedPortfolio.SetPosition(securityId, volume, avgPrice)

Установите исходное положение.

securityId
идентификатор финансового инструмента.
volume
Объем позиции.
avgPrice
Средняя цена входа.