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
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
Process(MyTrade)
Applies an own trade of the position.
bool Process(MyTrade trade)
Parameters
tradeMyTradeTrade 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
orderOrderOrder 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
avgPricedecimalNew 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
volumedecimal?Position volume in lots: positive for long, negative for short.
averagePricedecimal?Average entry price.
openedPnLdecimal?Open (unrealized) PnL in money.
closedPnLdecimal?Closed (realized) PnL in money.
commissiondecimal?Commission in money.
openVolumedecimal?Volume of the position at the start of the trading day, in lots.
riskRiskInfoRisk parameters of the position.
Returns
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
securitySecuritySecurity the price belongs to.
typeMarketDataTypePrice side: Bid is used for a long position, Ask for a short one.
pricedecimalBest price.
Returns
- bool
true when the open PnL changed.