Files
StockSharp/Fix.Core/MessageConverter.MarketData.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

49 lines
1.3 KiB
C#

namespace StockSharp.Fix;
partial class MessageConverter
{
/// <inheritdoc />
public IEnumerable<MarketDataMessage> ToMessages(FixMarketDataRequest fix)
=> fix.ToMessages();
/// <inheritdoc />
public FixMarketDataRequest ToFixMarketDataRequest(MarketDataMessage message, FixId mdReqId, FixId mdResponseId)
{
char[] mdEntryTypes;
string[] mdEntryArgs;
if (message.DataType2 == DataType.MarketDepth)
{
mdEntryTypes = [MDEntryType.Bid, MDEntryType.Offer];
mdEntryArgs = [null, null];
}
else
{
mdEntryTypes = [message.DataType2.ToFixMDType(out var arg)];
mdEntryArgs = [arg];
}
return new FixMarketDataRequest(
mdReqId,
mdResponseId,
message.GetSubscriptionType(),
mdEntryTypes,
mdEntryArgs,
message.SecurityId == default ? null : [message.SecurityId],
message.SecurityType == null ? null : [message.SecurityType.Value.ToFix()],
message.MaxDepth,
message.From,
message.To,
message.AllowBuildFromSmallerTimeFrame ? true : null,
message.IsCalcVolumeProfile ? true : null,
message.IsFinishedOnly ? true : null,
message.IsRegularTradingHours,
message.BuildMode != MarketDataBuildModes.LoadAndBuild ? (int)message.BuildMode : null,
message.BuildFrom?.ToFixMDType(out _),
message.BuildField?.ToFix(),
message.Skip,
message.Count,
message.Fields?.ToArray());
}
}