Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions fix-engine/src-core-pp/datetime_json.iml
Original file line number Diff line number Diff line change
Expand Up @@ -98,9 +98,9 @@ let utctimestamp_micro_decoder : fix_utctimestamp_micro Decoders_yojson.Basic.De
]

let utctimestamp_nano_to_json ( ts : fix_utctimestamp_nano ) =
ptime_to_json ts
ptime_to_json ts

let utctimestamp_nano_decoder : fix_utctimestamp_micro Decoders_yojson.Basic.Decode.decoder =
let utctimestamp_nano_decoder : fix_utctimestamp_nano Decoders_yojson.Basic.Decode.decoder =
ptime_decoder |> validate_with is_valid_utctimestamp_nano "fix_utctimestamp_nano"

let utctimestamp_pico_to_json ( ts : fix_utctimestamp_pico ) =
Expand Down
6 changes: 3 additions & 3 deletions fix-engine/src-core/datetime.iml
Original file line number Diff line number Diff line change
Expand Up @@ -125,9 +125,9 @@ let default_utctimestamp_milli : fix_utctimestamp_milli = T.epoch

let default_utctimestamp_micro : fix_utctimestamp_micro = T.epoch

let default_utctimestamp_nano : fix_utctimestamp_milli = T.epoch
let default_utctimestamp_nano : fix_utctimestamp_nano = T.epoch

let default_utctimestamp_pico : fix_utctimestamp_micro = T.epoch
let default_utctimestamp_pico : fix_utctimestamp_pico = T.epoch

(** Constructor for the UTC timestamp milli *)
let make_utctimestamp_milli (year : int) (month : int) (day : int) (hour : int)
Expand Down Expand Up @@ -281,7 +281,7 @@ let utctimestamp_Equal_milli_pico (t1 : fix_utctimestamp_milli)

let utctimestamp_Equal_micro_milli (t1 : fix_utctimestamp_micro)
(t2 : fix_utctimestamp_milli) =
T.equal (to_millis t2) t1
T.equal t2 (to_millis t1)

let utctimestamp_Equal_micro_nano (t1 : fix_utctimestamp_micro)
(t2 : fix_utctimestamp_nano) =
Expand Down
2 changes: 1 addition & 1 deletion fix-engine/src-protocol-pp/encode_full_messages.iml
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ let encode_msg_data msg =

type fix_encoder_config = {
begin_string: string;
encode_UTCTimestamp: Datetime.fix_utctimestamp_micro -> string;
encode_UTCTimestamp: Datetime.fix_utctimestamp_nano -> string;
}

let encode_header (config : fix_encoder_config) msg_tag msg =
Expand Down
6 changes: 3 additions & 3 deletions fix-engine/src-protocol-pp/fix_engine_json.iml
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ let manual_int_data_to_json x : Yojson.Basic.t = match x with

