8

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!

Nag
  • 1,438
  • 1
  • 11
  • 39
dannosden
  • 111
  • 1
  • 2
  • 6
  • Check how **Transacttime** is implemented in quickfix.And then check what time.gmtime() returns. That should give you the problem point. – DumbCoder Feb 13 '12 at 15:10

4 Answers4

4

As UtcTimeStamp isn't supported in Python, I suggest setting the value manually.

newSingle.getHeader().setField(fix.StringField(60,(datetime.utcnow ().strftime ("%Y%m%d-%H:%M:%S.%f"))[:-3]))

Or you could also do like this.

transact_time = fix.TransactTime()
transact_time.setString('20160404-03:52:24.824')
newSingle.getHeader().setField(transact_time)
Salman Ahmed
  • 682
  • 1
  • 10
  • 24
fx-kirin
  • 1,906
  • 1
  • 20
  • 33
2

Try this:

code

#imports
import quickfix
import quickfix50sp2

#code
...
newSingle = quickfix50sp2.NewOrderSingle()

t = quickfix.TransactTime()
t.setString(datetime.datetime.utcnow().strftime("%Y%m%d-%H:%M:%S.%f")[:-3])

newSingle.setField(t)

After this you will have complete the "tag 60" in the message. Tri it in ipython a check it:

In[]: newSingle.toString()
Out[]: '8=FIXT.1.1\x019=37\x0135=D\x011128=9\x0160=20180603-18:19:51.428\x0110=091\x01'

Good luck!

Community
  • 1
  • 1
1

When you call fix.TransactionTime() it creates the tag with the current time by default. For example:

In [68] : fix.TransactTime().getString()
Out[68] : '20160701-18:01:57'

If you want to set a custom timestamp:

In [135] : dnow = datetime.utcnow()

In [136] : dnow.strftime('%Y%m%d-%H:%M:%S')
Out[136] : '20160701-18:23:33'

In [137] : tag = fix.TransactTime()

In [138] : tag.getString()
Out[138] : '20160701-18:23:46'

In [139] : tag.setString(dnow.strftime('%Y%m%d-%H:%M:%S'))

In [140] : tag.getString()
Out[140] : '20160701-18:23:33'

Note that SendingTime (52) and TransactionTime (60) are two different tags but their behavior is the same (i.e. you can apply the same logic to SendingTime as TransactionTime above).

sirfz
  • 4,097
  • 23
  • 37
1

Okay, rookie error, to answer my own question:

newSingle.getHeader().setField(fix.SendingTime(1)) 

This will do all the work for you.

Frank Shearar
  • 17,012
  • 8
  • 67
  • 94
dannosden
  • 111
  • 1
  • 2
  • 6