Commits

Oliver Gu committed d6e4137

Contract_specs -> Contract_details

Comments (0)

Files changed (19)

examples/demultiplex.ml

   Common.with_tws_client (fun tws ->
     let print_ticks symbol color =
       let stock = Contract.stock ~currency:`USD symbol in
-      Tws.contract_specs_exn tws ~contract:stock
-      >>= fun specs ->
-      Tws.market_data_exn tws ~contract:(Contract_specs.to_contract specs)
+      Tws.contract_details_exn tws ~contract:stock
+      >>= fun details ->
+      Tws.market_data_exn tws ~contract:(Contract_details.to_contract details)
       >>= fun (ticks, id) ->
       upon (Clock.after duration) (fun () -> Tws.cancel_market_data tws id);
       Pipe.iter ticks ~f:(unstage (make_tick_printer ~id ~symbol ~color))

examples/quote_table.ml

         ~currency:`USD
         (Symbol.of_string symbol)
       in
-      Tws.contract_specs_exn tws ~contract:stock
-      >>= fun specs ->
-      (* extract unambigious contract description *)
-      let contract = Contract_specs.to_contract specs in
+      Tws.contract_details_exn tws ~contract:stock
+      >>= fun details ->
+      (* extract unambiguous contract description *)
+      let contract = Contract_details.to_contract details in
       Tws.quote_snapshot_exn tws ~contract)
     >>| fun quotes -> print_quote_table quotes)
 

examples/show_contract_specs.ml

         print_endline s;
         print_newline ()
       in
-      Tws.contract_specs tws ~contract >>| function
+      Tws.contract_details tws ~contract >>| function
       | Error e ->
         message (Error.to_string_hum e)
       | Ok (Error tws_error) ->
         message (Tws_error.to_string_hum tws_error)
-      | Ok (Ok con_specs) ->
-        message (Contract_specs.sexp_of_t con_specs |> Sexp.to_string_hum))
+      | Ok (Ok details) ->
+        message (Contract_details.sexp_of_t details |> Sexp.to_string_hum))
   )
 
 let command =
-  Command.async_basic ~summary:"show contract specifications"
+  Command.async_basic ~summary:"show contract details"
     Command.Spec.(
       empty
       +> Common.logging_flag ()
 end
 
 (* +-----------------------------------------------------------------------+
-   | Contract specs                                                        |
+   | Contract details                                                      |
    +-----------------------------------------------------------------------+ *)
 
-module Contract_specs = struct
+module Contract_details = struct
   type t = Raw_contract.t with sexp
 
   let create ~contract = Contract.to_raw contract
   let ( = ) t1 t2 = Raw_contract.(=) t1 t2
 
   let pickler =
-    Pickler.create ~name:"Query.Contract_specs"
-      (Raw_contract.Pickler_specs.contract_specs_query ())
+    Pickler.create ~name:"Query.Contract_details"
+      (Raw_contract.Pickler_specs.contract_details_query ())
 
   let unpickler = Only_in_test.of_thunk (fun () ->
-    Unpickler.create ~name:"Query.Contract_specs"
-      (Raw_contract.Unpickler_specs.contract_specs_query ())
+    Unpickler.create ~name:"Query.Contract_details"
+      (Raw_contract.Unpickler_specs.contract_details_query ())
       Fn.id)
 end
 
     -> t
 end
 
-(** {1 Contract specs} *)
+(** {1 Contract details} *)
 (*****************************************************************************)
 
-module Contract_specs : sig
+module Contract_details : sig
   type t with sexp
   include Query_intf.S with type t := t
   val create : contract:[< Contract.Type.t ] Contract.t -> t

lib/raw_contract.ml

         ~combo_legs:(fields_value skipped))
     |> wrap_contract_spec
 
-  let contract_specs_query () =
+  let contract_details_query () =
     Pickler.Spec.(
       Fields.fold
         ~init:(empty ())
       ++ value (optional Symbol.val_type)
         ~name:(field_name Fields.local_symbol))
 
