Module: IB::OutgoingMessages
- Defined in:
- lib/ib-ruby/messages.rb
Overview
Outgoing messages
Defined Under Namespace
Classes: AbstractMessage, CancelHistoricalData, CancelMarketData, CancelMarketDepth, CancelNewsBulletins, CancelOrder, CancelScannerSubscription, ExerciseOptions, PlaceOrder, ReplaceFA, RequestAccountData, RequestAllOpenOrders, RequestAutoOpenOrders, RequestContractData, RequestExecutions, RequestFA, RequestHistoricalData, RequestIds, RequestManagedAccounts, RequestMarketData, RequestMarketDepth, RequestNewsBulletins, RequestOpenOrders, RequestScannerParameters, RequestScannerSubscription, SetServerLoglevel
Constant Summary collapse
- EOL =
"\0"
- ALLOWED_HISTORICAL_TYPES =
data = { :ticker_id => int,
:contract => Contract, :end_date_time => string, :duration => string, # this specifies an integer number of seconds :bar_size => int, :what_to_show => symbol, # one of :trades, :midpoint, :bid, or :ask :use_RTH => int, :format_date => int }
Note that as of 4/07 there is no historical data available for forex spot.
data may either be a Contract object or a String. A String should be in serialize_ib_ruby format; that is, it should be a colon-delimited string in the format:
symbol:security_type:expiry:strike:right:multiplier:exchange:primary_exchange:currency:local_symbol
Fields not needed for a particular security should be left blank (e.g. strike and right are only relevant for options.)
For example, to query the British pound futures contract trading on Globex expiring in September, 2008, the correct string is:
GBP:FUT:200809:::62500:GLOBEX::USD:
A Contract object will be automatically serialized into the required format.
See also chuckcaplan.com/twsapi/index.php/void%20reqIntradayData%28%29 for general information about how TWS handles historic data requests, whence the following has been adapted:
The server providing historical prices appears to not always be available outside of market hours. If you call it outside of its supported time period, or if there is otherwise a problem with it, you will receive error #162 “Historical Market Data Service query failed.:HMDS query returned no data.”
The “endDateTime” parameter accepts a string in the form “yyyymmdd HH:mm:ss”, with a time zone optionally allowed after a space at the end of the string; e.g. “20050701 18:26:44 GMT”
The ticker id needs to be different than the reqMktData ticker id. If you use the same ticker ID you used for the symbol when you did ReqMktData, nothing comes back for the historical data call.
Possible :bar_size values: 1 = 1 sec 2 = 5 sec 3 = 15 sec 4 = 30 sec 5 = 1 minute 6 = 2 minutes 7 = 5 minutes 8 = 15 minutes 9 = 30 minutes 10 = 1 hour 11 = 1 day
Values less than 4 do not appear to work for certain securities.
The nature of the data extracted is governed by sending a string having a value of “TRADES,” “MIDPOINT,” “BID,” or “ASK.” Here, we require a symbol argument of :trades, :midpoint, :bid, or :asked to be passed as data.
If data is set to 0, all data available during the time span requested is returned, even data bars covering time intervals where the market in question was illiquid. If useRTH has a non-zero value, only data within the “Regular Trading Hours” of the product in question is returned, even if the time span requested falls partially or completely outside of them.
Using a :format_date of 1 will cause the dates in the returned messages with the historic data to be in a text format, like “20050307 11:32:16”. If you set :format_date to 2 instead, you will get an offset in seconds from the beginning of 1970, which is the same format as the UNIX epoch time.
For backfill on futures data, you may need to leave the Primary Exchange field of the Contract structure blank; see www.interactivebrokers.com/discus/messages/2/28477.html?1114646754
- This message does not appear to exist anymore as of 4/07.
[:trades, :midpoint, :bid, :ask]