Files
StockSharp/MatchingEngine/TradeProcessingResult.cs
mika@stocksharp.com 1cb1c5487c Let the engine own its portfolio book
IPortfolio and IPortfolioManager had one implementation each, and substitution
through them did not work: the adapter narrowed the manager back to the concrete
type before wiring it, so a foreign one got neither a margin controller nor a price
source and could compute neither margin nor unrealized result. An interface that
cannot be implemented by anything else is a contract with itself.

The adapter now holds an EmulatedPortfolioManager it creates and never replaces,
wired in the constructor, and the narrowing step is gone with the interfaces.
PositionInfo and TradeProcessingResult, which shared the interfaces' file, get files
of their own; the documentation the interfaces carried moves onto the members that
implement it.

TryGetPortfolio is added beside GetPortfolio, which creates on a miss - so asking
whether the book holds an account was writing to it. A caller that wants to read an
account it may not have now has a lookup that answers without opening one.

One test comes with them. ValidateFunds answers "no objection" for an account the
book has never heard of, which reads like a hole: with the money check on, an order
naming an unknown account would be paid for by nobody. It is not one - the register
path opens the account before the funds check runs, so the check sees it holding zero
and refuses the order - and now something says so.
2026-08-24 02:37:31 +03:00

10 lines
394 B
C#

namespace StockSharp.MatchingEngine;
/// <summary>
/// Result of trade processing.
/// </summary>
/// <param name="RealizedPnL">Realized PnL from the trade.</param>
/// <param name="PositionChange">Position change amount.</param>
/// <param name="Position">Updated position info.</param>
public record TradeProcessingResult(decimal RealizedPnL, decimal PositionChange, PositionInfo Position);