Activate the `verify` plugin to use this feature
 
require 'ib-api' 
ib= IB::Connection.new            # Connect to the TWS
ib.activate_plugin 'verify'       # Activate the Plugin
ib.try_connection!
puts IB::Stock.new( symbol: 'T' ).verify.as_table

┌───────┬────────┬──────────┬──────────┬───────────────┬──────────┐
│       │ symbol │ con_id   │ exchange │ trading-class │ currency │
╞═══════╪════════╪══════════╪══════════╪═══════════════╪══════════╡
│ Stock │ T      │ 37018770 │  SMART   │       T       │   USD    │
└───────┴────────┴──────────┴──────────┴───────────────┴──────────┘

Contract#verify

To ease the process of verification of given contract-attributes, a handy verify method is provided.

  w =  IB::Symbols::Stocks.wfc
  w.con_id                       => 0 
  ww = w.verify.first
  ww.con_id                      => 10375 
  ww.contract_detail.long_name   => "WELLS FARGO & CO" 

IB::Contract.verify sends a :RequestContractData-Message, fetches the response and extracts IB::Contracts. It returns an array of qualified IB::Contracts.

Manipulations of the response

Contract#verify accepts a block to to manipulate the received contract.

 f =  IB::Symbols::Options.stoxx.mini_dax.merge expiry: 0  #  unset expiry
 dax_con_ids =  f.verify do |c| 
     { c.expiry => c.con_id } if c.last_trading_day =~ /#{Date.today.year}/
   end.compact
 => [{"20240920"=>540729524}, {"20241220"=>540729531}]
Tags: