Comments (0)

Files changed (3)

File lib/order.ml Modified

View file
  • Ignore whitespace
  • Hide word diff
 
 let ( = ) t1 t2 = Raw_order.(=) (to_raw t1) (to_raw t2)
 
-let order_type t = Order_type.t_of_tws t.Raw_order.order_type
+let order_type t = t.Raw_order.order_type
 let quantity t = t.Raw_order.quantity
 
 let buy_limit ~quantity limit_price =
   of_raw (
     Raw_order.create
-      ~action:"BUY"
-      ~order_type:"LMT"
+      ~action:`Buy
+      ~order_type:`Limit
       ~quantity
       ~limit_price
       ()
 let sell_limit ~quantity limit_price =
   of_raw (
     Raw_order.create
-      ~action:"SELL"
-      ~order_type:"LMT"
+      ~action:`Sell
+      ~order_type:`Limit
       ~quantity
       ~limit_price
       ()
 let buy_market ~quantity =
   of_raw (
     Raw_order.create
-      ~action:"BUY"
-      ~order_type:"MKT"
+      ~action:`Buy
+      ~order_type:`Market
       ~quantity
       ()
   )
 let sell_market ~quantity =
   of_raw (
     Raw_order.create
-      ~action:"SELL"
-      ~order_type:"MKT"
+      ~action:`Sell
+      ~order_type:`Market
       ~quantity
       ()
   )

File lib/raw_order.ml Modified

View file
  • Ignore whitespace
  • Hide word diff
 type t =
   { (* ===================== main order fields ==================== *)
     order_id : Order_id.t;
-    action : string;
+    action : Order_action.t;
     quantity : Volume.t;
-    order_type : string;
+    order_type : Order_type.t;
     limit_price : Price.t option;
     stop_price : Price.t option;
     (* ================== extended order fields =================== *)

File lib/submit_order.ml Modified

View file
  • Ignore whitespace
  • Hide word diff
     sec_id_type : Security_id.Type.t option;
     sec_id : Security_id.Id.t option;
     (* ====================== order fields ====================== *)
-    action : string;
+    action : Order_action.t;
     quantity : Volume.t;
-    order_kind : string;
+    order_kind : Order_type.t;
     limit_price : Price.t option;
     stop_price : Price.t option;
     time_in_force : Raw_order.Time_in_force.t option;
     right                           = contract.Raw_contract.right;
     multiplier                      = contract.Raw_contract.multiplier;
     exchange                        = contract.Raw_contract.exchange;
-    prim_exch                = contract.Raw_contract.prim_exch;
+    prim_exch                       = contract.Raw_contract.prim_exch;
     currency                        = contract.Raw_contract.currency;
     local_symbol                    = contract.Raw_contract.local_symbol;
     sec_id_type                     = contract.Raw_contract.sec_id_type;
           ~local_symbol:(fields_value (optional Symbol.val_type))
           ~sec_id_type:(fields_value (optional Security_id.Type.val_type))
           ~sec_id:(fields_value (optional Security_id.Id.val_type))
-          ~action:(fields_value (required string))
+          ~action:(fields_value (required Order_action.val_type))
           ~quantity:(fields_value (required Volume.val_type))
-          ~order_kind:(fields_value (required string))
+          ~order_kind:(fields_value (required Order_type.val_type))
           ~limit_price:(fields_value (optional Price.val_type ~default_on_none:"0.0"))
           ~stop_price:(fields_value (optional Price.val_type ~default_on_none:"0.0"))
           ~time_in_force:(fields_value (optional Raw_order.Time_in_force.val_type))
         ~local_symbol:(fields_value (optional Symbol.val_type))
         ~sec_id_type:(fields_value (optional Security_id.Type.val_type))
         ~sec_id:(fields_value (optional Security_id.Id.val_type))
-        ~action:(fields_value (required string))
+        ~action:(fields_value (required Order_action.val_type))
         ~quantity:(fields_value (required Volume.val_type))
-        ~order_kind:(fields_value (required string))
+        ~order_kind:(fields_value (required Order_type.val_type))
         ~limit_price:(fields_value (optional Price.val_type ~none_on_default:"0.0"))
         ~stop_price:(fields_value (optional Price.val_type ~none_on_default:"0.0"))
         ~time_in_force:(fields_value (optional Raw_order.Time_in_force.val_type))