Since TWS version 950 derivats are defined by :last_trading_day
instead of :expiry
.
IB-Release Notes.
:real_expiration_date
was added to the list of IB::Contract
attributes.
IB-Ruby still uses :expiry
to query Options and Futures. However, the :last_trading_day
directive is supported as well. :expiry
is addressed via YYYYMMDD
, either as String or as Integer. :last_trading_day
uses the String-representation of a Date
-Object: "YYYY-MM-DD"
.
> the_contract = IB::Option.new symbol: 'SPY', right: :put, strike: 330, currency: 'USD', expiry: 202012
> the_contract.to_human => "<Option: SPY 202012 put 330.0 SMART USD>"
> the_contract.last_trading_day => ""
> the_contract.verify.size => 68
> the_contract.verify.first.last_trading_day => "2020-12-18"
> spy = IB::Option.new symbol: 'SPY', last_trading_day: "2020-12-18", right: :put, strike: 330
> spy.verify.size => 1
> spy.to_human => "<Option: SPY 202018 put 330.0 SMART USD>"
> IB::Option.new symbol: 'GE', strike: 7, expiry: 202101, exchange: 'SMART'
covers all options expiring in January 2020. When requested (Contract.verify ) Call- and Put-options with a strike at 15$ are returned.
> ge_options = IB::Option.new( symbol: 'GE', strike: 15, expiry: 202101, exchange: 'SMART' ).verify
> ge_options.size => 2
> ge_options.map &:to_human
=> ["<Option: GE 20210115 call 15.0 SMART USD>", "<Option: GE 20210115 put 15.0 SMART USD>"]
> ge_options.map &:expiry => ["20210115", "20210115" ]
> ge_ option.map &:last_trading_day => ["2021-01-15", "2021-01-15"]