Files
StockSharp/Fix.Core/MessageConverter.Other.cs
T
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

126 lines
2.8 KiB
C#

namespace StockSharp.Fix;
/// <summary>
/// Other message converters: BoardLookup, BoardUpdate, Remove, HistoryStart, DataTypeLookup.
/// </summary>
partial class MessageConverter
{
/// <inheritdoc />
public virtual BoardLookupMessage ToMessage(FixBoardLookup fix)
{
return new BoardLookupMessage
{
TransactionId = fix.MdReqId.ToLong(),
Like = fix.Like,
};
}
/// <inheritdoc />
public virtual FixBoardLookup ToFixBoardLookup(BoardLookupMessage message)
{
return new FixBoardLookup(
MdReqId: FixId.FromLong(message.TransactionId),
Like: message.Like,
DisableArchive: false);
}
/// <inheritdoc />
public virtual BoardMessage ToMessage(FixBoardUpdate fix)
{
return new BoardMessage
{
Code = fix.Board,
ExchangeCode = fix.Exchange,
};
}
/// <inheritdoc />
public virtual FixBoardUpdate ToFixBoardUpdate(BoardMessage message)
{
return new FixBoardUpdate(
Board: message.Code,
Exchange: message.ExchangeCode);
}
/// <inheritdoc />
public virtual RemoveMessage ToMessage(FixRemove fix)
{
var msg = new RemoveMessage
{
TransactionId = fix.MdReqId.ToLong(),
RemoveId = fix.Id,
};
if (!fix.Type.IsEmpty())
msg.RemoveType = fix.Type.To<RemoveTypes>();
return msg;
}
/// <inheritdoc />
public virtual FixRemove ToFixRemove(RemoveMessage message)
{
return new FixRemove(
MdReqId: FixId.FromLong(message.TransactionId),
Id: message.RemoveId,
Type: message.RemoveType.To<string>());
}
/// <inheritdoc />
public virtual (string RequestId, DateTime? From) ToHistoryStart(FixHistoryStart fix)
{
return (null, fix.StartDate);
}
/// <inheritdoc />
public virtual FixHistoryStart ToFixHistoryStart(string requestId, DateTime? from)
{
return new FixHistoryStart(
StartDate: from,
EndDate: null);
}
/// <inheritdoc />
public virtual DataTypeLookupMessage ToMessage(FixDataTypeLookup fix)
{
var msg = new DataTypeLookupMessage
{
TransactionId = fix.MdReqId.ToLong(),
IncludeDates = fix.IncludeDates,
};
if (!fix.Symbol.IsEmpty() || !fix.Exchange.IsEmpty())
{
msg.SecurityId = new SecurityId
{
SecurityCode = fix.Symbol,
BoardCode = fix.Exchange,
};
}
if (fix.MdEntryType != null)
msg.RequestDataType = fix.MdEntryType.Value.ToDataType(fix.MdEntryArg);
if (fix.Format != null)
msg.Format = fix.Format.Value;
return msg;
}
/// <inheritdoc />
public virtual FixDataTypeLookup ToFixDataTypeLookup(DataTypeLookupMessage message)
{
string arg = null;
var mdType = message.RequestDataType?.ToFixMDType(out arg);
return new FixDataTypeLookup(
MdReqId: FixId.FromLong(message.TransactionId),
Symbol: message.SecurityId.SecurityCode,
Exchange: message.SecurityId.BoardCode,
MdEntryType: mdType,
MdEntryArg: arg,
Format: message.Format,
IncludeDates: message.IncludeDates);
}
}