In this example, the FIX timestamp is only in ms resolution, and so is only really useful for tracking latency from application to capture point where the latency is in 100s of ms.

We can create 2 FIX probes with the exact same configuration details, except for the following details:

  1. Name the first e.g. FIX_time_order, node ID 1

  2. Name the second e.g. FIX_order, node ID 2

  3. The the first probe should have SDK transformation enabled

    1. The Script File parameter should be the full path to the js file - /data/sdk/fix_time/fix_time.js

  4. The first probe should have the following DDC:

    52:string:fix.SendingTime


  5. The first probe should have TimeStamp Data Field set to fix.TS

Save the following code into /data/sdk/fix_time/fix_time.js (it will only function with Stack 2.1.77 or above)

mkdir -p /data/sdk/fix_time if it doesn't exist

var console = vu8.load('console')
// example SDK code to take fix SendingTime and generates a timestamp
// requires DDC 52:string:fix.SendingTime
try {
var SendingTimeString = decoder.protocol.getDatafield("fix.SendingTime")
if (! SendingTimeString) {
console.log('fix_time script decoder: error getting fix.SendingTime')
}
else if (! (SendingTimeString instanceof decoder.DatafieldString)) {
console.log('equiduct FIX-MD script decoder: fix.SendingTime is not DatafieldString')
SendingTimeString = null
}
var dfTS = new decoder.DatafieldTimestamp("fix.TS")
decoder.protocol.addDatafield(dfTS)
}
catch (e) {
console.log('fix_time script decoder: exception getting data fields')
}
 
console.log('fix_time decoder: loaded script')
 
function on_new_decoder(dec) {
//console.log('fix_time decoder: create decoder')
}
 
function on_data(dec) {
if (SendingTimeString) {
var val = new decoder.UInt64()
// SendingTime (52): 20121123-12:12:17.278
var timestr = SendingTimeString.get()
//console.log('SendingTime: ' + timestr);
var matches = timestr.match(/(\d\d\d\d)(\d\d)(\d\d)-(\d\d):(\d\d):(\d\d).(\d+)/)
//console.log(matches)
if(matches != null) {
var year = matches[1]
var month = matches[2] -1
var day = matches[3]
var hours = matches[4]
var mins = matches[5]
var secs = matches[6]
var msecs = matches[7]
var d = new Date(year, month, day, hours, mins, secs, msecs)
//console.log("DATE: " + d + "M: " + month + " D:" + day + " H:" + hours);
val.fromUInt32((d.getTime()/1000) - (d.getTimezoneOffset()*60))
val.multiply(1000)
val.increment(d.getUTCMilliseconds())
val.multiply(1000000)
// now we need to - but waiting on implementation in SDK
// val.multiplyBy(1000000)
// parse the timestamp into this number
dfTS.fromUInt64(val)
dec.nextDecoder()
}
}
}
 
function on_missed_data(dec, size) {
dec.log("fix_time decoder: missed data of length: " + size.toDouble())
}