Oliver Gu avatar Oliver Gu committed cb8519c

Fixed problem with ambigious contract description

The concrete error message was:
200 - The contract description specified for MSFT is ambiguous.

Comments (0)

Files changed (2)

examples/demultiplex.ml

 let print_market_data ~duration =
   Common.with_tws_client (fun tws ->
     let print_ticks symbol color =
-      Tws.market_data_exn tws ~contract:(Contract.stock ~currency:`USD symbol)
+      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)
       >>= 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.quote_snapshot_exn tws ~contract:stock)
+      Tws.contract_specs_exn tws ~contract:stock
+      >>= fun specs ->
+      (* extract unambigious contract description *)
+      let contract = Contract_specs.to_contract specs in
+      Tws.quote_snapshot_exn tws ~contract)
     >>| fun quotes -> print_quote_table quotes)
 
 let command =
Tip: Filter by directory path e.g. /media app.js to search for public/media/app.js.
Tip: Use camelCasing e.g. ProjME to search for ProjectModifiedEvent.java.
Tip: Filter by extension type e.g. /repo .js to search for all .js files in the /repo directory.
Tip: Separate your search with spaces e.g. /ssh pom.xml to search for src/ssh/pom.xml.
Tip: Use ↑ and ↓ arrow keys to navigate and return to view the file.
Tip: You can also navigate files with Ctrl+j (next) and Ctrl+k (previous) and view the file with Ctrl+o.
Tip: You can also navigate files with Alt+j (next) and Alt+k (previous) and view the file with Alt+o.