StrategyPositionManager
Manages strategy positions (per Security + Portfolio) and calculates position quantity, average price, realized PnL and commission incrementally from order executions. Additionally maintains cached per-position aggregates (blocked volume and active buy/sell orders count) via incremental updates (O(1) per order update, no rescans).
Konstruktoren
StrategyPositionManager(Func<string>)
Manages strategy positions (per Security + Portfolio) and calculates position quantity, average price, realized PnL and commission incrementally from order executions. Additionally maintains cached per-position aggregates (blocked volume and active buy/sell orders count) via incremental updates (O(1) per order update, no rescans).
- strategyIdGetter
- Delegate returning strategy identifier to stamp into newly created StrategyId.
Eigenschaften
StrategyIdGetter : Func<string>
Delegate returning strategy id to assign into new positions.
Methoden
ProcessOrder(Order) : OrderResults
Process order state change (registration, balance change, partial/full execution, cancellation, done).
- order
- Order to process.
Rückgabe: OrderResults
Reset()
Reset all internal caches (positions, execution info, aggregates, order tracks).
SetPosition(Security, Portfolio, decimal, DateTime)
Set current position value explicitly (utility for manual restoration / overrides).
- security
- Security.
- portfolio
- Portfolio.
- value
- New signed quantity.
- time
- Timestamp to assign into LocalTime and ServerTime if position is created anew.
TryGetPosition(Security, Portfolio) : Position
Try get existing position instance for and .
- security
- Security.
- portfolio
- Portfolio.
Rückgabe: Existing Position or .
UpdateAggregates(Order, Position)
Incrementally update aggregates for the order (blocked volume and counts) and push them into the .
UpdateCurrentPrice(SecurityId, decimal, DateTime, DateTime)
Update current (market) price for all positions of the specified .
- secId
- Security identifier whose positions need price update.
- price
- New market price.
- serverTime
- Server time of the price snapshot.
- localTime
- Local time when the price was processed.
Ereignisse
PositionProcessed : Action<Position, bool>
Occurs after position was processed (created or updated by an order execution or order state change affecting aggregates).