InMemoryPositionStorage

StockSharp.Algo.Storages

In memory implementation of IPositionStorage.

Implements: IPositionStorage, IPositionProvider, IPortfolioProvider

Constructors

InMemoryPositionStorage
public InMemoryPositionStorage()
inMemoryPositionStorage = InMemoryPositionStorage()

Initializes a new instance of the InMemoryPositionStorage.

InMemoryPositionStorage
public InMemoryPositionStorage(IPortfolioProvider underlying)
inMemoryPositionStorage = InMemoryPositionStorage(underlying)

Initializes a new instance of the InMemoryPositionStorage.

underlying
Underlying provider.

Properties

Portfolios
public IEnumerable<Portfolio> Portfolios { get; }
value = inMemoryPositionStorage.Portfolios

Get all portfolios.

Positions
public IEnumerable<Position> Positions { get; }
value = inMemoryPositionStorage.Positions

Get all positions.

Methods

Delete
public void Delete(Portfolio portfolio)
inMemoryPositionStorage.Delete(portfolio)

Delete portfolio.

portfolio
Portfolio.
Delete
public void Delete(Position position)
inMemoryPositionStorage.Delete(position)

Delete position.

position
Position.
EnterScope
public Scope EnterScope()
result = inMemoryPositionStorage.EnterScope()

Enter sync scope.

Returns: Sync scope.

GetPosition
public Position GetPosition(Portfolio portfolio, Security security, string strategyId, Sides? side, string clientCode, string depoName, TPlusLimits? limitType)
result = inMemoryPositionStorage.GetPosition(portfolio, security, strategyId, side, clientCode, depoName, limitType)

To get the position by portfolio and instrument.

portfolio
The portfolio on which the position should be found.
security
The instrument on which the position should be found.
strategyId
Strategy ID.
side
Side.
clientCode
The client code.
depoName
The depository name where the stock is located physically. By default, an empty string is passed, which means the total position by all depositories.
limitType
Limit type for Т+ market.

Returns: Position.

LookupByPortfolioName
public Portfolio LookupByPortfolioName(string name)
result = inMemoryPositionStorage.LookupByPortfolioName(name)

To get the portfolio by the code name.

name
Portfolio code name.

Returns: The got portfolio. If there is no portfolio by given criteria, is returned.

Save
public void Save(Portfolio portfolio)
inMemoryPositionStorage.Save(portfolio)

Save portfolio.

portfolio
Portfolio.
Save
public void Save(Position position)
inMemoryPositionStorage.Save(position)

Save position.

position
Position.

Events

NewPortfolio
public event Action<Portfolio> NewPortfolio
inMemoryPositionStorage.NewPortfolio += handler

New portfolio received.

NewPosition
public event Action<Position> NewPosition
inMemoryPositionStorage.NewPosition += handler

New position received.

PortfolioChanged
public event Action<Portfolio> PortfolioChanged
inMemoryPositionStorage.PortfolioChanged += handler

Portfolio changed.

PositionChanged
public event Action<Position> PositionChanged
inMemoryPositionStorage.PositionChanged += handler

Position changed.