Page tree

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Logging in JavaScript

print(<text>)

Example Code

print (getCurrentDateStr(DATETIMEUtc));

Execution of this line results in the following record in the application log:

[NOTE]  20131023-08:28:53.651 [4320] [../FixEdge/conf/test.js] - JavaScript '../FixEdge/conf/test.js' output: 20131023-08:28:53

Operations with session

startSession(<sessionName>)

Starts session "sessionName"

Example Code

startSession("StartByEvent")
Starts the "StartByEvent" session

startSession(<senderCompId>,<targetCompId>)

Starts session where SenderCompID = "senderCompID" and TargetCompID = "targetCompID"

Example Code

startSession("FIXEdge","SimpleClient")
Starts a session where SenderCompID = "FIXEdge" and TargetCompID = "SimpleClient"

startSession(<senderCompId>,<targetCompId>,<sessionQualifier>)

Starts session where SenderCompID = "senderCompID",TargetCompID = "targetCompID",SessionQualifierValue = "sessionQualifier"


Example Code

startSession("FIXEdge","SimpleClient","Q1")
Starts a session where SenderCompID = "FIXEdge", TargetCompID = "SimpleClient", SessionQualifierValue = "Q1"

disconnectSession(<sessionName>,<reason>)

Disconnects session "sessionName" with reason "reason"

Example Code

disconnectSession("DisconnectByEvent","Disconnect by message")
Disconnects the "DisconnectByEvent"session with the "Disconnect by message" reason

disconnectSession(<senderCompId>,<targetCompId>,<reason>)

Disconnects session where SenderCompID = "senderCompId" and TargetCompID = "targetCompId" with reason "reason"

Example Code

disconnectSession("FIXEdge","SimpleClient","Disconnect by message")
Disconnects a session where SenderCompID = "FIXEdge" and TargetCompID = "SimpleClient" with reason "Disconnect by message"

disconnectSession(<senderCompId>,<targetCompId>,<sessionQualifier>,<reason>)

Starts session where SenderCompID = "senderCompID",TargetCompID = "targetCompID",SessionQualifierValue = "sessionQualifier" with reason "reason"


Example Code

disconnectSession("FIXEdge","SimpleClient","Disconnect by message","Q1")
Disconnects a session where SenderCompID = "FIXEdge", TargetCompID = "SimpleClient", SessionQualifierValue = "Q1" with reason "Disconnect by message"

terminateSession(<sessionName>,<reason>)

Terminates session "sessionName" with reason "reason"

Example Code

terminateSession("TerminateByEvent","Terminate by message")
Terminates the "TerminateByEvent" session with the "Terminate by message" reason

terminateSession(<senderCompId>,<targetCompId>,<reason>)

Terminates session where SenderCompID = "senderCompID" and TargetCompID = "targetCompID" with reason "reason"

Example Code

terminateSession("FIXEdge","SimpleClient","Terminate by message")
Terminates a session where SenderCompID = "FIXEdge" and TargetCompID = "SimpleClient" with reason "Terminate by message"

terminateSession(<senderCompId>,<targetCompId>,<sessionQualifier>,<reason>)

Terminates session where SenderCompID = "senderCompID",TargetCompID = "targetCompID",SessionQualifierValue = "sessionQualifier"


Example Code

terminateSession("FIXEdge","SimpleClient","Q1","Terminate by message")
Terminates a session where SenderCompID = "FIXEdge", TargetCompID = "SimpleClient", SessionQualifierValue = "Q1" with reason "Terminate by message"

Please note:

  1. The session will not be visible in FIXICC or manageable (start, disconnect, etc) from FIXICC/BL/JS/scheduler.
  2. The termination and the disconnection occur with async way after rule completion. In case of fail <OnRuleFailEvent> will be called.

Operations with group fields

getGroup(<fieldTag>)

Returns group handle for <fieldTag> group field 

Example Code

hndl = getGroup(78);
isGroupValid(hndl)

Gets a handle on group 78 and tests whether handle 78 is valid

