Module: IB::Messages::Outgoing
- Extended by:
- IB::Messages
- Defined in:
- lib/ib/messages/outgoing.rb,
lib/ib/messages/outgoing/place_order.rb,
lib/ib/messages/outgoing/bar_requests.rb,
lib/ib/messages/outgoing/abstract_message.rb
Overview
Outgoing IB messages (sent to TWS/Gateway)
Defined Under Namespace
Classes: AbstractMessage, BarRequestMessage, PlaceOrder, RequestHistoricalData, RequestRealTimeBars
Constant Summary collapse
- RequestOpenOrders =
Request the open orders that were placed from THIS client. Each open order will be fed back through the OpenOrder and OrderStatus messages ONCE. NB: Client with a client_id of 0 will also receive the TWS-owned open orders. These orders will be associated with the client and a new orderId will be generated. This association will persist over multiple API and TWS sessions.
5
- RequestAllOpenOrders =
Request the open orders placed from all clients and also from TWS. Each open order will be fed back through the OpenOrder and OrderStatus messages ONCE. Note this does not re-bind those Orders to requesting Client! Use RequestAutoOpenOrders to request such re-binding.
16
- RequestAutoOpenOrders =
Request that newly created TWS orders be implicitly associated with this client. When a new TWS order is created, the order will be associated with this client and automatically fed back through the OpenOrder and OrderStatus messages. It is a ‘continuous’ request such that it gets turned ‘on’ when called with a TRUE auto_bind parameter. When it’s called with FALSE auto_bind, new TWS orders will not bind to this client going forward. Note that TWS orders can only be bound to clients with a client_id of 0. TODO: how to properly test this? data = { :auto_bind => boolean }
15, :auto_bind
- RequestScannerParameters =
Requests an XML document that describes the valid parameters that a scanner subscription can have (for outgoing RequestScannerSubscription message).
24
- CancelNewsBulletins =
13
- RequestManagedAccounts =
17
- RequestCurrentTime =
49
- RequestGlobalCancel =
58
- CancelMarketData =
Data format is: @data = { :id => ticker_id}
2
- CancelMarketDepth =
11
- CancelScannerSubscription =
23
- CancelHistoricalData =
25
- CancelRealTimeBars =
51
- CancelFundamentalData =
Data format is: @data = { :id => request_id }
53
- CancelCalculateImpliedVolatility =
CancelImpliedVolatility = (56)
- CancelCalculateOptionPrice =
CancelOptionPrice = (57)
- CancelOrder =
Data format is: @data ={ :id => local_id of order to cancel }
4
- RequestIds =
Request the next valid ID that can be used when placing an order. Responds with NextValidId message, and the id returned is that next valid Id for orders. That ID will reflect any autobinding that has occurred (which generates new IDs and increments the next valid ID therein).
8, [:number, 1]
- RequestNewsBulletins =
data = { :all_messages => boolean }
12, :all_messages
- SetServerLoglevel =
data = { :log_level => int }
14, :log_level
- RequestFA =
data = { :fa_data_type => int }
18, :fa_data_type
- ReplaceFA =
data = { :fa_data_type => int, :xml => String }
19, :fa_data_type, :xml
- RequestAccountUpdates =
RequestAccountData = ([6, 2], [:subscribe, true], :account_code)
- RequestContractDetails =
data => { :id => request_id (int), :contract => Contract }
Special case for options: “wildcards” in the Contract fields retrieve Option chains
strike = 0 means all strikes right = "" meanns both call and put expiry = "" means all expiries expiry = "2013" means all expiries in 2013 expiry = "201311" means all expiries in Nov 2013
You’ll get several ContractData (10) messages back if there is more than one match. When all the matches are delivered you’ll get ContractDataEnd (52) message.
RequestContractData = ([9, 6], [:contract, :serialize_short, [:con_id, :include_expired, :sec_id]])
- RequestMarketDepth =
data = { :id => ticker_id (int), :contract => Contract, :num_rows => int }
([10, 3], [:contract, :serialize_short, []], :num_rows)
- RequestExecutions =
When this message is sent, TWS responds with ExecutionData messages, each containing the execution report that meets the specified criteria. @data={:id => int: :request_id,
:client_id => int: Filter the results based on the clientId. :acct_code => Filter the results based on based on account code. Note: this is only relevant for Financial Advisor accts. :sec_type => Filter the results based on the order security type. :time => Filter the results based on execution reports received after the specified time - format "yyyymmdd-hh:mm:ss" :symbol => Filter the results based on the order symbol. :exchange => Filter the results based on the order exchange :side => Filter the results based on the order action: BUY/SELL/SSHORT
([7, 3], :client_id, :acct_code, :time, # Format "yyyymmdd-hh:mm:ss" :symbol, :sec_type, :exchange, :side)
- ExerciseOptions =
data = { :id => ticker_id (int),
:contract => IB::Contract, :exercise_action => int, 1 = exercise, 2 = lapse :exercise_quantity => int, The number of contracts to be exercised :account => string, :override => int: Specifies whether your setting will override the system's natural action. For example, if your action is "exercise" and the option is not in-the-money, by natural action the option would not exercise. If you have override set to "yes" the natural action would be overridden and the out-of-the money option would be exercised. Values are: - 0 = do not override - 1 = override
(21, [:contract, :serialize_short], :exercise_action, :exercise_quantity, :account, :override)
- RequestMarketData =
@data={:id => int: ticker_id - Must be a unique value. When the market data
returns, it will be identified by this tag, :contract => IB::Contract, requested contract. :tick_list => String: comma delimited list of requested tick groups: Group ID - Description - Requested Tick Types 100 - Option Volume (currently for stocks) - 29, 30 101 - Option Open Interest (currently for stocks) - 27, 28 104 - Historical Volatility (currently for stocks) - 23 106 - Option Implied Volatility (currently for stocks) - 24 162 - Index Future Premium - 31 165 - Miscellaneous Stats - 15, 16, 17, 18, 19, 20, 21 221 - Mark Price (used in TWS P&L computations) - 37 225 - Auction values (volume, price and imbalance) - 34, 35, 36 233 - RTVolume - 48 236 - Shortable - 46 256 - Inventory - ? 258 - Fundamental Ratios - 47 411 - Realtime Historical Volatility - 58 :snapshot => bool: Check to return a single snapshot of market data and have the market data subscription canceled. Do not enter any :tick_list values if you use snapshot. }
([1, 9], [:contract, :serialize_long, [:con_id]], [:contract, :serialize_legs, []], [:contract, :serialize_under_comp, []], [:tick_list, lambda do |tick_list| tick_list.is_a?(Array) ? tick_list.join(',') : (tick_list || '') end, []], [:snapshot, false])
- RequestMarketDataType =
The API can receive frozen market data from Trader Workstation. Frozen market data is the last data recorded in our system. During normal trading hours, the API receives real-time market data. If you use this function, you are telling TWS to automatically switch to frozen market data AFTER the close. Then, before the opening of the next trading day, market data will automatically switch back to real-time market data. :market_data_type = 1 for real-time streaming, 2 for frozen market data
59, [:market_data_type, lambda { |type| MARKET_DATA_TYPES.invert[type] || type }, []]
- RequestFundamentalData =
Send this message to receive Reuters global fundamental data. There must be a subscription to Reuters Fundamental set up in Account Management before you can receive this data. data = { :id => int: :request_id,
:contract => Contract, :report_type => String: one of the following: 'estimates' - Estimates 'finstat' - Financial statements 'snapshot' - Summary }
(52, [:contract, :serialize, [:primary_exchange]], :report_type)
- RequestCalculateImpliedVolatility =
data = { :request_id => int, :contract => Contract,
:option_price => double, :under_price => double }
CalculateImpliedVolatility = RequestImpliedVolatility = (54, [:contract, :serialize_long, [:con_id]], :option_price, :under_price)
- RequestCalculateOptionPrice =
data = { :request_id => int, :contract => Contract,
:volatility => double, :under_price => double }
CalculateOptionPrice = RequestOptionPrice = (55, [:contract, :serialize_long, [:con_id]], :volatility, :under_price)
- RequestScannerSubscription =
Start receiving market scanner results through the ScannerData messages.
To learn all valid parameter values that a scanner subscription can have, first subscribe to ScannerParameters and send RequestScannerParameters message. Available scanner parameters values will be listed in received XML document.
([22, 3], [:number_of_rows, -1], # was: EOL, :instrument, :location_code, :scan_code, :above_price, :below_price, :above_volume, :market_cap_above, :market_cap_below, :moody_rating_above, :moody_rating_below, :sp_rating_above, :sp_rating_below, :maturity_date_above, :maturity_date_below, :coupon_rate_above, :coupon_rate_below, :exclude_convertible, :average_option_volume_above, # ? :scanner_setting_pairs, :stock_type_filter)
- Classes =
Container for specific message classes, keyed by their message_ids
{}
Constants included from IB::Messages
CLIENT_VERSION, SERVER_VERSION