简体   繁体   English

使用 Quickfix Python 创建 FIX 消息

[英]Create A FIX Message using Quickfix Python

I am a very new user to Quickfix Python.我是 Quickfix Python 的新用户。 I want to send a QuoteRequest.我想发送一个 QuoteRequest。 My function to create a new quote request message is as below:我创建新报价请求消息的功能如下:


import quickfix as fix

def create_quote_request():
    message = fix.Message()
    header  = message.getHeader()
    header.setField(fix.MsgType(fix.MsgType_QuoteRequest))
    gp      = fix.Group()
    gp.setField(fix.Symbol("GBPUSD"))
    gp.setField(fix.Side(fix.Side_BUY))
    gp.setField(fix.Account("TestAcc"))
    gp.setField(fix.Currency("GBP"))
    message.addGroup(gp)
    fix.Session.sendToTarget(message, self.sessionID)

When I execute the code, I am getting error as below:当我执行代码时,出现如下错误:

NotImplementedError: Wrong number r type of arguments for overloaded function 'new_group'. NotImplementedError: 重载函数“new_group”的参数数量 r 类型错误。

Possible C/C++ prototypes are:可能的 C/C++ 原型是:

FIX::Group::Group(int, int) FIX::Group::Group(int, int)

FIX::Group::Group(int, int, int const[]) FIX::Group::Group(int, int, int const[])

FIX::Group::Group(int, int, message_order const &) FIX::Group::Group(int, int, message_order const &)

FIX::Group::Group(FIX::Group const &) FIX::Group::Group(FIX::Group const &)

I did read the documentation and found that the Group object requires arguments Group(int field, int delim)我确实阅读了文档,发现 Group 对象需要参数Group(int field, int delim)

Not sure what to pass the values for field and delim.不确定传递 field 和 delim 的值是什么。 Appreciate your response and help.感谢您的回应和帮助。

not sure I´m on time to help.不确定我是否能准时提供帮助。 But I will try.但是我会尝试。 I think @JimmyNJ is giving you proper answer.我认为@JimmyNJ 给了你正确的答案。

According to official doc you can easily do it, but you don´t have to use a generic group, you have to use specific group available to your kind of message.根据官方文档,您可以轻松地做到这一点,但您不必使用通用组,您必须使用可用于您的消息类型的特定组。

As far as I know, you should program something like this.据我所知,你应该编写这样的程序。

from quickfix44 import QuoteRequest
import quickfix as fix
message = QuoteRequest()
group = QuoteRequest.NoRelatedSym()
group.setField(fix.Symbol("GBPUSD"))
group.setField(fix.Side(fix.Side_BUY))
group.setField(fix.Account("TestAcc"))
group.setField(fix.Currency("GBP"))
message.addGroup(group)

I´m assuming you want to add these 4 tags into NoRelatedSym group, based in their tag numbers.我假设您想根据它们的标签编号将这 4 个标签添加到 NoRelatedSym 组中。 I´ve also used FIX 44 version, maybe you are using a different version, but main idea is the same.我也使用过 FIX 44 版本,也许您使用的是不同的版本,但主要思想是相同的。

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

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