Sha256: 9a9d993bb6678a577c8e4a80c483622e41b63d2d78a146ddf7f2279a0a14b528
Contents?: true
Size: 1.04 KB
Versions: 1
Compression:
Stored size: 1.04 KB
Contents
require 'integration_helper' # Define butterfly def butterfly symbol, expiry, right, *strikes unless @ib && @ib.connected? @ib = IB::Connection.new OPTS[:connection].merge(:logger => mock_logger) end legs = strikes.zip([1, -2, 1]).map do |strike, weight| # Create contract contract = IB::Option.new :symbol => symbol, :expiry => expiry, :right => right, :strike => strike # Find out contract's con_id @ib.clear_received :ContractData, :ContractDataEnd @ib.send_message :RequestContractData, :id => strike, :contract => contract @ib.wait_for :ContractDataEnd, 3 con_id = @ib.received[:ContractData].last.contract.con_id # Create Comboleg from con_id and weight IB::ComboLeg.new :con_id => con_id, :weight => weight end # Create new Combo contract IB::Bag.new :symbol => symbol, :currency => "USD", # Only US options in combo Contracts :exchange => "SMART", :legs => legs end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
ib-ruby-0.7.4 | spec/combo_helper.rb |