GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • IB-Ruby Doc
  • Nav
  • GitHub
  • News

This view

  • Original page
  • New address

GeezerVison is showing ib-ruby.github.io — IB-Ruby Console | IB-Ruby documentation

  • ib-ruby
  • Overview
    • The IB-Ruby Project
    • Introduction
    • Support
  • Installation
    • Setup Ruby and Install the Software.
    • Create a new Project
  • Connection / Plugins
    • Connect to the TWS
    • IB-Connection
    • IB-Ruby Console
    • Jupyter Notebooks
  • Messages
    • List of Messages
    • Request-ID
    • Request Market-Data
  • Contracts
    • Specify and Query
    • Verify
    • Market Price
    • Historical Data
    • Expiry vs. Last-Trading-Day
    • Watchlists
    • Spread Prototypes
    • Rolling of Options and Futures
    • Option-Chains
    • Option-Greeks
  • Orders
    • Prototypes
    • Placing Orders (plain vanilla)
    • Placing Orders (advanced)
  • Accounts
    • Overview
  • Database & Rails Integration
    • Overview

IB-Ruby Console

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

To Access: cd bin && ./console.

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..

API-Ports and Client_id are read from connect.yml.
: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] 

You are visitor 01402503 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.