1. Oliver Gu
  2. ibx

Commits

Oliver Gu  committed 6daf567

Renamed example

  • Participants
  • Parent commits d6e4137
  • Branches master

Comments (0)

Files changed (5)

File _oasis

View file
   BuildDepends:   ibx
   CompiledObject: best
 
-Executable "show-contract-specs"
+Executable "show-contract-details"
   Build$:         flag(examples)
   Path:           examples
-  MainIs:         show_contract_specs.ml
+  MainIs:         show_contract_details.ml
   Install:        false
   BuildDepends:   ibx
   CompiledObject: best

File _tags

View file
 # OASIS_START
-# DO NOT EDIT (digest: 47edbb26a464e27295966367d7ab00d2)
+# DO NOT EDIT (digest: b9841ba622f93363f0645f700e533358)
 # Ignore VCS directories, you can use the same kind of rule outside 
 # OASIS_START/STOP if you want to exclude directories that contains 
 # useless stuff for the build process
 <examples/server_time.{native,byte}>: pkg_textutils
 <examples/server_time.{native,byte}>: pkg_threads
 <examples/server_time.{native,byte}>: pkg_str
-# Executable show-contract-specs
-<examples/show_contract_specs.{native,byte}>: use_ibx
-<examples/show_contract_specs.{native,byte}>: pkg_core
-<examples/show_contract_specs.{native,byte}>: pkg_async
-<examples/show_contract_specs.{native,byte}>: pkg_sexplib.syntax
-<examples/show_contract_specs.{native,byte}>: pkg_fieldslib.syntax
-<examples/show_contract_specs.{native,byte}>: pkg_textutils
-<examples/show_contract_specs.{native,byte}>: pkg_threads
-<examples/show_contract_specs.{native,byte}>: pkg_str
+# Executable show-contract-details
+<examples/show_contract_details.{native,byte}>: use_ibx
+<examples/show_contract_details.{native,byte}>: pkg_core
+<examples/show_contract_details.{native,byte}>: pkg_async
+<examples/show_contract_details.{native,byte}>: pkg_sexplib.syntax
+<examples/show_contract_details.{native,byte}>: pkg_fieldslib.syntax
+<examples/show_contract_details.{native,byte}>: pkg_textutils
+<examples/show_contract_details.{native,byte}>: pkg_threads
+<examples/show_contract_details.{native,byte}>: pkg_str
 # Executable submit-orders
 <examples/submit_orders.{native,byte}>: use_ibx
 <examples/submit_orders.{native,byte}>: pkg_core

File examples/show_contract_details.ml

