IB/Extensions


Documentation: https://ib-ruby.github.io/ib-doc/

Questions, Contributions, Remarks: Discussions are opened in ib-api

Helpers and Macros that ease the usage of the TWS-API of Interactive Brokers

To activate use

gem 'ib-extensions'

in the Gemfile and require the extensions as needed

Include all

(except gateway)

require 'ib-api'
require 'ib/extensions'

Verify

require 'ib-api'
require 'ib/verify'

Verifies a given contract, for details refer to the documentation

Market Price

require 'ib-api'
require 'ib/market-price'

Returns the most recent market-price of a given contract ( documentation )

Historical Data (EOD)

require 'ib-api'
require 'ib/eod'

puts IB::Symbols.Index.estx.eod( duration: '10 d' )

Fetch historical data with just one line of code (documentation )

*NEW :: Contract.eod returns a PolarsDataframe *

Order Prototypes

require 'ib-api'
require 'ib/order-prototypes'

order = IB::Limit.order size: 100, price: 10, action: :buy
order = IB::StopLimit.order size: 100, price: 10, stop_price: 9.5

then transmit the order through the place_order method of IB::Connection or Account-based preview, place, modify and cancel methods of IB::Gateway.

More details in the documentation

Spread Prototypes

require 'ib-api'
require 'ib/spread-prototypes'

Compose most common spreads through

s = IB::Straddle.build from: IB::Symbols::Index.stoxx, 
                            strike: 4200, 
                            expiry: 202112 

t = IB::Strangle.build from: IB::Symbols::Index.stoxx, 
                            c: 2400, p: 2200, 
                            expiry: 202103 

puts s.as_table

and use the speads like any other contract. (documentation)

Gateway

require 'ib-gateway'

IB::Gateway is an enhancement of IB::Connection. Upon initialization, it detects active accounts and stores them in thread safe arrays.

g =  IB::Gateway.current
clients =  G.clients
puts client.first.portfolio_values.as_table

Details in the documentation

Generally puts IB::Model.as_table provides a modern and convient output for the console and notebooks.

g.update_orders
puts g.clients.first.orders.as_table

Its used in Simple Monitor

Notebooks

IB-Ruby code can be executed in iruby jupyter notebooks. A few scripts are included in IB-Examples. (*.ipynb- files)

## Contributing

Bug reports and pull requests are welcome on GitHub at https://github.com/ib-ruby/ib-extensions. This project is intended to be a safe, welcoming space for collaboration, and contributors are expected to adhere to the [code of conduct](https://github.com/[ib-ruby/ib-extensions/blob/master/CODE_OF_CONDUCT.md).


## Code of Conduct

Everyone interacting in the Ib::Extensions project's codebases, issue trackers, chat rooms and mailing lists is expected to follow the [code of conduct](https://github.com/ib-ruby/ib-extensions/blob/master/CODE_OF_CONDUCT.md).