-  let contract_specs_query () =
+  let contract_details_query () =
     Unpickler.Spec.(
       step (fun conv id symbol contract_type expiry strike option_right
         multiplier exchange currency local_symbol include_expired
 end
 
 (* +-----------------------------------------------------------------------+
-   | Contract specs                                                        |
+   | Contract details                                                      |
    +-----------------------------------------------------------------------+ *)
 
-module Contract_specs = struct
+module Contract_details = struct
   type t =
     { symbol : Symbol.t;
       contract_type : Contract.Type.t;
       ~liquid_hours:(use (=))
 
   let unpickler =
-    Unpickler.create ~name:"Response.Contract_specs"
+    Unpickler.create ~name:"Response.Contract_details"
       Unpickler.Spec.(
         Fields.fold
           ~init:(empty ())
           })
 
   let pickler = Only_in_test.of_thunk (fun () ->
-    Pickler.create ~name:"Response.Contract_specs"
+    Pickler.create ~name:"Response.Contract_details"
       Pickler.Spec.(
         wrap (
           Fields.fold
     -> t
 end
 
-(** {1 Contract specs} *)
+(** {1 Contract details} *)
 (*****************************************************************************)
 
-module Contract_specs : sig
+module Contract_details : sig
   type t = private
     { symbol : Symbol.t;
       contract_type : Contract.Type.t;
 module Portfolio_update  = Response.Portfolio_update
 module Execution_report  = Response.Execution_report
 module Commission_report = Response.Commission_report
-module Contract_specs    = Response.Contract_specs
+module Contract_details  = Response.Contract_details
 module Book_update       = Response.Book_update
 module Historical_data   = Response.Historical_data
 module Realtime_bar      = Response.Realtime_bar
   | Ok pipe_r -> Pipe.map pipe_r ~f:Tws_result.ok_exn
 
 (* +-----------------------------------------------------------------------+
-   | Contract specs                                                        |
+   | Contract details                                                      |
    +-----------------------------------------------------------------------+ *)
 
-let contract_specs t ~contract =
+let contract_details t ~contract =
   with_connection t ~f:(fun con ->
-    let q = Query.Contract_specs.create ~contract in
-    dispatch_and_cancel Tws_reqs.req_contract_specs con q
+    let q = Query.Contract_details.create ~contract in
+    dispatch_and_cancel Tws_reqs.req_contract_details con q
   )
 
-let contract_specs_exn t ~contract =
-  contract_specs t ~contract >>| function
+let contract_details_exn t ~contract =
+  contract_details t ~contract >>| function
   | Error e -> raise (Error.to_exn e)
   | Ok result -> Tws_result.ok_exn result
 
   -> (Execution_report.t Pipe.Reader.t) Deferred.t
 
 
-(** {1 Contract specifications} *)
+(** {1 Contract details} *)
 (******************************************************************************)
 
-val contract_specs
+val contract_details
   :  t
   -> contract:[< `Stock | `Futures | `Option | `Forex ] Contract.t
-  -> Contract_specs.t Tws_result.t Or_error.t Deferred.t
+  -> Contract_details.t Tws_result.t Or_error.t Deferred.t
 
-val contract_specs_exn
+val contract_details_exn
   :  t
   -> contract:[< `Stock | `Futures | `Option | `Forex ] Contract.t
-  -> Contract_specs.t Deferred.t
+  -> Contract_details.t Deferred.t
 
 
 (** {1 Market depth} *)
     U.map Response.Tick_option.unpickler ~f:Response.Tick_option.implied_volatility;
   ] ()
 
-(* ===================== Contract specs ========================= *)
+(* ===================== Contract details ========================= *)
 
-let req_contract_specs = Ib.Streaming_request.create
+let req_contract_details = Ib.Streaming_request.create
   ~send_header:(Ib.Header.create ~tag:S.Contract_data ~version:6)
   ~recv_header:[Ib.Header.create ~tag:R.Contract_data ~version:8]
   ~skip_header:[Ib.Header.create ~tag:R.Contract_data_end ~version:1]
-  ~tws_query:Query.Contract_specs.pickler
-  ~tws_response:[Response.Contract_specs.unpickler]
+  ~tws_query:Query.Contract_details.pickler
+  ~tws_response:[Response.Contract_details.unpickler]
   ()
 
 (* ========================== Orders ============================== *)
 val req_implied_volatility :
   (Query.Implied_volatility.t, float option) Ib.Streaming_request.t
 
-(** {1 Contract specs} *)
+(** {1 Contract details} *)
 (*****************************************************************************)
 
-val req_contract_specs :
-  (Query.Contract_specs.t, Response.Contract_specs.t) Ib.Streaming_request.t
+val req_contract_details :
+  (Query.Contract_details.t, Response.Contract_details.t) Ib.Streaming_request.t
 
 (** {1 Orders} *)
 (*****************************************************************************)

lib_test/client_test.ml

     )
   );
 
-  "contract-specs" >:: (fun () ->
+  "contract-details" >:: (fun () ->
     with_tws_client (fun tws ->
-      let module R = Response.Contract_specs in
-      let gen_contract_specs = Lazy.force Gen.contract_specs in
-      Tws.contract_specs_exn tws ~contract:(Rg.contract_g ())
-      >>| fun contract_specs ->
+      let module R = Response.Contract_details in
+      let gen_contract_details = Lazy.force Gen.contract_details in
+      Tws.contract_details_exn tws ~contract:(Rg.contract_g ())
+      >>| fun contract_details ->
       assert_response_equal
         (module R : Response_intf.S with type t = R.t)
-        ~expected:gen_contract_specs
-        ~actual:contract_specs;
-      Log.Global.sexp ~level:`Debug contract_specs R.sexp_of_t
+        ~expected:gen_contract_details
+        ~actual:contract_details;
+      Log.Global.sexp ~level:`Debug contract_details R.sexp_of_t
     )
   );
 
 let tick_option       = lazy (tick_option_g ())
 let order_states      = lazy (order_states_g ())
 let execution_reports = lazy (execution_reports_g ())
-let contract_specs    = lazy (contract_specs_g ())
+let contract_details  = lazy (contract_details_g ())
 let book_updates      = lazy (book_updates_g ())
 let historical_data   = lazy (historical_data_g ())
 let realtime_bars     = lazy (realtime_bars_g ())
 val tick_option       : Tick_option.t Lazy.t
 val order_states      : Order_status.t list Lazy.t
 val execution_reports : Execution_report.t list Lazy.t
-val contract_specs    : Contract_specs.t Lazy.t
+val contract_details  : Contract_details.t Lazy.t
 val book_updates      : Book_update.t list Lazy.t
 val historical_data   : Historical_data.t Lazy.t
 val realtime_bars     : Realtime_bar.t list Lazy.t

lib_test/pickle_test.ml

       let module Q = Query.Execution_reports in
       gen_test (module Q : Query_intf.S with type t = Q.t) Rg.Q.execution_reports_g);
 
-    (* ========================== Contract specs =========================== *)
+    (* ========================= Contract details ========================== *)
 
     (fun () ->
-      let module Q = Query.Contract_specs in
-      gen_test (module Q : Query_intf.S with type t = Q.t) Rg.Q.contract_specs_g);
+      let module Q = Query.Contract_details in
+      gen_test (module Q : Query_intf.S with type t = Q.t) Rg.Q.contract_details_g);
 
     (* =========================== Market depth ============================ *)
 
       let module R = Response.Portfolio_update in
       gen_test (module R : Response_intf.S with type t = R.t) Rg.R.portfolio_update_g);
 
-    (* ========================== Contract specs =========================== *)
+    (* ========================= Contract details ========================== *)
 
     (fun () ->
-      let module R = Response.Contract_specs in
-      gen_test (module R : Response_intf.S with type t = R.t) Rg.R.contract_specs_g);
+      let module R = Response.Contract_details in
+      gen_test (module R : Response_intf.S with type t = R.t) Rg.R.contract_details_g);
 
     (* =========================== Executions ============================== *)
 
 
   val execution_reports_g : Query.Execution_reports.t gen
 