getGroup(<parentGroupHandle>, <entry>, <fieldTag>)

Returns group handle for <fieldTag> group field from <parentGroupHandle>[<entry>] group

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl);
hndl2 = getGroup(hndl, 0, 518);
isGroupValid(hndl2); 
if(hndl2 != hndl){
    setNumField(552, 4);
}

Gets a handle on group 552 and tests whether the handle 552 is valid

Gets a handle from the first record of 552 group on group 518 and tests whether the handle 518 is valid

If the group handles are not identical, then increase the number of group 552 elements up to 4

removeField(<group handle>, <entry>, <fieldTag>)

Removes field from group field

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(78);
isGroupValid(hndl);
removeField(hndl, 0, 79);

Gets handle on group 78 and tests whether the handle 78 is valid 

Removes tag 79 from group 78

isGroupValid(<handle>)

Returns true or false depending on the handle value

Example Code

//see the example above 


Bulk operations with group fields

Note

Available since FIXEdge 6.12.0 

bulkSetStringField(<group handle>, <starting entry>, <fieldTag>, <value>, [<max count>])

Populates multiple entries' specific tag with constant value, or copies values from list, depending on value type.

Note

Numeration of <starting_entry> starts with 0.

Example Code 1 

setNumField(268, 200);
hndl = getGroup(268);
bulkSetStringField(hndl, 0, 269, '0', 100);
bulkSetStringField(hndl, 100, 269, '1', 100);


Example Code 2 

bid_qty_list = [10, 20, 30, 40, 50];
ask_qty_list = [11, 22, 33];

setNumField(268, bid_qty_list.length + ask_qty_list.length);
hndl = getGroup(268);

bulkSetStringField(hndl, 0, 271, bid_qty_list);
bulkSetStringField(hndl, bid_qty_list.length, 271, ask_qty_list);

Example 1

Resizes group 268 (NoMDEntries) to 200

Gets a handle on group 268 (NoMDEntries)

For entries 0 - 99 set tag 269 (MDEntryType) to '0' ('Bid')

For entries 100 - 199 set tag 269 (MDEntryType) to '1' ('offer')

This is equivalent to code:

for (var i = 0; i < 100; i++) {
setStringField(hndl, i, 269, '0');
}

for (var i = 100; i < 200; i++) {
setStringField(hndl, i, 269, '1');
}


Example 2

Creates a bid_qty_list variable with 5 elements and ask_qty_list with 3 elements

Resizes group 268 (NoMDEntries) to 8 (total size of 2 lists)

Gets a handle on group 268 (NoMDEntries)

For entries 0-4, copy values from bid_qty_list, so that entry[i][271] = bid_qty_list[i]

For entries 5-7, copy values from ask_qty_list, so that entry[5+i][271] = ask_qty_list[i]

This is equivalent to code:

for (var i = 0; i < bid_qty_list.length; i++) {
setStringField(hndl, i, 271, bid_qty_list[i]);
}

for (var i = 0; i < ask_qty_list.length; i++) {
setStringField(hndl, bid_qty_list.length + i, 271, ask_qty_list[i]);
}

bulkSetStringFieldMapped(<group handle>, <starting entry>, <fieldTag>, <source list>, <key> [, <max count>])

Populates multiple entries' specific tag by copying values from nested elements of source Javascript array.

Note

Numeration of <starting entry> starts with 0.

Numeration of <source list> starts with 0.

Example Code

bids = [ [0.1, 10], [0.2, 20], [0.3, 30], [0.4, 40], [0.5, 50] ] ;

asks = [ [1.1, 11], [2.2, 20], [3.3, 30] ] ;

setNumField(268, bid_qty_list.length + ask_qty_list.length);
hndl = getGroup(268);

bulkSetStringFieldMapped(hndl, 0, 270, bids, 0);
bulkSetStringFieldMapped(hndl, 0, 271, bids, 1);