(** These are the messages going in/out of the engine to the owner. *)
let int_inc_msg_to_json x : Yojson.Basic.t = match x with
| IncIntMsg_TimeChange t -> `Assoc [ ( "TimeChange", `Assoc [ ( "new_time" , utctimestamp_micro_to_json t )] )]
| IncIntMsg_TimeChange t -> `Assoc [ ( "TimeChange", `Assoc [ ( "new_time" , utctimestamp_nano_to_json t )] )]
| IncIntMsg_CreateSession cs -> `Assoc [ ( "CreateSession", `Assoc [ ( "dest_comp_id" , `String cs.dest_comp_id )])]
| IncIntMsg_EndSession -> `String "EndSession"
| IncIntMsg_ApplicationData d -> `Assoc [ ( "ApplicationData", `Assoc [ ( "msg" , ( full_app_msg_to_json d) )] )]
Expand Down Expand Up @@ -133,7 +133,7 @@ let fix_engine_state_to_json utctimestamp_to_json s =
`Assoc [
( "curr_mode" , `String (fix_engine_mode_to_string s.fe_curr_mode) );
( "initiator" , bool_opt_to_json s.fe_initiator );
( "curr_time" , utctimestamp_micro_to_json s.fe_curr_time );
( "curr_time" , utctimestamp_nano_to_json s.fe_curr_time );
( "comp_id" , `String s.fe_comp_id );
( "target_comp_id" , `String s.fe_target_comp_id );
( "incoming_int_msgs" , int_inc_msg_opt_to_json s.incoming_int_msg );
Expand All @@ -144,7 +144,7 @@ let fix_engine_state_to_json utctimestamp_to_json s =
( "outgoing_fix_msgs" , full_top_level_msg_opt_to_json s.outgoing_fix_msg );
( "cache" , cache_entry_list_to_json s.fe_cache );
( "history" , full_msg_list_to_json s.fe_history );
( "last_hearbeat_received" , utctimestamp_micro_to_json s.fe_last_data_received );
( "last_hearbeat_received" , utctimestamp_nano_to_json s.fe_last_data_received );
( "heartbeat_interval" , duration_to_json s.fe_heartbeat_interval );
( "history_to_send" , full_msg_list_to_json s.fe_history_to_send );
( "application_up" , `Bool s.fe_application_up );
Expand Down
4 changes: 2 additions & 2 deletions fix-engine/src-protocol/full_messages.iml
Original file line number Diff line number Diff line change
Expand Up @@ -114,8 +114,8 @@ type fix_header = {
h_poss_dup_flag : bool option; (* Tag 43 *)

h_poss_resend : bool option; (* Tag 97 *)
h_sending_time : fix_utctimestamp_micro; (* Tag 52 *)
h_orig_sending_time : fix_utctimestamp_micro option; (* Tag 122 *)
h_sending_time : fix_utctimestamp_nano; (* Tag 52 *)
h_orig_sending_time : fix_utctimestamp_nano option; (* Tag 122 *)
h_xml_data_len : int option; (* Tag 212 *)
h_xml_data : int option; (* Tag 213 *)
h_message_encoding : int option; (* Tag 347 *)
Expand Down
4 changes: 2 additions & 2 deletions fix-engine/src-runtime/fix_io.ml
Original file line number Diff line number Diff line change
Expand Up @@ -76,8 +76,8 @@ end = struct
Lwt_io.(open_file ~flags ~mode:output s)

let get_time_string () =
Current_time.get_current_utctimestamp_micro ()
|> Encode_datetime.encode_UTCTimestamp_micro
Current_time.get_current_utctimestamp_nano ()
|> Encode_datetime.encode_UTCTimestamp_nano

let logfix oc logmsg =
let str = Printf.sprintf "[%s]: %s\n" (get_time_string ()) logmsg in
Expand Down
24 changes: 12 additions & 12 deletions fix-engine/src/fix_engine.iml
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,9 @@ let proc_incoming_int_msg ( x, engine : fix_engine_int_inc_msg * fix_engine_stat
if engine.fe_curr_mode = ActiveSession then
begin
(* First, check whether we need to send out a TestRequest message - if we haven't heard anything in a while *)
let received_cutoff = utctimestamp_micro_duration_Add engine.fe_last_data_received engine.fe_heartbeat_interval in
let received_cutoff_padded = utctimestamp_micro_duration_Add received_cutoff engine.fe_testreq_interval in
let received_cutoff_violated = utctimestamp_GreaterThan_micro_micro t received_cutoff_padded in
let received_cutoff = utctimestamp_nano_duration_Add engine.fe_last_data_received engine.fe_heartbeat_interval in
let received_cutoff_padded = utctimestamp_nano_duration_Add received_cutoff engine.fe_testreq_interval in
let received_cutoff_violated = utctimestamp_GreaterThan_nano_nano t received_cutoff_padded in

if received_cutoff_violated then
begin
Expand All @@ -48,8 +48,8 @@ let proc_incoming_int_msg ( x, engine : fix_engine_int_inc_msg * fix_engine_stat
else

(* If we have not sent out any data within the last heartbeat_int, need to send a Heatbeat message. *)
let sent_cutoff = utctimestamp_micro_duration_Add engine.fe_last_time_data_sent engine.fe_heartbeat_interval in
let sent_cutoff_violated = utctimestamp_GreaterThan_micro_micro t sent_cutoff in
let sent_cutoff = utctimestamp_nano_duration_Add engine.fe_last_time_data_sent engine.fe_heartbeat_interval in
let sent_cutoff_violated = utctimestamp_GreaterThan_nano_nano t sent_cutoff in

if sent_cutoff_violated && not ( hbeat_interval_null engine.fe_heartbeat_interval ) then
begin
Expand All @@ -67,9 +67,9 @@ let proc_incoming_int_msg ( x, engine : fix_engine_int_inc_msg * fix_engine_stat

else if engine.fe_curr_mode = WaitingForHeartbeat then
begin
let received_cutoff = utctimestamp_micro_duration_Add engine.fe_last_time_data_sent engine.fe_heartbeat_interval in
let received_cutoff_padded = utctimestamp_micro_duration_Add received_cutoff engine.fe_testreq_interval in
if utctimestamp_GreaterThan_micro_micro t received_cutoff_padded then
let received_cutoff = utctimestamp_nano_duration_Add engine.fe_last_time_data_sent engine.fe_heartbeat_interval in
let received_cutoff_padded = utctimestamp_nano_duration_Add received_cutoff engine.fe_testreq_interval in
if utctimestamp_GreaterThan_nano_nano t received_cutoff_padded then
begin
let logoff_msg = create_logoff_msg ( engine ) in {
engine' with
Expand All @@ -90,9 +90,9 @@ let proc_incoming_int_msg ( x, engine : fix_engine_int_inc_msg * fix_engine_stat
begin
(* Wait twice the heartbeat_interval, as recommended in the FIX Session Layer specification *)
let received_cutoff = engine.fe_last_time_data_sent
|> utctimestamp_micro_duration_Add engine.fe_heartbeat_interval
|> utctimestamp_micro_duration_Add engine.fe_heartbeat_interval in
if utctimestamp_GreaterThan_micro_micro t received_cutoff then
|> utctimestamp_nano_duration_Add engine.fe_heartbeat_interval
|> utctimestamp_nano_duration_Add engine.fe_heartbeat_interval in
if utctimestamp_GreaterThan_nano_nano t received_cutoff then
{
engine' with
fe_curr_mode = NoActiveSession;
Expand Down Expand Up @@ -250,7 +250,7 @@ let is_int_message_valid ( engine : fix_engine_state ) =
| None -> true
| Some int_msg ->
match int_msg with
| IncIntMsg_TimeChange t -> (utctimestamp_LessThan_micro_micro engine.fe_curr_time t ) && is_valid_utctimestamp_micro( t )
| IncIntMsg_TimeChange t -> (utctimestamp_LessThan_nano_nano engine.fe_curr_time t ) && is_valid_utctimestamp_nano( t )
| IncIntMsg_ApplicationData _d -> true
| IncIntMsg_TransportTermination -> true
| IncIntMsg_CreateSession _d ->
Expand Down
18 changes: 9 additions & 9 deletions fix-engine/src/fix_engine_state.iml
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ type session_data = {

(** These are internal messages into the Engine. *)
type fix_engine_int_inc_msg =
| IncIntMsg_TimeChange of fix_utctimestamp_micro
| IncIntMsg_TimeChange of fix_utctimestamp_nano
(** Updates internal time of the engine. *)
| IncIntMsg_CreateSession of session_data (** Create sessions command. *)
| IncIntMsg_EndSession (** Terminate current active session. *)
Expand Down Expand Up @@ -122,7 +122,7 @@ type fix_engine_state = {
(** initiator = True if we've received an internal message to initiate
the connection. It's False if we've received a Logon request first.
It's None by default prior to any Logon sequences. *)
fe_curr_time: fix_utctimestamp_micro;
fe_curr_time: fix_utctimestamp_nano;
(** Need to define time so we're aware of heartbeat status. *)
fe_comp_id: string; (** Our company ID *)
fe_target_comp_id: string; (** Target company ID *)
Expand All @@ -142,9 +142,9 @@ type fix_engine_state = {
(** Maintain a cache of messages in case we detect out-of-sequence message(s). *)
fe_history: full_valid_fix_msg list;
(** We maintain history of our outgoing messages in case we're asked to retransmit. *)
fe_last_time_data_sent: fix_utctimestamp_micro;
fe_last_time_data_sent: fix_utctimestamp_nano;
(** Last time we sent out data to the corresponding engine *)
fe_last_data_received: fix_utctimestamp_micro;
fe_last_data_received: fix_utctimestamp_nano;
(** Last time we received a heartbeat or other message. *)
fe_heartbeat_interval: fix_duration; (** Negotiated heartbeat interval. *)
fe_testreq_interval: fix_duration;
Expand Down Expand Up @@ -235,12 +235,12 @@ let engine_state_busy engine =
we need to maintain that every state transition from a valid state
would result in another valid state. *)
let is_state_valid (engine : fix_engine_state) =
utctimestamp_LessThanEqual_micro_micro engine.fe_last_data_received
utctimestamp_LessThanEqual_nano_nano engine.fe_last_data_received
engine.fe_curr_time
&& utctimestamp_LessThanEqual_micro_micro engine.fe_last_time_data_sent
&& utctimestamp_LessThanEqual_nano_nano engine.fe_last_time_data_sent
engine.fe_curr_time
&& is_valid_utctimestamp_micro engine.fe_curr_time
&& is_valid_utctimestamp_micro engine.fe_last_time_data_sent
&& is_valid_utctimestamp_micro engine.fe_last_data_received
&& is_valid_utctimestamp_nano engine.fe_curr_time
&& is_valid_utctimestamp_nano engine.fe_last_time_data_sent
&& is_valid_utctimestamp_nano engine.fe_last_data_received
&& is_valid_duration engine.fe_heartbeat_interval
&& is_valid_duration engine.fe_testreq_interval
4 changes: 2 additions & 2 deletions fix-engine/src/fix_engine_utils.iml
Original file line number Diff line number Diff line change
Expand Up @@ -359,8 +359,8 @@ let validate_message_header ( engine, msg_header, msg_tag : fix_engine_state * f
let engine = session_reject ( reject , engine ) in
let msg =
let open Encode_datetime in
let send_time = encode_UTCTimestamp_micro msg_header.h_sending_time in
let orig_send_time = encode_UTCTimestamp_micro orig_sending_time in
let send_time = encode_UTCTimestamp_nano msg_header.h_sending_time in
let orig_send_time = encode_UTCTimestamp_nano orig_sending_time in
CCFormat.asprintf "SendingTime(%s) is before OrigSendingTime(%s)" send_time orig_send_time in
Some { engine with
fe_curr_mode = ShuttingDown (Error "SendingTime is before OrigSendingTime");
Expand Down