简体   繁体   English

将消息发送到QUICKFIX N中的特定会话

[英]Sending a Message to a specific session in QUICKFIX N

I've recently been given the task of making a basic trading platform for new traders. 最近,我被赋予为新交易者建立基本交易平台的任务。 I'm connecting to a bank FIX 4.4 implementation. 我正在连接银行FIX 4.4实施。

The bank has specified 2 sessions. 银行指定了2个会话。 One for quote data and one for trade executions. 一种用于报价数据,另一种用于交易执行。

I'm using QuickfixN and coding in c# 我正在使用QuickfixN并在C#中进行编码

I have set up my initiator session config to have both sessions in it. 我已将启动程序会话配置设置为同时包含两个会话。 The port is different and the target comp ids and sender comp ids are different. 端口不同,目标组件ID和发件人组件ID也不同。 I can connect to both fine. 我可以同时连接两个。 What i'm struggling with is figuring out how to send my order requests through one session and not the other. 我正在努力解决的问题是弄清楚如何通过一个会话而不是另一个会话发送订单请求。

Both sessions require FIX 4.4. 两个会话都需要FIX 4.4。 By default it just uses the first session. 默认情况下,它仅使用第一个会话。

When you create the initiators, save the session objects into variables. 创建启动器时,请将会话对象保存到变量中。 (Perhaps via the OnCreate callback, as done here .) (也许通过OnCreate回调,如此处所示 。)

Make those variables accessible to the message-sending class. 使那些变量可供消息发送类访问。

Then to send messages, just call one of: 然后,要发送消息,只需调用以下方法之一:

quoteSession.send(msg)
tradeSession.send(msg)

Well you need to multiplex the SessionId of the session on which to send a message, and setup the message header. 那么,您需要多路复用要在其上发送消息的会话的SessionId,并设置消息头。 Something like this (in Java): 像这样(在Java中):

public void mySend (Message m) throws FieldNotFound 
{       
    String beginString = "FIX.4.4";
    String sender = "SENDER";
    String target = "TARGET";

    // Set the message headers
    m.getHeader().setField(new SenderCompID(sender));
    m.getHeader().setField(new TargetCompID(target));

    // Set the correct session for the initiator to send out to
    SessionID s = new SessionID(beginString, sender, target);

    // Lookup the relevant QF session
    _session = Session.lookupSession(s);

    // Send the FIX message
    try
    {
            if (_session != null)
            {
                _session.send(m);
            }
            else
            {
                log("Can't send message: FIX session not created.");
                log(" " + m.toString());
            }
    }
    catch (Exception e)
    {
            errorHandler(e);
    }
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM