Table of Contents

Interface ISecurityPositionManager

Namespace
ATAS.DataFeedsCore
Assembly
ATAS.DataFeedsCore.dll

Maintains one Position of a connector: applies position values received from the server, own trades and market prices, and reports whether the position changed.

public interface ISecurityPositionManager
Extension Methods

Properties

IsPositionInitialized

true after the first Update(decimal?, decimal?, decimal?, decimal?, decimal?, decimal?, RiskInfo?) call; trades can be processed only after that.

bool IsPositionInitialized { get; }

Property Value

bool

Position

The position maintained by the manager.

Position Position { get; }

Property Value

Position

Methods

Clear()

Resets the locally calculated position values and the accumulated trades.

void Clear()

GetIsChanged()

Checks whether the average price or volume changed since the previous call and remembers the current values.

bool GetIsChanged()

Returns

bool

true when the average price or volume differs from the previous call.

GetIsNeedSubscribeLevel1()

Checks whether the connector should subscribe to best prices of the position security to calculate open PnL.

bool GetIsNeedSubscribeLevel1()

Returns

bool

true once, the first time a subscription is needed; false afterwards.

Process(MyTrade)

Applies an own trade of the position.

bool Process(MyTrade trade)

Parameters

trade MyTrade

Trade of the position security and portfolio.

Returns

bool

true when the position changed.

Process(Order)

Applies an order of the position.

bool Process(Order order)

Parameters

order Order

Order of the position security and portfolio.

Returns

bool

true when the position changed.

SetAveragePrice(decimal)

Sets the average price of the position manually.

void SetAveragePrice(decimal avgPrice)

Parameters

avgPrice decimal

New average price.

Update(decimal?, decimal?, decimal?, decimal?, decimal?, decimal?, RiskInfo?)

Applies position values received from the server; a null argument means the value was not received.

bool Update(decimal? volume = null, decimal? averagePrice = null, decimal? openedPnL = null, decimal? closedPnL = null, decimal? commission = null, decimal? openVolume = null, RiskInfo? risk = null)

Parameters

volume decimal?

Position volume in lots: positive for long, negative for short.

averagePrice decimal?

Average entry price.

openedPnL decimal?

Open (unrealized) PnL in money.

closedPnL decimal?

Closed (realized) PnL in money.

commission decimal?

Commission in money.

openVolume decimal?

Volume of the position at the start of the trading day, in lots.

risk RiskInfo

Risk parameters of the position.

Returns

bool

true when the position changed; always true for the first call.

UpdateAveragePriceByTrades()

Recalculates the average price from the accumulated trades.

bool UpdateAveragePriceByTrades()

Returns

bool

true when the average price or its AveragePriceValueType changed.

UpdateOpenPnL(Security, MarketDataType, decimal)

Recalculates the open PnL from a new best price of the position security.

bool UpdateOpenPnL(Security security, MarketDataType type, decimal price)

Parameters

security Security

Security the price belongs to.

type MarketDataType

Price side: Bid is used for a long position, Ask for a short one.

price decimal

Best price.

Returns

bool

true when the open PnL changed.