ib-api 972.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (91) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +50 -0
  3. data/.rspec +3 -0
  4. data/.travis.yml +7 -0
  5. data/CODE_OF_CONDUCT.md +74 -0
  6. data/Gemfile +16 -0
  7. data/Gemfile.lock +105 -0
  8. data/Guardfile +24 -0
  9. data/LICENSE +674 -0
  10. data/README.md +65 -0
  11. data/Rakefile +11 -0
  12. data/VERSION +1 -0
  13. data/api.gemspec +43 -0
  14. data/bin/console +95 -0
  15. data/bin/console.yml +3 -0
  16. data/bin/setup +8 -0
  17. data/changelog.md +7 -0
  18. data/example/README.md +76 -0
  19. data/example/account_info +54 -0
  20. data/example/account_positions +30 -0
  21. data/example/account_summary +88 -0
  22. data/example/cancel_orders +74 -0
  23. data/example/fa_accounts +25 -0
  24. data/example/fundamental_data +40 -0
  25. data/example/historic_data_cli +186 -0
  26. data/example/list_orders +45 -0
  27. data/example/portfolio_csv +81 -0
  28. data/example/scanner_data +62 -0
  29. data/example/template +19 -0
  30. data/example/tick_data +28 -0
  31. data/lib/extensions/class-extensions.rb +87 -0
  32. data/lib/ib-api.rb +7 -0
  33. data/lib/ib/base.rb +103 -0
  34. data/lib/ib/base_properties.rb +160 -0
  35. data/lib/ib/connection.rb +450 -0
  36. data/lib/ib/constants.rb +393 -0
  37. data/lib/ib/errors.rb +44 -0
  38. data/lib/ib/logger.rb +26 -0
  39. data/lib/ib/messages.rb +99 -0
  40. data/lib/ib/messages/abstract_message.rb +101 -0
  41. data/lib/ib/messages/incoming.rb +251 -0
  42. data/lib/ib/messages/incoming/abstract_message.rb +116 -0
  43. data/lib/ib/messages/incoming/account_value.rb +78 -0
  44. data/lib/ib/messages/incoming/alert.rb +34 -0
  45. data/lib/ib/messages/incoming/contract_data.rb +102 -0
  46. data/lib/ib/messages/incoming/delta_neutral_validation.rb +23 -0
  47. data/lib/ib/messages/incoming/execution_data.rb +50 -0
  48. data/lib/ib/messages/incoming/historical_data.rb +84 -0
  49. data/lib/ib/messages/incoming/market_depths.rb +44 -0
  50. data/lib/ib/messages/incoming/next_valid_id.rb +18 -0
  51. data/lib/ib/messages/incoming/open_order.rb +277 -0
  52. data/lib/ib/messages/incoming/order_status.rb +85 -0
  53. data/lib/ib/messages/incoming/portfolio_value.rb +78 -0
  54. data/lib/ib/messages/incoming/real_time_bar.rb +32 -0
  55. data/lib/ib/messages/incoming/scanner_data.rb +54 -0
  56. data/lib/ib/messages/incoming/ticks.rb +268 -0
  57. data/lib/ib/messages/outgoing.rb +437 -0
  58. data/lib/ib/messages/outgoing/abstract_message.rb +88 -0
  59. data/lib/ib/messages/outgoing/account_requests.rb +112 -0
  60. data/lib/ib/messages/outgoing/bar_requests.rb +250 -0
  61. data/lib/ib/messages/outgoing/place_order.rb +209 -0
  62. data/lib/ib/messages/outgoing/request_marketdata.rb +99 -0
  63. data/lib/ib/messages/outgoing/request_tick_data.rb +21 -0
  64. data/lib/ib/model.rb +4 -0
  65. data/lib/ib/models.rb +14 -0
  66. data/lib/ib/server_versions.rb +114 -0
  67. data/lib/ib/socket.rb +185 -0
  68. data/lib/ib/support.rb +160 -0
  69. data/lib/ib/version.rb +6 -0
  70. data/lib/models/ib/account.rb +85 -0
  71. data/lib/models/ib/account_value.rb +33 -0
  72. data/lib/models/ib/bag.rb +55 -0
  73. data/lib/models/ib/bar.rb +31 -0
  74. data/lib/models/ib/combo_leg.rb +105 -0
  75. data/lib/models/ib/condition.rb +245 -0
  76. data/lib/models/ib/contract.rb +415 -0
  77. data/lib/models/ib/contract_detail.rb +108 -0
  78. data/lib/models/ib/execution.rb +67 -0
  79. data/lib/models/ib/forex.rb +13 -0
  80. data/lib/models/ib/future.rb +15 -0
  81. data/lib/models/ib/index.rb +15 -0
  82. data/lib/models/ib/option.rb +78 -0
  83. data/lib/models/ib/option_detail.rb +55 -0
  84. data/lib/models/ib/order.rb +519 -0
  85. data/lib/models/ib/order_state.rb +152 -0
  86. data/lib/models/ib/portfolio_value.rb +64 -0
  87. data/lib/models/ib/stock.rb +16 -0
  88. data/lib/models/ib/underlying.rb +34 -0
  89. data/lib/models/ib/vertical.rb +96 -0
  90. data/lib/requires.rb +12 -0
  91. metadata +203 -0
