mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-04 00:21:31 +00:00
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.
58 lines
1.3 KiB
C#
58 lines
1.3 KiB
C#
namespace StockSharp.MatchingEngine;
|
|
|
|
/// <summary>
|
|
/// Position information for a security.
|
|
/// </summary>
|
|
public class PositionInfo(SecurityId securityId)
|
|
{
|
|
/// <summary>
|
|
/// Security ID.
|
|
/// </summary>
|
|
public SecurityId SecurityId { get; } = securityId;
|
|
|
|
/// <summary>
|
|
/// Begin value (initial position).
|
|
/// </summary>
|
|
public decimal BeginValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// Position change since begin.
|
|
/// </summary>
|
|
public decimal Diff { get; set; }
|
|
|
|
/// <summary>
|
|
/// Current position value.
|
|
/// </summary>
|
|
public decimal CurrentValue => BeginValue + Diff;
|
|
|
|
/// <summary>
|
|
/// Average entry price.
|
|
/// </summary>
|
|
public decimal AveragePrice { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total volume of active buy orders.
|
|
/// </summary>
|
|
public decimal TotalBidsVolume { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total volume of active sell orders.
|
|
/// </summary>
|
|
public decimal TotalAsksVolume { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total value of active buy orders (volume * price).
|
|
/// </summary>
|
|
public decimal TotalBidsValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// Total value of active sell orders (volume * price).
|
|
/// </summary>
|
|
public decimal TotalAsksValue { get; set; }
|
|
|
|
/// <summary>
|
|
/// Margin leverage for this position. Null means default (1x).
|
|
/// </summary>
|
|
public decimal? Leverage { get; set; }
|
|
}
|