上下文
我有一个测试Acceptor和Initiator.我正在使用QuickFix/N 1.7版本.如果我将Acceptor和Initiator配置为FIX 4.4,一切正常.什么都不做,只是连接,然后将传入/传出的心跳消息记录到调试控制台.好的,见下文.
我改变什么相应的只是两个配置文件从FIX 4.4至5.0 FIX.所有工作(我的意思是心跳消息仍在进行中),但回调的message参数不再是类型化(心跳)运行时实例消息,而是基类.
诊断:
题:
为什么消息实例不是FIX 5.0案例中的类型化运行时实例消息,并且在FIX 4.4案例中键入?这是预期的行为还是我错过了什么?
代码展品:
Initiator IApplication实现中的代码,用于生成输出行:
public void ToAdmin(Message message, SessionID sessionID)
{
Debug.WriteLine($@"(A)OUT: {message.GetType()}{message}");
}
public void FromAdmin(Message message, SessionID sessionID)
{
Debug.WriteLine($@"(A)IN: {message.GetType()}{message}");
}
Run Code Online (Sandbox Code Playgroud)
使用4.4配置时,我看到:(消息类型是QuickFix.FIX44.Heartbeat)
Logon - FIX.4.4:TEST01->MYACCEPTOR
(A)IN: QuickFix.FIX44.Heartbeat8=FIX.4.4 9=5335=034=249=MYACCEPTOR52=20170715-15:00:31.59656=TEST0110=179
(A) OUT: QuickFix.FIX44.Heartbeat8=FIX.4.4 9=5335=034=249=TEST0152=20170715-15:00:31.60456=MYACCEPTOR10=169
(A) OUT: QuickFix.FIX44.Heartbeat8=FIX.4.4 9=5335=034=349=TEST0152=20170715-15:00:36.61056=MYACCEPTOR10=172
(A) IN: QuickFix.FIX44.Heartbeat8=FIX.4.4 9=5335=034=349=MYACCEPTOR52=20170715-15:00:36.61556=TEST0110=177
Run Code Online (Sandbox Code Playgroud)
使用5.0和配置时,我看到:( 消息类型只是 QuickFix.FIX50.Message)
Logon - FIXT.1.1:TEST01->MYACCEPTOR
(A)IN: QuickFix.Message8=FIXT.1.19=5335=034=249=MYACCEPTOR52=20170715-15:06:16.92256=TEST0110=003
(A) OUT: QuickFix.Message8=FIXT.1.19=5335=034=249=TEST0152=20170715-15:06:16.93056=MYACCEPTOR10=002
(A) OUT: QuickFix.Message8=FIXT.1.19=5335=034=349=TEST0152=20170715-15:06:21.93656=MYACCEPTOR10=005
(A) IN: QuickFix.Message8=FIXT.1.19=5335=034=349=MYACCEPTOR52=20170715-15:06:21.94156=TEST0110=001
Run Code Online (Sandbox Code Playgroud)
Intiator的FIX5.0配置:
[DEFAULT] …Run Code Online (Sandbox Code Playgroud) 我正在尝试使用QuickFIX/n通过FIX协议(4.4)连接到Bloomberg.
Bloomberg要求使用TLS 1.2协议.我按照说明安装了PFX证书.
我当前的FIX配置文件如下所示:
[DEFAULT]
ConnectionType=initiator
ReconnectInterval=2
FileStorePath=store
FileLogPath=fixlog
StartTime=06:00:00
StartDay=monday
EndTime=22:00:00
EndDay=friday
SocketConnectHost=xxx.xx.xxx.xx
SocketConnectPort=8228
# standard config elements
[SESSION]
BeginString=FIX.4.4
SenderCompID=MY_COMP_ID
TargetCompID=BBG_COMP_ID
HeartBtInt=60
ValidateFieldsOutOfOrder=N
UseDataDictionary=Y
DataDictionary=FIX_BBG.xml
CheckLatency=N
[SSL]
SSLEnable=Y
SSLProtocols=Tls12
SSLValidateCertificates=Y
SSLCheckCertificateRevocation=N
SSLCertificate=C:\Services\FixEngineService\cert\pkcs12\cert.pfx
SSLCertificatePassword=xxxxxxxxxxxx
Run Code Online (Sandbox Code Playgroud)
当我打开会话时,我立即断开连接.实际上,达到服务器并不是网络问题.布隆伯格告诉我他们有一个"未知协议"的消息.我没有得到任何记录.
你觉得我的配置有问题吗?有没有人成功建立与彭博的quickfix连接?如果是的话,根据您的经验,我的设置可能出现什么问题?
我正在编写一个基于Quickfix/N的 FIX 引擎,它监听交易执行(ExecutionReport)并将其保存到数据库中。
如果接收到的消息中不存在该值,则从 API 请求字段值会引发 FieldNotFoundException。例如,如果帐户不存在,则调用executionReport.Account 将引发异常。
由于某些字段是可选的,因此我必须在获取字段值之前明确检查该字段值是否存在。我对此有两种可能性:
可能性一:
executionReport.IsSetAccount() ? executionReport.Account : null;
可能性2:
try
{
return executionReport.Account.getValue();
}
catch (Exception e)
{
return null;
}
Run Code Online (Sandbox Code Playgroud)
第一个选项很干净,但我发现它真的很重,第二个选项可以概括为辅助函数,但它违背了 API 哲学,我感觉我做错了什么。
那么我的问题是:
或者我对协议/API的理解完全错误?我感觉我没有以正确的方式解决这个问题。
多谢
我目前正在使用QuickFIX/n来构建一个接受器服务,我已经构建了一个启动器来测试接受器.我怀疑我得到的错误是由于接收器中的错误,因为同一错误发生在其他人发送给服务的消息上.
在发起程序中,我构建并发送AllocationInstruction,如下所示:
var fix44Message = new QuickFix.FIX44.AllocationInstruction(
new AllocID(request.Info.AllocationID), EnumHelpers.ParseAllocationTransactionType(request.Info.AllocationTransactionType), EnumHelpers.ParseAllocationType(request.Info.AllocationType),
new AllocNoOrdersType(AllocNoOrdersType.EXPLICIT_LIST_PROVIDED), EnumHelpers.ParseSide(request.Info.Side), new Symbol(request.Info.Symbol), new Quantity(request.Info.Quantity),
new AvgPx(request.Info.AveragePrice), new TradeDate(request.Info.TradeDate.ToString("yyyyMMdd")))
{
SecurityID = new SecurityID(request.Info.SecurityID),
SecurityIDSource = new SecurityIDSource(request.Info.SecurityIDSource),
SecurityExchange = new SecurityExchange(request.Info.SecurityExchange),
Issuer = new Issuer(request.Info.Issuer),
Currency = new Currency(request.Info.Currency),
TransactTime = new TransactTime(request.Info.TransactTime),
SettlDate = new SettlDate(request.Info.SettlementDate.ToString("yyyyMMdd")),
GrossTradeAmt = new GrossTradeAmt(request.Info.GrossTradeAmount),
NetMoney = new NetMoney(request.Info.NetMoney)
};
var group = new QuickFix.FIX44.AllocationInstruction.NoOrdersGroup
{
ClOrdID = new ClOrdID(order.ClOrdID),
OrderID = new OrderID(order.OrderID),
OrderQty = new OrderQty(order.Quantity)
};
fix44Message.AddGroup(group); …Run Code Online (Sandbox Code Playgroud)