bulkSetStringFieldMapped(hndl, bid_qty_list.length, 270, bids, 0);
bulkSetStringFieldMapped(hndl, bid_qty_list.length, 271, bids, 1);

For alternative source structure

bids = [ {"price": 0.1, "qty": 10}, 
{"price": 0.2, "qty": 20},
{"price": 0.3, "qty": 30},
{"price": 0.4, "qty": 40},
{"price": 0.5, "qty": 50}] ;

asks = [ {"price": 1.1, "qty": 11},
{"price": 2.2, "qty": 22},
{"price": 3.3, "qty": 33}] ;

setNumField(268, bid_qty_list.length + ask_qty_list.length);
hndl = getGroup(268);

bulkSetStringFieldMapped(hndl, 0, 270, bids, 'price');
bulkSetStringFieldMapped(hndl, 0, 271, bids, 'qty');

bulkSetStringFieldMapped(hndl, bid_qty_list.length, 270, bids, 'price');
bulkSetStringFieldMapped(hndl, bid_qty_list.length, 271, bids, 'qty');

Creates a bids variable with 5 nested pairs of elements, and ask_qty_list with 3 pairs.

Resizes group 268 (NoMDEntries) to 8 (total size of 2 lists)

Gets a handle on group 268 (NoMDEntries)

For entries 0-4, copy Price(270) and Size(271) values from bids;

For entries 5-7, copy Price(270) and Size(271) values from asks.

This is equivalent to code:

for (var i = 0; i < bid_qty_list.length; i++) {
bid = bid_qty_list[i];
setStringField(hndl, i, 270, bid[0]);
setStringField(hndl, i, 271, bid[1]);
}

for (var i = 0; i < ask_qty_list.length; i++) {
ask = ask_qty_list[i];
setStringField(noMDEntries, bid_qty_list.length + i, 270, ask[0]);
setStringField(noMDEntries, bid_qty_list.length + i, 271, ask[1]);
}


For alternative source structure

for (var i = 0; i < bid_qty_list.length; i++) {
bid = bid_qty_list[i];
setStringField(hndl, i, 270, bid['price']);
setStringField(hndl, i, 271, bid['qty']);
}

for (var i = 0; i < ask_qty_list.length; i++) {
ask = ask_qty_list[i];
setStringField(noMDEntries, bid_qty_list.length + i, 270, ask['price']);
setStringField(noMDEntries, bid_qty_list.length + i, 271, ask['qty']);
}

Operations with message fields

removeField(<fieldTag>)

Removes field from message

Example Code

removeField(58);

Removes tag 58 from the message

createReject("session")

Creating reject

Example code

createReject("Target42sohSender42");

Creating reject and sending status message 35=3

isSupportedField(<fieldTag>)

Returns true if the field is defined in the dictionary, i.e. it can be presented in the message. False means the tag is not expected in this message type

Example Code:

if ( isSupportedField( 58 ) )
    removeField( 58 );

The example shows how to remove tag 58 from the message if it is defined in the dictionary

The script checks if tag 58 is defined for the message
And remove it from the message.

isSupportedField( <group handle> , <fieldTag>)

Returns true if the field is defined in the dictionary for the specific group, i.e. it can be presented in the repeating group of the message. False means the tag is not expected in this specific group for this  message type

Example Code

partiesGrp = getGroup(448);
if ( isGroupValid(partiesGrp) && isSupportedField(partiesGrp, 2376) )
    removeField( partiesGrp, 0 , 2376 );

The example shows how to remove non required tag 2376 from the Parties group entry #0. 

The script gets the repeating group 448 handle.
Then checks if the group is valid and present in the message. And if tag 2376 is defined in the dictionary.
Then removes tag 2376 from the group entry #0

getNumField(<fieldTag>)

Returns numeric value of the <fieldTag> field

Example Code

getNumField(78);

Returns a numeric value of field 78

getNumField(<group handle>, <entry>, <fieldTag>)

Returns number value of the <fieldTag> field from group <group handle>[<entry>]

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl);
setNumField(552,getNumField(hndl, 0, 581));

Gets handle on group 552 and tests whether the handle 552 is valid

Gets a numeric value of field 581 and assigns it to field 552

getDateField(<fieldTag>, <format>)

Returns date handle to the <fieldTag> field value

Example Code

getDateField(64, YYYYMMDDLmd);

Gets a date value of the field 64 in YYYYMMDD format

getDateField(<group handle>, <entry>, <fieldTag>, <format>)

Returns date handle to the <fieldTag> field value from group <group handle>[<entry>]

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(778);
isGroupValid(hndl);
getDateField(hndl, 0, 779, YYYYMMDDLmd);

Gets handle on group 778 and tests whether the handle 778 is valid

Gets a date value of the field 779 in the YYYYMMDD format from the first element of group 778

getStringField(<fieldTag>)

Returns string value of the <fieldTag> field

Example Code

getStringField(78); 

Returns a string value of field 78

getStringField(<group handle>, <entry>, <fieldTag>)

Returns string value of the <fieldTag> field from group <group handle>[<entry>]

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl);
setStringField(552,getStringField(hndl, 0, 581));

Gets a handle on group 552 and tests whether handle 552 is valid

Gets a string value of field 581 and assigns it to field 552

getMStringField(<fieldTag>)

Returns array that contains multi string value of the <fieldTag> field

Example Code

tmp = getMStringField(18);
if(3 == tmp.length){
setStringField(55, tmp[0]);
setStringField(65, tmp[1]);
}

Gets a multiple string value of field 18 and assigns it to the tmp variable

If the number of strings in the tmp variable equals to 3, then the value of the first string is assigned to field 55 and the value of the second string is assigned to field 65


getMStringField(<group handle>, <entry>, <fieldTag>)

Returns array that contains multi string value of the <fieldTag> field from group <group handle>[<entry>]

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl);
tmp = getMStringField(hndl, 0, 18);


Gets a handle on group 552 and tests whether handle 552 is valid

Gets a multiple string value of field 18 found in the first entry of group 552 and assigns it to the tmp variable


getRawDataField(<fieldTag>)

returns array that contains raw data value of the <fieldTag> field

Example Code

tmp = getRawDataField(91);

Gets a raw data value of field 91 and assigns it to the tmp variable

getRawDataField(<group handle>, <entry>, <fieldTag>)

Returns array that contains raw data value of the <fieldTag> field from group <group handle>[<entry>]

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(5521);
isGroupValid(hndl);
tmp = getRawDataField(hndl, 0, 91); 
        

Gets a handle on group 5521 and tests whether handle 5521 is valid

Gets a raw data value of field 91 found in the first entry of group 5521 and assigns it to the tmp variable

setNumField(<fieldTag>, <new value>)

assigns value <new value> to the <fieldTag> field as a NUMBER

Example Code

//see the sample for the getNumField();


setDateField(<fieldTag>, <format>, <new value>)

Assigns value <new value> to the <fieldTag> field as a DATE

Example Code

tmp = getDateField(64, YYYYMMDDLmd);
setYear(tmp, 1979);
setDateField(64, YYYYMMDDLmd, tmp);

Gets a date value of field 64 in the YYYYMMDD format and assigns it to the tmp variable

Sets the year of the date to 1979 in the tmp variable

Assigns a date from the tmp variable back to field 64