View file
+open Core.Std
+open Async.Std
+open Ibx.Std
+
+let contracts : Contract.Type.t Contract.t list = [
+  Contract.stock ~currency:`USD (Symbol.of_string "AAPL");
+  Contract.stock ~currency:`EUR (Symbol.of_string "BMW");
+
+  (* For current contracts check:
+     http://www.cmegroup.com/trading/equity-index/us-index/
+     e-mini-sandp500_product_calendar_futures.html
+  *)
+  Contract.futures
+    ~exchange:`GLOBEX
+    ~currency:`USD
+    ~expiry:(Date.create_exn ~y:2014 ~m:Month.Mar ~d:21)
+    (Symbol.of_string "ES");
+
+  (* For current contracts check: http://finance.yahoo.com/q/op?s=GOOG *)
+  Contract.option
+    ~exchange:`CBOE
+    ~currency:`USD
+    ~option_right:`Call
+    ~expiry:(Date.create_exn ~y:2013 ~m:Month.Jun ~d:21)
+    ~strike:(Price.of_float 850.)
+    (Symbol.of_string "GOOG");
+
+  Contract.forex
+    ~exchange:`IDEALPRO
+    ~currency:`JPY
+    (Symbol.of_string "USD");
+]
+
+let run () =
+  Common.with_tws_client (fun tws ->
+    Deferred.List.iter contracts ~f:(fun contract ->
+      let symbol = Symbol.to_string (Contract.symbol contract) in
+      let message s =
+        printf "===== [ %s ] =====\n" symbol;
+        print_endline s;
+        print_newline ()
+      in
+      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 details) ->
+        message (Contract_details.sexp_of_t details |> Sexp.to_string_hum))
+  )
+
+let command =
+  Command.async_basic ~summary:"show contract details"
+    Command.Spec.(
+      empty
+      +> Common.logging_flag ()
+      +> Common.host_arg ()
+      +> Common.port_arg ()
+    )
+    (fun enable_logging host port () ->
+      run ~enable_logging ~host ~port ()
+      >>= function
+      | Error e -> prerr_endline (Error.to_string_hum e); exit 1
+      | Ok () -> return ()
+    )
+
+let () = Command.run command

File examples/show_contract_specs.ml

-open Core.Std
-open Async.Std
-open Ibx.Std
-
-let contracts : Contract.Type.t Contract.t list = [
-  Contract.stock ~currency:`USD (Symbol.of_string "AAPL");
-  Contract.stock ~currency:`EUR (Symbol.of_string "BMW");
-
-  (* For current contracts check:
-     http://www.cmegroup.com/trading/equity-index/us-index/
-     e-mini-sandp500_product_calendar_futures.html
-  *)
-  Contract.futures
-    ~exchange:`GLOBEX
-    ~currency:`USD
-    ~expiry:(Date.create_exn ~y:2014 ~m:Month.Mar ~d:21)
-    (Symbol.of_string "ES");
-
-  (* For current contracts check: http://finance.yahoo.com/q/op?s=GOOG *)
-  Contract.option
-    ~exchange:`CBOE
-    ~currency:`USD
-    ~option_right:`Call
-    ~expiry:(Date.create_exn ~y:2013 ~m:Month.Jun ~d:21)
-    ~strike:(Price.of_float 850.)
-    (Symbol.of_string "GOOG");
-
-  Contract.forex
-    ~exchange:`IDEALPRO
-    ~currency:`JPY
-    (Symbol.of_string "USD");
-]
-
-let run () =
-  Common.with_tws_client (fun tws ->
-    Deferred.List.iter contracts ~f:(fun contract ->
-      let symbol = Symbol.to_string (Contract.symbol contract) in
-      let message s =
-        printf "===== [ %s ] =====\n" symbol;
-        print_endline s;
-        print_newline ()
-      in
-      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 details) ->
-        message (Contract_details.sexp_of_t details |> Sexp.to_string_hum))
-  )
-
-let command =
-  Command.async_basic ~summary:"show contract details"
-    Command.Spec.(
-      empty
-      +> Common.logging_flag ()
-      +> Common.host_arg ()
-      +> Common.port_arg ()
-    )
-    (fun enable_logging host port () ->
-      run ~enable_logging ~host ~port ()
-      >>= function
-      | Error e -> prerr_endline (Error.to_string_hum e); exit 1
-      | Ok () -> return ()
-    )
-
-let () = Command.run command

File setup.ml

View file
 (* setup.ml generated for the first time by OASIS v0.2.0 *)
 
 (* OASIS_START *)
-(* DO NOT EDIT (digest: 4cd7fa68e8658faeadfe5421524a5466) *)
+(* DO NOT EDIT (digest: 98aba7c6075478480cad2c26fbcc3954) *)
 (*
    Regenerated by OASIS v0.3.0
    Visit http://oasis.forge.ocamlcore.org for more information and
                    {exec_custom = false; exec_main_is = "server_time.ml"; });
                Executable
                  ({
-                     cs_name = "show-contract-specs";
+                     cs_name = "show-contract-details";
                      cs_data = PropList.Data.create ();
                      cs_plugin_data = [];
                      },
                       },
                    {
                       exec_custom = false;
-                      exec_main_is = "show_contract_specs.ml";
+                      exec_main_is = "show_contract_details.ml";
                       });
                Executable
                  ({
           };
      oasis_fn = Some "_oasis";
      oasis_version = "0.3.0";
-     oasis_digest = Some "\242[b\220p\220\142w1\186\"u\205_15";
+     oasis_digest = Some "\235r\169\177},eQ{u\004o\160hrZ";
      oasis_exec = None;
      oasis_setup_args = [];
      setup_update = false;