mirror of
https://github.com/StockSharp/StockSharp.git
synced 2026-12-04 08:32:23 +00:00
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.
77 lines
2.0 KiB
C#
77 lines
2.0 KiB
C#
namespace StockSharp.Fix;
|
|
|
|
/// <summary>
|
|
/// Session message converters: TestRequest, SequenceReset, ResendRequest, TradingSessionStatus.
|
|
/// </summary>
|
|
partial class MessageConverter
|
|
{
|
|
/// <inheritdoc />
|
|
public virtual TimeMessage ToMessage(FixTestRequest fix)
|
|
{
|
|
return new TimeMessage
|
|
{
|
|
TransactionId = fix.TestReqId.To<long?>() ?? 0,
|
|
};
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual FixTestRequest ToFixTestRequest(TimeMessage message)
|
|
{
|
|
return new FixTestRequest(
|
|
TestReqId: message.TransactionId.To<string>());
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual (bool GapFill, long NewSeqNo) ToSequenceReset(FixSequenceReset fix)
|
|
{
|
|
return (fix.GapFill ?? false, fix.NewSeqNo ?? 0);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual FixSequenceReset ToFixSequenceReset(bool gapFill, long newSeqNo)
|
|
{
|
|
return new FixSequenceReset(
|
|
GapFill: gapFill,
|
|
NewSeqNo: newSeqNo);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual (long BeginSeqNo, long EndSeqNo) ToResendRange(FixResendRequest fix)
|
|
{
|
|
return (fix.BeginSeqNo ?? 0, fix.EndSeqNo ?? 0);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual FixResendRequest ToFixResendRequest(long beginSeqNo, long endSeqNo)
|
|
{
|
|
return new FixResendRequest(
|
|
BeginSeqNo: beginSeqNo,
|
|
EndSeqNo: endSeqNo);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual BoardLookupMessage ToMessage(FixTradingSessionStatusRequest fix)
|
|
{
|
|
var msg = new BoardLookupMessage
|
|
{
|
|
TransactionId = fix.TradSesReqId.ToLong(),
|
|
IsSubscribe = GetIsSubscribe(fix.SubscriptionRequestType),
|
|
};
|
|
|
|
if (!fix.SessionId.IsEmpty())
|
|
msg.Like = fix.SessionId;
|
|
|
|
return msg;
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
public virtual FixTradingSessionStatusRequest ToFixTradingSessionStatusRequest(BoardLookupMessage message)
|
|
{
|
|
return new FixTradingSessionStatusRequest(
|
|
SessionId: message.Like,
|
|
TradSesReqId: FixId.FromLong(message.TransactionId),
|
|
ResponseId: message.OriginalTransactionId != 0 ? FixId.FromLong(message.OriginalTransactionId) : default,
|
|
SubscriptionRequestType: ToFixSubscriptionType(message.IsSubscribe));
|
|
}
|
|
}
|