Files
StockSharp/Fix.Core/MessageConverter.Position.cs
mika@stocksharp.com 26ef427982 Take the FIX record <-> message mapping into Fix.Core
IMessageConverter and MessageConverter map FIX record structs to StockSharp
messages and back. They referenced nothing but Fix.Core, yet lived in a project
named Server.Protocol, so anything consuming the mapping - including a client
codec - had to compile against a Server.* assembly.

They now sit in Fix.Core under namespace StockSharp.Fix, next to
FixOrderCondition and FixMessageTypes, which makes the wire tier
Fix.Core -> codec -> connector with no server assembly in the chain. Both types
become public API of the StockSharp.Fix.Core package.

Fix.Core gains the two aliases the mapping needs (FixExtensions, FixTimeInForce)
- inside StockSharp.Fix both Extensions and TimeInForce are ambiguous between
StockSharp.Messages and StockSharp.Fix.Native.

The 72 round-trip tests come along as Tests/MessageConverterTests*, and Tests
takes its first reference on Fix.Core. The mass-cancel scope test asserts tag
530 on the record the converter produces instead of calling the helper that
derives it, so GetMassCancelRequestType stays private and Fix.Core needs no
InternalsVisibleTo beyond the one Fix.Dialects already has.
2026-08-10 22:44:26 +03:00

63 lines
1.8 KiB
C#

namespace StockSharp.Fix;
/// <summary>
/// Position message converters: RequestForPositions.
/// </summary>
partial class MessageConverter
{
/// <inheritdoc />
public virtual PortfolioLookupMessage ToMessage(FixRequestForPositions fix)
{
var msg = new PortfolioLookupMessage
{
TransactionId = fix.PosReqId.ToLong(),
PortfolioName = fix.Account,
IsSubscribe = GetIsSubscribe(fix.SubscriptionRequestType),
IsIncremental = fix.IsIncremental ?? false,
UserId = fix.UserId,
};
// PortfolioMessage carries only ClientCode, so only PartyRole.ClientId is read.
if (fix.Parties != null)
{
foreach (var party in fix.Parties)
{
if (party is null)
continue;
switch (party.PartyRole)
{
case PartyRole.ClientId:
msg.ClientCode = party.PartyId;
break;
}
}
}
if (!fix.ResponseId.IsEmpty())
msg.OriginalTransactionId = fix.ResponseId.ToLong();
if (fix.SecurityIds != null && fix.SecurityIds.Length > 0)
msg.SecurityIds = fix.SecurityIds;
return msg;
}
/// <inheritdoc />
public virtual FixRequestForPositions ToFixRequestForPositions(PortfolioLookupMessage message)
{
return new FixRequestForPositions(
PosReqId: FixId.FromLong(message.TransactionId),
Account: message.PortfolioName,
SubscriptionRequestType: ToFixSubscriptionType(message.IsSubscribe),
ResponseId: message.OriginalTransactionId != 0 ? FixId.FromLong(message.OriginalTransactionId) : default,
Side: null,
IsIncremental: message.IsIncremental ? true : null,
UserId: message.UserId,
SecurityIds: message.SecurityIds,
// ClientCode travels in the Parties block under PartyRole.ClientId.
// PortfolioMessage carries no BrokerCode, hence the single-party array.
Parties: BuildParties(message.ClientCode, brokerCode: null));
}
}