查询组

时间:2015-10-06 10:41:19

标签: fix-protocol quickfixn

我目前正在使用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);

在这种特定情况下,只使用一个订单组创建消息。

在接受者中,我尝试按如下方式获取订单组:

public void OnMessage(QuickFix.FIX44.AllocationInstruction allocation, SessionID sessionID)
{
    Console.WriteLine("Order count: " + allocation.NoOrders.getValue());
    var orderGroup = new QuickFix.FIX44.AllocationInstruction.NoOrdersGroup();
    allocation.GetGroup(1, orderGroup);
    info.Orders.Add(new AllocationInstructionOrder
    {
        ClOrdID = orderGroup.ClOrdID.getValue(),
        OrderID = orderGroup.OrderID.getValue(),
        Quantity = orderGroup.OrderQty.getValue()
    });
}

allocation.NoOrders的值为1。但是,当使用索引1(第一组)调用GetGroup()时,我得到

QuickFix.FieldNotFoundException occurred
  HResult=-2146232832
  Message=field not found for tag: 73
  Source=QuickFix
  Field=73
  StackTrace:
       at QuickFix.FieldMap.GetGroup(Int32 num, Int32 field)
       at QuickFix.FieldMap.GetGroup(Int32 num, Group group)
       at FIX.FixAcceptorService.AcceptorExchange.OnMessage(AllocationInstruction allocation, SessionID sessionID) in c:\Projects\AdHoc\FIX\FIX\FIX\FixAcceptorService\AcceptorExchange.cs:line 82
  InnerException: 

这是FIX消息日志:

20151008-06:03:57.410 : 8=FIX.4.4 9=65 35=A 34=1 49=TEST 52=20151008-06:03:57.388 56=BAOBAB 98=0 108=30 10=225 
20151008-06:03:57.444 : 8=FIX.4.4 9=65 35=A 34=1 49=BAOBAB 52=20151008-06:03:57.440 56=TEST 98=0 108=30 10=214 
20151008-06:04:04.162 : 8=FIX.4.4 9=258 35=J 34=2 49=TEST 52=20151008-06:04:04.158 56=BAOBAB 6=9.175 15=ZAR 22=4 48=ZAE0007990962 53=506 54=1 55=R 60=20151008-08:04:04.141 64=20151008 70=080404139 71=0 75=20151008 106=ABC 118=4642.56 207=XJSE 381=4642.56 626=2 857=1 73=1 11=18122977 37=118 38=506 10=251 
20151008-06:04:10.876 : 8=FIX.4.4 9=110 35=j 34=2 49=BAOBAB 52=20151008-06:04:10.876 56=TEST 45=2 58=Conditionally Required Field Missing 372=J 380=5 10=127 
20151008-06:04:34.890 : 8=FIX.4.4 9=53 35=0 34=3 49=TEST 52=20151008-06:04:34.890 56=BAOBAB 10=176 
20151008-06:04:40.894 : 8=FIX.4.4 9=53 35=0 34=3 49=BAOBAB 52=20151008-06:04:40.894 56=TEST 10=177 
20151008-06:05:04.909 : 8=FIX.4.4 9=53 35=0 34=4 49=TEST 52=20151008-06:05:04.908 56=BAOBAB 10=175 
20151008-06:05:10.910 : 8=FIX.4.4 9=53 35=0 34=4 49=BAOBAB 52=20151008-06:05:10.910 56=TEST 10=165 
20151008-06:05:34.921 : 8=FIX.4.4 9=53 35=0 34=5 49=TEST 52=20151008-06:05:34.920 56=BAOBAB 10=173 
20151008-06:05:40.924 : 8=FIX.4.4 9=53 35=0 34=5 49=BAOBAB 52=20151008-06:05:40.924 56=TEST 10=174 

最后,接受者设置:

[DEFAULT]
SenderCompID=BAOBAB
UseDataDictionary=N
StartTime=00:00:00
EndTime=00:00:00
FileStorePath=C:\Users\bernhard.haussermann\AppData\Local\Temp\FIX_BAOBAB
FileLogPath=C:\Users\bernhard.haussermann\AppData\Local\Temp\FIX_BAOBAB_log
ConnectionType=acceptor
SocketAcceptPort=8030
ResetOnLogon=N
ResetOnLogout=N
ResetOnDisconnect=N
[SESSION]
BeginString=FIX.4.4
TargetCompID=TEST
[SESSION]
BeginString=FIXT.1.1
DefaultApplVerID=FIX.5.0
TargetCompID=TEST

上面的C#代码基于example on the QuickFIX/n site

有什么想法吗?

1 个答案:

答案 0 :(得分:5)

下载quickfix / n的源代码并对其进行调试后,我终于找到了问题的原因!

接受者没有正确解释该消息,因为它没有为NoOrders(73)标记创建一个组。查找组标签的数据字典映射为空,因为我在设置中使用了UseDataDictionary = N. 更改接受器以使用数据字典解决了问题。

这是我更新的设置字符串:

[DEFAULT]
SenderCompID=BAOBAB
UseDataDictionary=Y
DataDictionary=C:\Users\bernhard.haussermann\AppData\Local\Temp\FIX44.xml
StartTime=00:00:00
EndTime=00:00:00
FileStorePath=C:\Users\bernhard.haussermann\AppData\Local\Temp\FIX_BAOBAB
FileLogPath=C:\Users\bernhard.haussermann\AppData\Local\Temp\FIX_BAOBAB_log
ConnectionType=acceptor
SocketAcceptPort=8030
ResetOnLogon=N
ResetOnLogout=N
ResetOnDisconnect=N
[SESSION]
BeginString=FIX.4.4
TargetCompID=TEST