Module Fix_engine_utils

FIX 4.4 engine utility functions.

val msg_is_sequence_gap : (Fix_engine_state.fix_engine_state * Full_messages.fix_header) -> bool

If sequence number is too high, then we need to transfer into Recovery Mode and request the missing sequence to be retransmitted.

val get_historic_msg : Full_messages.full_valid_fix_msg -> Full_messages.full_valid_fix_msg

get_gap_fill_msg -> out of all of the administrative messages, only the 'Reject' can be retransmitted. All application-level messages may be retransmitted - we should, in the future add logic to not retransmit stale orders, etc.

val get_critical_reset_seq_num : Full_messages.full_msg_data -> Imandra_prelude.int option

This function returns a new sequence number if we got a SequenceReset without GapFill flag. Returns None in all other cases.

val combine_gapfill_msgs : (Full_admin_messages.full_msg_sequence_reset_data * Full_admin_messages.full_msg_sequence_reset_data) -> Full_admin_messages.full_msg_sequence_reset_data

Give us a single GapFill message with the correct NextSequenceNumber.

From the specification: "If there are consecutive administrative messages to be resent, it is suggested that only one SeqReset-GapFill message be sent in their place. The sequence number of the SeqReset-GapFill message is the next expected outbound sequence number. The NewSeqNo field of the GapFill message contains the sequence number of the highest administrative message in this group plus 1. For example, during a Resend operation there are 7 sequential administrative messages waiting to be resent. They start with sequence number 9 and end with sequence number 15. Instead of transmitting 7 Gap Fill messages (which is perfectly legal, but not network friendly), a SeqReset-GapFill message may be sent. The sequence number of the Gap Fill message is set to 9 because the remote side is expecting that as the next sequence number. The NewSeqNo field of the GapFill message contains the number 16, because that will be the sequence number of the next message to be transmitted."

val add_msg_to_history : (Full_messages.full_valid_fix_msg list * Full_messages.full_valid_fix_msg) -> Full_messages.full_valid_fix_msg list

Adding a valid message to the list, while

  • converting any message that needs to be converted into a SequenceRest-GapFill
  • ensuring that any two sequential SequenceReset-GapFill messages are combined into one with an updated expected NextSeqNum parameter
val create_outbound_fix_msg : (Z.t * Imandra_prelude.string * Imandra_prelude.string * TimeDefaults.fix_utctimestamp * Full_messages.full_msg_data * bool) -> Full_messages.full_valid_fix_msg

Create outbound FIX message with the appropriate header and trailer.

val create_logon_msg : (Fix_engine_state.fix_engine_state * bool) -> Full_messages.full_valid_fix_msg

Create a logon message we would send out to initiate a connection with another FIX engine.

val create_logoff_msg : Fix_engine_state.fix_engine_state -> Full_messages.full_valid_fix_msg

Create a Logoff message.

val create_heartbeat_msg : (Fix_engine_state.fix_engine_state * Imandra_prelude.string option) -> Full_messages.full_valid_fix_msg

Create a heartbeat message

val create_test_request_msg : Fix_engine_state.fix_engine_state -> Full_messages.full_valid_fix_msg

Create Test Request message.

val create_resend_request_msg : Fix_engine_state.fix_engine_state -> Full_messages.full_valid_fix_msg

Create Resend Request message.

val create_session_reject_msg : (Imandra_prelude.int * Imandra_prelude.string * Imandra_prelude.string * TimeDefaults.fix_utctimestamp * Full_messages.session_rejected_msg_data) -> Full_messages.full_valid_fix_msg

Create session-rejection message.

val create_business_reject_msg : (Imandra_prelude.int * Imandra_prelude.string * Imandra_prelude.string * TimeDefaults.fix_utctimestamp * Full_messages.biz_rejected_msg_data) -> Full_messages.full_valid_fix_msg

Create business reject message. Note: the reason we're separating the ApplicationDown reason is that the parser would not have access to this information.

val noop : (Full_messages.full_valid_fix_msg * Fix_engine_state.fix_engine_state) -> Fix_engine_state.fix_engine_state

A NO-OPeration

val business_reject : (Full_messages.biz_rejected_msg_data * Fix_engine_state.fix_engine_state) -> Fix_engine_state.fix_engine_state

Convert the rejection information into an outbound BusinessReject message.

val session_reject : (Full_messages.session_rejected_msg_data * Fix_engine_state.fix_engine_state) -> Fix_engine_state.fix_engine_state

Convert the rejection information into an outbound Reject message.

val field_null : Imandra_prelude.int option -> bool
val hbeat_interval_null : Datetime.fix_duration -> bool
val validate_message_header : (Fix_engine_state.fix_engine_state * Full_messages.fix_header * Full_message_tags.full_msg_tag) -> Fix_engine_state.fix_engine_state option

Check the message header ( presence and value of the OrigSendingTime ) returns None if no problems are found.