如何使用 Python 将 QuickFix 中的 TransactTime 设置为 GMT 格式
我对使用 python
和 quickfix
比较陌生,我希望消息的事务时间采用 UTC 格式,以便事务时间看起来像 YYYYMMDD- HH:MM:SS.mmm
所以基本上我希望标签 60 看起来像 2012-02-13-08:15:35.435
例如
我做了以下代码
newSingle.getHeader().setField(fix.Transacttime(time.gmtime()))
,但是我收到与 C/C++ 原型不匹配的错误
newSingle.getHeader().setField(fix.TransactTime(time.gmtime()))
File "/usr/lib/python2.6/dist-packages/quickfix.py", line 41959, in __init__
quickfix.UtcTimeStampField.__init__(self, 60, data)
File "/usr/lib/python2.6/dist-packages/quickfix.py", line 764, in __init__
this = _quickfix.new_UtcTimeStampField(*args)
NotImplementedError: Wrong number of arguments for overloaded function 'new_UtcTimeStampField'.
Possible C/C++ prototypes are:
FIX::UtcTimeStampField(int,UtcTimeStamp const &,bool)
FIX::UtcTimeStampField(int,UtcTimeStamp const &)
FIX::UtcTimeStampField(int,bool)
FIX::UtcTimeStampField(int)
有关如何实现我正在寻找的结果的任何帮助。谢谢!
I'm relatively new to using python
and quickfix
, I want the transaction time for a message to be in UTC format so that the transact time looks like YYYYMMDD-HH:MM:SS.mmm
so basically I want tag 60 to look like 2012-02-13-08:15:35.435
for example
I did the following code
newSingle.getHeader().setField(fix.Transacttime(time.gmtime()))
but I'm getting errors that doesn't match C/C++ prototypes
newSingle.getHeader().setField(fix.TransactTime(time.gmtime()))
File "/usr/lib/python2.6/dist-packages/quickfix.py", line 41959, in __init__
quickfix.UtcTimeStampField.__init__(self, 60, data)
File "/usr/lib/python2.6/dist-packages/quickfix.py", line 764, in __init__
this = _quickfix.new_UtcTimeStampField(*args)
NotImplementedError: Wrong number of arguments for overloaded function 'new_UtcTimeStampField'.
Possible C/C++ prototypes are:
FIX::UtcTimeStampField(int,UtcTimeStamp const &,bool)
FIX::UtcTimeStampField(int,UtcTimeStamp const &)
FIX::UtcTimeStampField(int,bool)
FIX::UtcTimeStampField(int)
Any help as to how I can achieve the result I'm looking for. Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
由于 Python 不支持
UtcTimeStamp
,因此我建议手动设置该值。或者你也可以这样做。
As
UtcTimeStamp
isn't supported in Python, I suggest setting the value manually.Or you could also do like this.
试试这个:
code
此后您将完成消息中的“标签 60”。
在 ipython 中尝试一下,检查一下:
祝你好运!
Try this:
code
After this you will have complete the "tag 60" in the message.
Tri it in ipython a check it:
Good luck!
好吧,菜鸟错误,回答我自己的问题:
这将为您完成所有工作。
Okay, rookie error, to answer my own question:
This will do all the work for you.
当您调用
fix.TransactionTime()
时,它会默认创建带有当前时间的标签。例如:如果您想设置自定义时间戳:
请注意,
SendingTime
(52) 和TransactionTime
(60) 是两个不同的标签,但它们的行为是相同的(即您可以将与上面的TransactionTime
相同的逻辑应用于SendingTime
)。When you call
fix.TransactionTime()
it creates the tag with the current time by default. For example:If you want to set a custom timestamp:
Note that
SendingTime
(52) andTransactionTime
(60) are two different tags but their behavior is the same (i.e. you can apply the same logic toSendingTime
asTransactionTime
above).