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, just omit the specification of an :id of any kind.

C.send_message :RequestContractData, contract: IB::Symbols::Stocks.aapl
 => 171 
06:21:31.555 Got message 10 (IB::Messages::Incoming::ContractData)
I, [2018-03-22T06:21:31.556812 $1969]  INFO -- : <Stock: AAPL USD>
06:21:31.557 Got message 52 (IB::Messages::Incoming::ContractDataEnd)
I, [2018-03-22T06:21:31.557438 $1969]  INFO -- : <ContractDataEnd: request_id 171 >

The :send_message-method returns the generated »request_id«. The corresponding :ContractDataEnd message finishes the request.

If you want to control the :request_id, just specify it. The autogeneration mechanism is simply overridden.

 C.send_message :RequestContractData, contract: IB::Symbols::Stocks.aapl, :id => 456
  => 456 
06:26:53.247 Got message 10 (IB::Messages::Incoming::ContractData)
I, [2018-03-22T06:26:53.248262 $1969]  INFO -- : <Stock: AAPL USD>
06:26:53.248 Got message 52 (IB::Messages::Incoming::ContractDataEnd)
I, [2018-03-22T06:26:53.248435 $1969]  INFO -- : <ContractDataEnd: request_id 456 >

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: