Creating a Signature

The signature is created by concatenating

  • SendingTime (52) as a string

  • ASCII 01 value

  • SeqNum (34) as a string

  • ASCII 01 value

  • SenderCompID (49)

  • ASCII 01 value

  • TargetCompID (56)

    This string is then signed using the HMAC SHA-256 Algorithm and the API Secret for the API Key. Sample Java code showing how this can be done programmatically. Note this sample relies on Apache Commons-Codec and QuickFIX for Java


/**
* Takes a Message, an apiKey and apiSecret and uses the HMAC-SHA256
* algorithm to sign a FIX message by appending
* the sending-time sequenceNumber, SenderCompID and TargetCompID with
* \u0001 separator and signing using the
* secret, putting it into the RawBytes in Base64 encoding.
*/
private static void signLogon(final Message message,
                              final SessionID sessionId,
                              final String apiKey,
                              final String apiSecret) throws FieldNotFound {
    final var senderCompId = sessionId.getSenderCompID();
    final var targetCompId = sessionId.getTargetCompID();
    final var sendingTime = message.getString(SendingTime.FIELD);
    final var seqNum = message.getInt(MsgSeqNum.FIELD);
    final var sep = "\u0001";
    final var hmac = sign(apiSecret, sendingTime + sep + seqNum + sep +
            senderCompId + sep + targetCompId);
    message.setString(Password.FIELD, apiKey);
    message.setInt(RawDataLength.FIELD, hmac.length());
    message.setString(RawData.FIELD, hmac);
}

private static String sign(final String apiSecret, final String data) {
    final var mac = HmacUtils.getInitializedMac(HmacAlgorithms.HMAC_SHA_256,
            apiSecret.getBytes());
    final var encodedBytes = mac.doFinal(data.getBytes());
    final var encoder = Base64.getUrlEncoder();//URL Safe Base64
    return encoder.encodeToString(encodedBytes);
}

Heartbeat

TagField NameReq'dComments
<MessageHeader>YMsgType <35> = 0
112TestReqIDYRequired when the heartbeat is the result of a Test Request message
<MessageTrailer>Y

Test Request

TagField NameReq'dComments
<MessageHeader>YMsgType <35> = 1
112TestReqIDY
<MessageTrailer>Y

Resend Request

TagField NameReq'dComments
<MessageHeader>YMsgType <35> = 2
7BeginSeqNoY
16EndSeqNoY
<MessageTrailer>Y

Reject

TagField NameReq'dComments
<MessageHeader>YMsgType <35> = 3
45RefSeqNumYMsgSeqNum of rejected message
371RefTagIDNThe tag number of the FIX field being referenced
372RefMsgTypeNThe MsgType of the FIX message being referenced
373SessionRejectReasonNCode to identify reason for a session-level Reject message
58TextNWhere possible, message to explain reason for rejection
<MessageTrailer>Y

Sequence Reset

TagField NameReq'dComments
<MessageHeader>YMsgType <35> = 4
123GapFillFlagN
36NewSeqNoY
<MessageTrailer>Y

Logout

TagField NameReq'dComments
<MessageHeader>YMsgType <35> = 5
58TextN
<MessageTrailer>Y