-  (* Contract data *)
+  (* Contract details *)
 
-  val contract_specs_g : Query.Contract_specs.t gen
+  val contract_details_g : Query.Contract_details.t gen
 
   (* Market depth *)
 
       ~time:(tmg ())
       ~order_action:(order_action_g ())
 
-  (* =========================== Contract specs ============================ *)
+  (* ========================== Contract details =========================== *)
 
-  let contract_specs_g () =
+  let contract_details_g () =
     let contract_g () =
       Contract.futures
         ~multiplier:(sg ())
         ~expiry:(expiry_g ())
         (symbol_g ())
     in
-    Query.Contract_specs.create ~contract:(contract_g ())
+    Query.Contract_details.create ~contract:(contract_g ())
 
   (* ============================ Market depth ============================= *)
 
   val account_update_g   : Response.Account_update.t gen
   val portfolio_update_g : Response.Portfolio_update.t gen
 
-  (* Contract specs *)
+  (* Contract details *)
 
-  val contract_specs_g : Response.Contract_specs.t gen
+  val contract_details_g : Response.Contract_details.t gen
 
   (* Executions *)
 
 
   (* ============================ Contract specs =========================== *)
 
-  let contract_specs_g () =
+  let contract_details_g () =
     let contract_type_g () = oneof [
       always (`Stock);
       always (`Option);
       always (`Futures);
     ] ()
     in
-    Response.Contract_specs.create
+    Response.Contract_details.create
       ~symbol:(symbol_g ())
       ~contract_type:(contract_type_g ())
       ~expiry:(og expiry_g ())

lib_test/simulation_server.ml

               data     = "";
             }]
 
-        (* ======================= Contract specs ======================== *)
+        (* ====================== Contract details ======================= *)
 
         | S.Contract_data ->
-          let pickler = Only_in_test.force R.Contract_specs.pickler in
+          let pickler = Only_in_test.force R.Contract_details.pickler in
           [ E.Server_response {
             Response.
             tag      = V.Contract_data;
             version  = 8;
             query_id = query.Query.id;
-            data     = to_tws pickler (Lazy.force Gen.contract_specs) }
+            data     = to_tws pickler (Lazy.force Gen.contract_details) }
           ; E.Server_response {
             Response.
             tag      = V.Contract_data_end;