EmulatedPortfolioManager
StockSharp.MatchingEngine
Portfolio manager that creates emulated portfolios in-memory.
Implements: IMarkPrices
Properties
InitialMoney
public Func<string, decimal?> InitialMoney { get; set; }
value = emulatedPortfolioManager.InitialMoney
emulatedPortfolioManager.InitialMoney = value
The money an account holds when it is opened, by the account's name, or for an account that opens empty.
MarginController
public IMarginController MarginController { get; set; }
value = emulatedPortfolioManager.MarginController
emulatedPortfolioManager.MarginController = value
Margin controller for order validation.
MarkPrices
public IMarkPrices MarkPrices { get; set; }
value = emulatedPortfolioManager.MarkPrices
emulatedPortfolioManager.MarkPrices = value
Where the prices to revalue open positions come from. Until the engine supplies them every position is worth what it cost.
Methods
GetAllPortfolios
public IEnumerable<EmulatedPortfolio> GetAllPortfolios()
result = emulatedPortfolioManager.GetAllPortfolios()
Get all portfolios.
GetPortfolio
public EmulatedPortfolio GetPortfolio(string name)
result = emulatedPortfolioManager.GetPortfolio(name)
Get or create a portfolio by name.
- name
- Portfolio name.
Returns: Portfolio instance.
HasPortfolio
public bool HasPortfolio(string name)
result = emulatedPortfolioManager.HasPortfolio(name)
Check if portfolio exists.
- name
- Portfolio name.
Returns: True if exists.
TryGetPortfolio
public virtual bool TryGetPortfolio(string name, EmulatedPortfolio portfolio)
result = emulatedPortfolioManager.TryGetPortfolio(name, portfolio)
Look an account up without opening one, unlike String), which creates the account when the name is unknown.
- name
- Portfolio name.
- portfolio
- The account, or when no account carries that name.
Returns: when the account exists.
ValidateFunds
public InvalidOperationException ValidateFunds(string portfolioName, SecurityId securityId, decimal price, decimal volume)
result = emulatedPortfolioManager.ValidateFunds(portfolioName, securityId, price, volume)
Validate that portfolio has sufficient funds for order registration.
- portfolioName
- Portfolio name.
- securityId
- Security ID (for per-position leverage).
- price
- Order price.
- volume
- Order volume.
Returns: Error if insufficient funds, null otherwise.