setStringField(<fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field as a STRING

Example Code

// see the example for getMStringField();


setMStringField(<fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field as a MString

Example Code

tmp = ["aa", "abb", "bbbc"];
setMStringField(18, tmp);

Sets an array of strings named tmp

Assigns the array of strings to multiple string field 18

setRawDataField(<fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field as a RawData

Example Code

tmp = [12, 56, 0, 34];
setRawDataField(91, tmp);

Sets an array of numbers named tmp

Assigns the array of numbers to raw data field 91

setNumField(<group handle>, <entry>, <fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field from group <group handle>[<entry>] as a NUMBER

Note
Numeration of <entry> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl); 
setNumField(hndl, 1, 519, 4);

Explanations

Gets a handle on group 552 and tests whether handle 552 is valid

Field 519 from the second entry of group 552 is assigned to 4

setDateField(<group handle>, <entry>, <fieldTag>, <format>, <new value>)

Assigns value <new value> to the <fieldTag> field from group <group handle>[<entry>] as a DATE

Note
Numeration of <entry> starts with 0.

Example Code

tmp = getDateField(64, YYYYMMDDLmd);

hndl = getGroup(5521);
isGroupValid(hndl); 
setDateField(hndl, 0, 64, YYYYMMDDLmd, tmp);

Gets a date in the YYYYMMDD format from field 64 and assigns the obtained value to the tmp variable

Gets a handle on group 5521 and tests whether handle 5521 is valid

Field 64 from the first entry of group 5521 is assigned the value from the tmp variable

setStringField(<group handle>, <entry>, <fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field from group <group handle>[<entry>] as a STRING

Note
Numeration of <entry> starts with 0.

Example Code

tmp = getStringField(581);

hndl = getGroup(5521);
isGroupValid(hndl); 
setDateField(hndl, 0, 581, tmp);

Gets a string value from field 581 and assigns it to the tmp variable

Gets a handle on group 5521 and tests whether handle 5521 is valid

Field 581 from the first entry of group 5521 is assigned the value from the tmp variable

setMStringField(<group handle>, <entry>, <fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field from group <group handle>[<entry>] as a MString

Note
Numeration of <entry> starts with 0.

Example Code

tmp = getMStringField(18);

hndl = getGroup(5521);
isGroupValid(hndl); 
setMStringField(hndl, 0, 18, tmp); 
        

Gets a multiple strings value from field 18 and assigns it to the tmp variable

Gets a handle on group 5521 and tests whether handle 5521 is valid

Field 18 from the first entry of group 5521 is assigned the value from the tmp variable

setRawDataField(<group handle>, <entry>, <fieldTag>, <new value>)

Assigns value <new value> to the <fieldTag> field from group <group handle>[<entry>] as a RawData

Note
Numeration of <entry> starts with 0.

Example Code

tmp = getRawDataField(91);

hndl = getGroup(5521);
isGroupValid(hndl); 
setRawDataField(hndl, 0, 91, tmp);

Gets a multiple raw data value from field 91 and assigns it to the tmp variable

Gets a handle on group 5521 and tests whether handle 5521 is valid

Field 91 from the first entry of group 5521 is assigned the value from the tmp variable

swapFields(<fieldTag1>, <fieldTag2>)

Exchanges values of fields <fieldTag1> and <fieldTag2>

Example Code

swapFields(63, 573);

Values of field 63 and field 573 were exchanged

swapFields(<group handle field 1>, <entry field 1>, <fieldTag1>, <fieldTag2>)

Exchanges values of fields <fieldTag1> (from group <group handle field 1>[<entry field 1>]) and <fieldTag2> (which can be both from group <group handle field 1>[<entry field 1>] and outside of it)

Note
Numeration of <entry field 1> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl); 
swapFields(hndl, 1, 11, 572);]

Gets a handle on group 552 and tests whether handle 552 is valid

Exchanges values of field 11 in the second entry of group 552 and field 572 outside of it

swapFields(<group handle field 1>, <entry field 1>, <fieldTag1>, <group handle field 2>, <entry field 2>, <fieldTag2>)

Exchanges values of fields <fieldTag1> (from group <group handle field 1>[<entry field 1>]) and
<fieldTag2> (from group <group handle field 2>[<entry field 2>])

Note
Numeration of <entry field 1> and <entry field 2> starts with 0.

Example Code

hndl = getGroup(552);
isGroupValid(hndl);
swapFields(hndl, 1, 11, hndl, 1, 37);

Gets a handle on group 552 and tests whether handle 552 is valid

Exchanges values of field 11 in the second entry and field 37 in the first entry of group 552

...