@@ -0,0 +1,44 @@
1
+ module IB
2
+
3
+ # Error handling
4
+ class Error < RuntimeError
5
+ end
6
+
7
+ class ArgumentError < ArgumentError
8
+ end
9
+
10
+ class SymbolError < ArgumentError
11
+ end
12
+
13
+ class LoadError < LoadError
14
+ end
15
+
16
+ class FlexError < RuntimeError
17
+ end
18
+
19
+ class TransmissionError < RuntimeError
20
+ end
21
+ end # module IB
22
+
23
+ # Patching Object with universally accessible top level error method.
24
+ # The method is used throughout the lib instead of plainly raising exceptions.
25
+ # This allows lib user to easily inject user-specific error handling into the lib
26
+ # by just replacing Object#error method.
27
+ def error message, type=:standard, backtrace=nil
28
+ e = case type
29
+ when :standard
30
+ IB::Error.new message
31
+ when :args
32
+ IB::ArgumentError.new message
33
+ when :symbol
34
+ IB::SymbolError.new message
35
+ when :load
36
+ IB::LoadError.new message
37
+ when :flex
38
+ IB::FlexError.new message
39
+ when :reader
40
+ IB::TransmissionError.new message
41
+ end
42
+ e.set_backtrace(backtrace) if backtrace
43
+ raise e
44
+ end
@@ -0,0 +1,26 @@
1
+ require "logger"
2
+ module LogDev
3
+ # define default_logger
4
+ def default_logger
5
+ @default_logger ||= Logger.new(STDOUT).tap do |l|
6
+ l.formatter = proc do |severity, datetime, progname, msg|
7
+ # "#{datetime.strftime("%d.%m.(%X)")}#{"%5s" % severity}->#{progname}##{msg}\n"
8
+ ## the default logger displays the message only
9
+ msg.to_s + "\n"
10
+ end
11
+ l.level = Logger::INFO
12
+ end
13
+ end
14
+
15
+
16
+ def default_logger= logger
17
+ @default_logger = logger
18
+ end
19
+
20
+ # Add universally accessible log method/accessor into Object
21
+ def log *args
22
+ default_logger.tap do |logger|
23
+ logger.fatal *args unless args.empty?
24
+ end
25
+ end
26
+ end # module
@@ -0,0 +1,99 @@
1
+ require 'ib/server_versions'
2
+ module IB
3
+
4
+ module Messages
5
+ # This gem supports incoming/outgoing IB messages compatible with the following
6
+ # IB client/server versions:
7
+ CLIENT_VERSION = 66 # => API V 9.71
8
+ SERVER_VERSION = "v"+ MIN_CLIENT_VER.to_s + ".." + MAX_CLIENT_VER.to_s # extracted from the python-client
9
+ end
10
+ end
11
+
12
+ require 'ib/messages/outgoing'
13
+ require 'ib/messages/incoming'
14
+
15
+ __END__
16
+ // Client version history
17
+ //
18
+ // 6 = Added parentId to orderStatus
19
+ // 7 = The new execDetails event returned for an order filled status and reqExecDetails
20
+ // Also market depth is available.
21
+ // 8 = Added lastFillPrice to orderStatus() event and permId to execution details
22
+ // 9 = Added 'averageCost', 'unrealizedPNL', and 'unrealizedPNL' to updatePortfolio event
23
+ // 10 = Added 'serverId' to the 'open order' & 'order status' events.
24
+ // We send back all the API open orders upon connection.
25
+ // Added new methods reqAllOpenOrders, reqAutoOpenOrders()
26
+ // Added FA support - reqExecution has filter.
27
+ // - reqAccountUpdates takes acct code.
28
+ // 11 = Added permId to openOrder event.
29
+ // 12 = requsting open order attributes ignoreRth, hidden, and discretionary
30
+ // 13 = added goodAfterTime
31
+ // 14 = always send size on bid/ask/last tick
32
+ // 15 = send allocation description string on openOrder
33
+ // 16 = can receive account name in account and portfolio updates, and fa params in openOrder
34
+ // 17 = can receive liquidation field in exec reports, and notAutoAvailable field in mkt data
35
+ // 18 = can receive good till date field in open order messages, and request intraday backfill
36
+ // 19 = can receive rthOnly flag in ORDER_STATUS
37
+ // 20 = expects TWS time string on connection after server version >= 20.
38
+ // 21 = can receive bond contract details.
39
+ // 22 = can receive price magnifier in version 2 contract details message
40
+ // 23 = support for scanner
41
+ // 24 = can receive volatility order parameters in open order messages
42
+ // 25 = can receive HMDS query start and end times
43
+ // 26 = can receive option vols in option market data messages
44
+ // 27 = can receive delta neutral order type and delta neutral aux price in place order version 20: API 8.85
45
+ // 28 = can receive option model computation ticks: API 8.9
46
+ // 29 = can receive trail stop limit price in open order and can place them: API 8.91
47
+ // 30 = can receive extended bond contract def, new ticks, and trade count in bars
48
+ // 31 = can receive EFP extensions to scanner and market data, and combo legs on open orders
49
+ // ; can receive RT bars
50
+ // 32 = can receive TickType.LAST_TIMESTAMP
51
+ // ; can receive "whyHeld" in order status messages
52
+ // 33 = can receive ScaleNumComponents and ScaleComponentSize is open order messages
53
+ // 34 = can receive whatIf orders / order state
54
+ // 35 = can receive contId field for Contract objects
55
+ // 36 = can receive outsideRth field for Order objects
56
+ // 37 = can receive clearingAccount and clearingIntent for Order objects
57
+ // 38 = can receive multiplier and primaryExchange in portfolio updates
58
+ // ; can receive cumQty and avgPrice in execution
59
+ // ; can receive fundamental data
60
+ // ; can receive underComp for Contract objects
61
+ // ; can receive reqId and end marker in contractDetails/bondContractDetails
62
+ // ; can receive ScaleInitComponentSize and ScaleSubsComponentSize for Order objects
63
+ // 39 = can receive underConId in contractDetails
64
+ // 40 = can receive algoStrategy/algoParams in openOrder
65
+ // 41 = can receive end marker for openOrder
66
+ // ; can receive end marker for account download
67
+ // ; can receive end marker for executions download
68
+ // 42 = can receive deltaNeutralValidation
69
+ // 43 = can receive longName(companyName)
70
+ // ; can receive listingExchange
71
+ // ; can receive RTVolume tick
72
+ // 44 = can receive end market for ticker snapshot
73
+ // 45 = can receive notHeld field in openOrder
74
+ // 46 = can receive contractMonth, industry, category, subcategory fields in contractDetails
75
+ // ; can receive timeZoneId, tradingHours, liquidHours fields in contractDetails
76
+ // 47 = can receive gamma, vega, theta, undPrice fields in TICK_OPTION_COMPUTATION
77
+ // 48 = can receive exemptCode in openOrder
78
+ // 49 = can receive hedgeType and hedgeParam in openOrder
79
+ // 50 = can receive optOutSmartRouting field in openOrder
80
+ // 51 = can receive smartComboRoutingParams in openOrder
81
+ // 52 = can receive deltaNeutralConId, deltaNeutralSettlingFirm, deltaNeutralClearingAccount and deltaNeutralClearingIntent in openOrder
82
+ // 53 = can receive orderRef in execution
83
+ // 54 = can receive scale order fields (PriceAdjustValue, PriceAdjustInterval, ProfitOffset, AutoReset,
84
+ // InitPosition, InitFillQty and RandomPercent) in openOrder
85
+ // 55 = can receive orderComboLegs (price) in openOrder
86
+ // 56 = can receive trailingPercent in openOrder
87
+ // 57 = can receive commissionReport message
88
+ // 58 = can receive CUSIP/ISIN/etc. in contractDescription/bondContractDescription
89
+ // 59 = can receive evRule, evMultiplier in contractDescription/bondContractDescription/executionDetails
90
+ // can receive multiplier in executionDetails
91
+ // 60 = can receive deltaNeutralOpenClose, deltaNeutralShortSale, deltaNeutralShortSaleSlot and …deltaNeutralDesignatedLocation in openOrder
92
+ // 61 = can receive multiplier in openOrder
93
+ // can receive tradingClass in openOrder, updatePortfolio, execDetails and position
94
+ // 62 = can receive avgCost in position message
95
+ // 63 = can receive verifyMessageAPI, verifyCompleted, displayGroupList and displayGroupUpdated messages
96
+ // 64 = can receive solicited attrib in openOrder message
97
+ // 65 = can receive verifyAndAuthMessageAPI and verifyAndAuthCompleted messages
98
+ // 66 = can receive randomize size and randomize price order fields
99
+
@@ -0,0 +1,101 @@
1
+ module IB
2
+ module Messages
3
+
4
+ # This is just a basic generic message from the server.
5
+ #
6
+ # Class variables:
7
+ # @message_id - int: message id.
8
+ # @message_type - Symbol: message type (e.g. :OpenOrderEnd)
9
+ #
10
+ # Instance attributes (at least):
11
+ # @version - int: current version of message format.
12
+ # @data - Hash of actual data read from a stream.
13
+ class AbstractMessage
14
+
15
+ # Class methods
16
+ def self.data_map # Map for converting between structured message and raw data
17
+ @data_map ||= []
18
+ end
19
+
20
+ def self.version # Per class, minimum message version supported
21
+ @version || 1
22
+ end
23
+
24
+ def self.message_id
25
+ @message_id
26
+ end
27
+
28
+ # Returns message type Symbol (e.g. :OpenOrderEnd)
29
+ def self.message_type
30
+ to_s.split(/::/).last.to_sym
31
+ end
32
+
33
+ def message_id
34
+ self.class.message_id
35
+ end
36
+
37
+ def request_id
38
+ @data[:request_id].presence || nil
39
+ end
40
+
41
+ def message_type
42
+ self.class.message_type
43
+ end
44
+
45
+ attr_accessor :created_at, :data
46
+
47
+ def self.properties?
48
+ @given_arguments
49
+ end
50
+
51
+
52
+ def to_human
53
+ "<#{self.message_type}:" +
54
+ @data.map do |key, value|
55
+ unless [:version].include?(key)
56
+ " #{key} #{ value.is_a?(Hash) ? value.inspect : value}"
57
+ end
58
+ end.compact.join(',') + " >"
59
+ end
60
+
61
+ end # class AbstractMessage
62
+
63
+ # Macro that defines short message classes using a one-liner.
64
+ # First arg is either a [message_id, version] pair or just message_id (version 1)
65
+ # data_map contains instructions for processing @data Hash. Format:
66
+ # Incoming messages: [field, type] or [group, field, type]
67
+ # Outgoing messages: field, [field, default] or [field, method, [args]]
68
+ def def_message message_id_version, *data_map, &to_human
69
+ base = data_map.first.is_a?(Class) ? data_map.shift : self::AbstractMessage
70
+ message_id, version = message_id_version
71
+
72
+ # Define new message class
73
+ message_class = Class.new(base) do
74
+ @message_id, @version = message_id, version || 1
75
+ @data_map = data_map
76
+ @given_arguments =[]
77
+
78
+ @data_map.each do |(name, _, type_args)|
79
+ dont_process = name == :request_id # [ :request_id, :local_id, :id ].include? name.to_sym
80
+ @given_arguments << name.to_sym
81
+ # Avoid redefining existing accessor methods
82
+ unless instance_methods.include?(name.to_s) || instance_methods.include?(name.to_sym) || dont_process
83
+ if type_args.is_a?(Symbol) # This is Incoming with [group, field, type]
84
+ attr_reader name
85
+ else
86
+ define_method(name) { @data[name] }
87
+ end
88
+ end
89
+ end
90
+
91
+ define_method(:to_human, &to_human) if to_human
92
+ end
93
+
94
+ # Add defined message class to Classes Hash keyed by its message_id
95
+ self::Classes[message_id] = message_class
96
+
97
+ message_class
98
+ end
99
+
100
+ end # module Messages
101
+ end # module IB
@@ -0,0 +1,251 @@
1
+ require 'ib/messages/incoming/abstract_message'
2
+
3
+ # EClientSocket.java uses sendMax() rather than send() for a number of these.
4
+ # It sends an EOL rather than a number if the value == Integer.MAX_VALUE (or Double.MAX_VALUE).
5
+ # These fields are initialized to this MAX_VALUE.
6
+ # This has been implemented with nils in Ruby to represent the case where an EOL should be sent.
7
+
8
+ # TODO: Don't instantiate messages, use their classes as just namespace for .encode/decode
9
+ # TODO: realize Message#fire method that raises EWrapper events
10
+
11
+ module IB
12
+ module Messages
13
+
14
+ # Incoming IB messages (received from TWS/Gateway)
15
+ module Incoming
16
+ extend Messages # def_message macros
17
+
18
+ ### Define short message classes in-line:
19
+
20
+
21
+ NewsBulletins =
22
+ def_message 14, [:request_id, :int], # unique incrementing bulletin ID.
23
+ [:type, :int], # Type of bulletin. Valid values include:
24
+ # 1 = Regular news bulletin
25
+ # 2 = Exchange no longer available for trading
26
+ # 3 = Exchange is available for trading
27
+ [:text, :string], # The bulletin's message text.
28
+ [:exchange, :string] # Exchange from which this message originated.
29
+
30
+
31
+ # Receives an converted XML document that describes the valid parameters that a scanner
32
+ # subscription can have (for outgoing RequestScannerSubscription message).
33
+ ScannerParameters = def_message 19, [:xml, :xml]
34
+
35
+ class ScannerParameters
36
+ # returns a List of Hashes specifing Instruments.
37
+ # > C.received[:ScannerParameters].first.instruments.first
38
+ # => {:name=>"US Stocks",
39
+ # :type=>"STK",
40
+ # :filters=>"AFTERHRSCHANGEPERC,AVGOPTVOLUME,AVGPRICETARGET,AVGRATING,AVGTARGET2PRICERATIO,AVGVOLUME,AVGVOLUME_USD,CHANGEOPENPERC,CHANGEPERC,EMA_20,EMA_50,EMA_100,EMA_200,PRICE_VS_EMA_20,PRICE_VS_EMA_50,PRICE_VS_EMA_100,PRICE_VS_EMA_200,DAYSTOCOVER,DIVIB,DIVYIELD,DIVYIELDIB,FEERATE,FIRSTTRADEDATE,GROWTHRATE,HALTED,HASOPTIONS,HISTDIVIB,HISTDIVYIELDIB,IMBALANCE,IMBALANCEADVRATIOPERC,IMPVOLAT,IMPVOLATOVERHIST,INSIDEROFFLOATPERC,INSTITUTIONALOFFLOATPERC,MACD,MACD_SIGNAL,MACD_HISTOGRAM,MKTCAP,MKTCAP_USD,NEXTDIVAMOUNT,NEXTDIVDATE,NUMPRICETARGETS,NUMRATINGS,NUMSHARESINSIDER,NUMSHARESINSTITUTIONAL,NUMSHARESSHORT,OPENGAPPERC,OPTVOLUME,OPTVOLUMEPCRATIO,PERATIO,PILOT,PPO,PPO_SIGNAL,PPO_HISTOGRAM,PRICE,PRICE2BK,PRICE2TANBK,PRICERANGE,PRICE_USD,QUICKRATIO,REBATERATE,REGIMBALANCE,REGIMBALANCEADVRATIOPERC,RETEQUITY,SHORTABLESHARES,SHORTOFFLOATPERC,SHORTSALERESTRICTED,SIC,ISSUER_COUNTRY_CODE,SOCSACT,SOCSNET,STKTYPE,STVOLUME_3MIN,STVOLUME_5MIN,STVOLUME_10MIN,TRADECOUNT,TRADERATE,UNSHORTABLE,VOLUME,VOLUMERATE,VOLUME_USD,RCGLTCLASS,RCGLTENDDATE,RCGLTIVALUE,RCGLTTRADE,RCGITCLASS,RCGITENDDATE,RCGITIVALUE,RCGITTRADE,RCGSTCLASS,RCGSTENDDATE,RCGSTIVALUE,RCGSTTRADE",
41
+ # :group=>"STK.GLOBAL",
42
+ # :shortName=>"US",
43
+ # :cloudScanNotSupported=>"false"}
44
+ def instruments
45
+ @data[:xml][:ScanParameterResponse][:InstrumentList].first[:Instrument]
46
+ end
47
+
48
+ # returns a List of Hashes specifing ScanTypes
49
+ # > C.received[:ScannerParameters].first.scan_types.first
50
+ # => {:displayName=>"Assets Under Management (AltaVista) Desc",
51
+ # :scanCode=>"SCAN_etfAssets_DESC",
52
+ # :instruments=>"ETF.EQ.US,ETF.FI.US",
53
+ # :absoluteColumns=>"false",
54
+ # :Columns=>{:ColumnSetRef=>{:colId=>"0", :name=>"PctPerf", :display=>"false", :displayType=>"DATA"},
55
+ # :Column=>{:colId=>"6031", :name=>"Assets Under Management", :display=>"true", :displayType=>"DATA"}},
56
+ # :supportsSorting=>"true",
57
+ # :respSizeLimit=>"2147483647", :snapshotSizeLimit=>"2147483647",
58
+ # :searchDefault=>"false", :access=>"unrestricted"}
59
+ #
60
+
61
+ def scan_types
62
+ @data[:xml][:ScanParameterResponse][:ScanTypeList][:ScanType]
63
+ end
64
+ end
65
+
66
+ # Receives the current system time on the server side.
67
+ CurrentTime = def_message 49, [:time, :int] # long!
68
+
69
+
70
+ HeadTimeStamp = def_message( [88, 0], [:request_id, :int], [:date, :int_date] ) do
71
+ # def to_human
72
+ "<#{self.message_type}:" +
73
+ "Request #{request_id}, First Historical Datapoint @ #{date.to_s}«"
74
+ end
75
+
76
+ # Receive Reuters global fundamental market data. There must be a subscription to
77
+ # Reuters Fundamental set up in Account Management before you can receive this data.
78
+ FundamentalData = def_message 51, [:request_id, :int], [:xml, :xml]
79
+
80
+ ContractDataEnd = def_message 52, [:request_id, :int]
81
+
82
+ OpenOrderEnd = def_message 53
83
+
84
+ AccountDownloadEnd = def_message 54, [:account_name, :string]
85
+
86
+ ExecutionDataEnd = def_message 55, [:request_id, :int]
87
+
88
+ MarketDataType = def_message 58, [:request_id, :int], [:market_data_type, :int] do
89
+ "<#{self.message_type}:" +
90
+ " switched to »#{MARKET_DATA_TYPES[market_data_type]}«" # to_human
91
+ end
92
+
93
+ CommissionReport =
94
+ def_message 59, [:exec_id, :string],
95
+ [:commission, :decimal], # Commission amount.
96
+ [:currency, :string], # Commission currency
97
+ [:realized_pnl, :decimal_max],
98
+ [:yield, :decimal_max],
99
+ [:yield_redemption_date, :int] # YYYYMMDD format
100
+
101
+ SecurityDefinitionOptionParameter = OptionChainDefinition = def_message [75,0] ,
102
+ [:request_id, :int],
103
+ [:exchange, :string],
104
+ [:con_id, :int], # underlying_con_id
105
+ [:trading_class, :string],
106
+ [:multiplier, :int]
107
+
108
+ class OptionChainDefinition
109
+ using IBSupport # defines tws-method for Array (socket.rb)
110
+ def load
111
+ super
112
+ load_map [:expirations, :array, proc { @buffer.read_date }],
113
+ [:strikes, :array, proc { @buffer.read_decimal } ]
114
+ end
115
+ def expirations
116
+ @data[:expirations]
117
+ end
118
+ def strikes
119
+ @data[:strikes]
120
+ end
121
+
122
+ def to_human
123
+ "OptionChainDefinition #{trading_class}@#{exchange} [#{multiplier} X ] strikes: #{strikes.first} - #{strikes.last} expirations: #{expirations.first} - #{expirations.last}"
124
+ end
125
+ end
126
+
127
+
128
+
129
+ OptionChainDefinitionEnd = SecurityDefinitionOptionParameterEnd = def_message [76,0 ],
130
+ [ :request_id, :int ]
131
+
132
+
133
+ #<- 1-9-789--USD-CASH-----IDEALPRO--CAD------
134
+ #-> ---81-123-5.0E-5--0-
135
+
136
+ MarketDepthExchanges = def_message [80,0],
137
+ [ :request_id, :int ]
138
+
139
+ TickRequestParameters = def_message [81, 0], [ :ticker_id, :int ],
140
+ [ :min_tick, :decimal],
141
+ [ :exchange, :string ],
142
+ [ :snapshot_prermissions, :int ]
143
+ # class TickRequestParameters
144
+ # def load
145
+ # simple_load
146
+ # end
147
+ # end
148
+
149
+ ### Require standalone source files for more complex message classes:
150
+
151
+ require 'ib/messages/incoming/alert'
152
+ require 'ib/messages/incoming/contract_data'
153
+ require 'ib/messages/incoming/delta_neutral_validation'
154
+ require 'ib/messages/incoming/execution_data'
155
+ require 'ib/messages/incoming/historical_data'
156
+ require 'ib/messages/incoming/market_depths'
157
+ require 'ib/messages/incoming/next_valid_id'
158
+ require 'ib/messages/incoming/open_order'
159
+ require 'ib/messages/incoming/order_status'
160
+ require 'ib/messages/incoming/account_value'
161
+ require 'ib/messages/incoming/portfolio_value'
162
+ require 'ib/messages/incoming/real_time_bar'
163
+ require 'ib/messages/incoming/scanner_data'
164
+ require 'ib/messages/incoming/ticks'
165
+
166
+ end # module Incoming
167
+ end # module Messages
168
+ end # module IB
169
+
170
+
171
+ __END__
172
+ // incoming msg id's
173
+ ## api 9.71v (python)
174
+ # incoming msg id's
175
+ class IN:
176
+ TICK_PRICE = 1
177
+ TICK_SIZE = 2
178
+ ORDER_STATUS = 3
179
+ ERR_MSG = 4
180
+ OPEN_ORDER = 5
181
+ ACCT_VALUE = 6
182
+ PORTFOLIO_VALUE = 7
183
+ ACCT_UPDATE_TIME = 8
184
+ NEXT_VALID_ID = 9
185
+ CONTRACT_DATA = 10
186
+ EXECUTION_DATA = 11
187
+ MARKET_DEPTH = 12
188
+ MARKET_DEPTH_L2 = 13
189
+ NEWS_BULLETINS = 14
190
+ MANAGED_ACCTS = 15
191
+ RECEIVE_FA = 16
192
+ HISTORICAL_DATA = 17
193
+ BOND_CONTRACT_DATA = 18
194
+ SCANNER_PARAMETERS = 19
195
+ SCANNER_DATA = 20
196
+ TICK_OPTION_COMPUTATION = 21
197
+ TICK_GENERIC = 45
198
+ TICK_STRING = 46
199
+ TICK_EFP = 47
200
+ CURRENT_TIME = 49
201
+ REAL_TIME_BARS = 50
202
+ FUNDAMENTAL_DATA = 51
203
+ CONTRACT_DATA_END = 52
204
+ OPEN_ORDER_END = 53
205
+ ACCT_DOWNLOAD_END = 54
206
+ EXECUTION_DATA_END = 55
207
+ DELTA_NEUTRAL_VALIDATION = 56
208
+ TICK_SNAPSHOT_END = 57
209
+ MARKET_DATA_TYPE = 58
210
+ COMMISSION_REPORT = 59 ##
211
+ ### const below are new in api 9.71
212
+ POSITION_DATA = 61
213
+ POSITION_END = 62
214
+ ACCOUNT_SUMMARY = 63
215
+ ACCOUNT_SUMMARY_END = 64
216
+ VERIFY_MESSAGE_API = 65
217
+ VERIFY_COMPLETED = 66
218
+ DISPLAY_GROUP_LIST = 67
219
+ DISPLAY_GROUP_UPDATED = 68
220
+ VERIFY_AND_AUTH_MESSAGE_API = 69
221
+ VERIFY_AND_AUTH_COMPLETED = 70
222
+ POSITION_MULTI = 71
223
+ POSITION_MULTI_END = 72
224
+ ACCOUNT_UPDATE_MULTI = 73
225
+ ACCOUNT_UPDATE_MULTI_END = 74
226
+ SECURITY_DEFINITION_OPTION_PARAMETER = 75
227
+ SECURITY_DEFINITION_OPTION_PARAMETER_END = 76
228
+ SOFT_DOLLAR_TIERS = 77
229
+ FAMILY_CODES = 78
230
+ SYMBOL_SAMPLES = 79
231
+ MKT_DEPTH_EXCHANGES = 80
232
+ TICK_REQ_PARAMS = 81
233
+ SMART_COMPONENTS = 82
234
+ NEWS_ARTICLE = 83
235
+ TICK_NEWS = 84
236
+ NEWS_PROVIDERS = 85
237
+ HISTORICAL_NEWS = 86
238
+ HISTORICAL_NEWS_END = 87
239
+ HEAD_TIMESTAMP = 88
240
+ HISTOGRAM_DATA = 89
241
+ HISTORICAL_DATA_UPDATE = 90
242
+ REROUTE_MKT_DATA_REQ = 91
243
+ REROUTE_MKT_DEPTH_REQ = 92
244
+ MARKET_RULE = 93
245
+ PNL = 94
246
+ PNL_SINGLE = 95
247
+ HISTORICAL_TICKS = 96
248
+ HISTORICAL_TICKS_BID_ASK = 97
249
+ HISTORICAL_TICKS_LAST = 98
250
+ TICK_BY_TICK = 99
251
+