To experiment with the API, a preconfigured interactive irb-console is provided

Install the console in your project

This is easily obtained by copying the bin-directory form the ib-api gem to the project-dir

 $ cd {your project}
 $ ib_gem=`bundle info --path ib-api`
 $ cp -r $ib_gem/bin  .

Include require [your_project_name] to the scripts.

Run the console

Without parameters it connects to a running Gateway-Application on localhost.
The GUI-Version (TWS) is addressed by calling ./console tws from the command line..

:gateway:  4002
:tws: 7496
:client_id: 2000

Edit the file and ensure that the ports chosen are equal to those specified in the API-section of the configuration of TWS/Gateway:

Screenshot

$ ./console

» IB-API Interactive Console <<
---------------------------------------------

Namespace is IB !

---------------------------------------------
F: Connected to server, version: 165, using client-id: 2000,
   connection time: 2024-07-01 14:29:37 +0200 local, 2024-07-01T14:29:36+01:00 remote.
   Connection established on  localhost:7497
---------------------------------------- OpenOrders -------------------------------------------
<Order: LMT GTC buy 1.0  @ 7.0 PreSubmitted #7/727847517 from 2000/DU4035275>
<Order: LMT GTC buy 100.0  @ 180.0 PreSubmitted #9/749082388 from 2000/DU4035278 dc: 5.0,>
<Order: LMT GTC sell 100.0  @ 180.0 Submitted #8/87541233 from 2000/DU4035279 Adaptive>

┌────────────────────────────────────────────────────────────────────────────┐
                               Active Plugins                               
├──────────────────┬──────────────────┬──────────────────┬───────────────────┤
 advanced-account  connection-tools  managed-accounts  market-price      
 order-prototypes  process-orders    roll              spread-prototypes 
 symbols           verify           
└──────────────────┴─────────────────────────────────────────────────────────┘

----> C    points to the connection-instance

---------------------------------------------

> puts Stock.new( symbol: 'TAP' ).verify.as_table
┌───────┬────────┬──────────┬──────────┬────────┬───────────────┬───────┬────────┬──────────┐
        symbol  con_id    exchange  expiry  trading-class  right  strike  currency 
╞═══════╪════════╪══════════╪══════════╪════════╪═══════════════╪═══════╪════════╪══════════╡
 Stock  TAP     33191300   SMART                 TAP                        USD    
└───────┴────────┴──────────┴──────────┴────────┴───────────────┴───────┴────────┴──────────┘

Array Expansion

To simplify operations with received data, arbitrary operations may be applied to array’s.

Example: After collecting End-of-Day historical data for a IB::Contract, the results can be inspected directly:

> C.activate_plugin 'eod'
> eod = IB::Stock.new( symbol: 'GE' ).eod( duration: 10 )
> eod.class                  => Array 
> eod.size                   => 10 
> eod.first.class            => IB::Bar 
> eod.first.attributes.keys
 => [:time, :open, :high, :low, :close, :volume, :wap, :trades, :created_at] 
> eod.close.to_f             # instead of eod.close.map{|y| y.close.to_f}
 => [6.89, 7.3, 7.32, 7.35, 7.31, 7.86, 7.66, 7.36, 7.13, 7.54]