Several message-calls use :id, :ticker_id or :request_id to distinguish between separate requests.
You can either specify the id or delegate it to IB-Ruby.

To delegate, omit the specification of an :id of any kind.

ib = IB::Connection.new( host: 'localhost:7697' ) 
ib.subscribe( :ContractData  ) {|m| puts  m.contract.as_table  }
ib.subscribe(:ContractDataEnd) {|m| puts "finished with request-id: #{ m.request_id }" }

ib.activate_plugin 'symbols'
ib.try_connection!
ib.send_message :RequestContractData, contract: IB::Symbols::Stocks.aapl
 => 171 
 ┌───────┬────────┬────────┬──────────┬───────────────┬───────┬────────┬──────────┐
         symbol  con_id  exchange  trading-class  right  strike  currency 
 ╞═══════╪════════╪════════╪══════════╪═══════════════╪═══════╪════════╪══════════╡
  Stock  AAPL    265598   SMART         NMS                        USD    
 └───────┴────────┴────────┴──────────┴───────────────┴───────┴────────┴──────────┘
  finished with request-id: 171

The :send_message-method returns the generated »request_id«.

If request_id is included in the parameter list to :send_message, the autogeneration mechanism is overridden.

Examples using this feature

List of Messages supporting auto-generated request_id’s

:RequestAccountSummary
:RequestPositionsMulti
:RequestAccountUpdatesMulti
:RequestContractDetails = :RequestContractData
:RequestExecutions
:RequestFundamentalData
:RequestHeadTimeStamp
:RequestHistogramData
:RequestHistoricalData
:RequestRealTimeBars
:RequestCalculateImpliedVolatility = :CalculateImpliedVolatility 
                                   = :RequestImpliedVolatility 

:RequestCalculateOptionPrice = :CalculateOptionPrice 
                             = :RequestOptionPrice 

:RequestScannerSubscription 
:RequestSecurityDefinitionOptionParameters = :ReqSecDefOptParams  
                                           = :RequestOptionChainDefinition 
Tags: