ib-ruby 0.5.13 → 0.5.14

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -97,3 +97,7 @@
97
97
  == 0.5.13 / 2012-01-03
98
98
 
99
99
  * Critical bug in Connection#place_order fixed
100
+
101
+ == 0.5.14 / 2012-01-28
102
+
103
+ * Bump after Rebundling
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.13
1
+ 0.5.14
data/bin/global_cancel CHANGED
File without changes
data/bin/historic_data CHANGED
@@ -10,9 +10,6 @@ require 'rubygems'
10
10
  require 'bundler/setup'
11
11
  require 'ib-ruby'
12
12
 
13
- ### Configurable Options
14
- QUIET = false # if Quiet == false, status data will be printed to STDERR
15
-
16
13
  # Definition of what we want data for. We have to keep track of what ticker id
17
14
  # corresponds to what symbol ourselves, because the ticks don't include any other
18
15
  # identifying information. The choice of ticker ids is, as far as I can tell, arbitrary.
@@ -34,14 +31,13 @@ ib.subscribe(:Alert) { |msg| puts msg.to_human }
34
31
  # Note that we have to look the ticker id of each incoming message
35
32
  # up in local memory to figure out what it's for.
36
33
  ib.subscribe(IB::Messages::Incoming::HistoricalData) do |msg|
37
- STDERR.puts @market[msg.data[:id]].description + ": " +
38
- msg.data[:count].to_s + " items:" unless QUIET
34
+ puts @market[msg.data[:id]].description + ": " +
35
+ msg.data[:count].to_s + " items:"
39
36
 
40
37
  msg.data[:results].each do |datum|
41
- @last_msg_time = Time.now.to_i
42
-
43
- STDERR.puts " " + datum.to_s unless QUIET
38
+ puts " " + datum.to_s
44
39
  end
40
+ @last_msg_time = Time.now.to_i
45
41
  end
46
42
 
47
43
  # Now we actually request historical data for the symbols we're interested in. TWS will
data/bin/list_orders CHANGED
File without changes
data/bin/place_order CHANGED
File without changes
@@ -129,7 +129,7 @@ module IB
129
129
  subscriber_id
130
130
  end
131
131
 
132
- # Remove all subscribers with specific subscriber id
132
+ # Remove all subscribers with specific subscriber id (TODO: multiple ids)
133
133
  def unsubscribe(subscriber_id)
134
134
 
135
135
  subscribers.each do |message_class, message_subscribers|
@@ -14,7 +14,21 @@ module IB
14
14
  '15 mins', '30 mins', '1 hour', '1 day']
15
15
 
16
16
  # Enumeration of data types
17
- DATA_TYPES = [:trades, :midpoint, :bid, :ask]
17
+ DATA_TYPES = [:trades,
18
+ :midpoint,
19
+ :bid,
20
+ :ask
21
+ #Determines the nature of data being extracted. Valid values:
22
+ # � TRADES
23
+ #� MIDPOINT
24
+ #� BID
25
+ #� ASK
26
+ #� BID_ASK
27
+ #� HISTORICAL_VOLATILITY
28
+ #� OPTION_IMPLIED_VOLATILITY
29
+ #� OPTION_VOLUME
30
+ #� OPTION_OPEN_INTEREST
31
+ ]
18
32
 
19
33
  # Valid security types (sec_type attribute of IB::Contract)
20
34
  SECURITY_TYPES = {:stock => "STK",
@@ -79,7 +93,7 @@ module IB
79
93
  48 => :rt_volume, # tickGeneric()
80
94
  49 => :halted, # see Note 2 below.
81
95
  50 => :bid_yield, # tickPrice() See Note 3 below
82
- 51 => :asky_ield, # tickPrice() See Note 3 below
96
+ 51 => :ask_yield, # tickPrice() See Note 3 below
83
97
  52 => :last_yield, # tickPrice() See Note 3 below
84
98
  53 => :cust_option_computation, # tickOptionComputation()
85
99
  54 => :trade_count, # tickGeneric()
@@ -1,12 +1,16 @@
1
1
  require "logger"
2
2
 
3
- # Hack in log method into Object
4
- def log
5
- @@log ||= Logger.new(STDOUT).tap do |log|
6
- log.formatter = proc do |level, time, prog, msg|
7
- "#{time.strftime('%m-%d %H:%M:%S.%3N')}-#{level[0]}: #{msg}\n"
3
+ # Add universally accessible log method/accessor into Object
4
+ def log *args
5
+ @@logger ||= Logger.new(STDOUT).tap do |logger|
6
+ logger.formatter = proc do |level, time, prog, msg|
7
+ "#{time.strftime('%H:%M:%S.%3N')} #{msg}\n"
8
8
  end
9
- log.level = Logger::WARN
9
+ logger.level = Logger::INFO
10
+ end
11
+
12
+ @@logger.tap do |logger|
13
+ logger.fatal *args unless args.empty?
10
14
  end
11
15
  end
12
16
 
@@ -20,3 +24,4 @@ end
20
24
 
21
25
 
22
26
 
27
+
@@ -551,8 +551,8 @@ module IB
551
551
  [:market_price, :decimal],
552
552
  [:market_value, :decimal],
553
553
  [:average_cost, :decimal],
554
- [:unrealized_pnl, :decimal],
555
- [:realized_pnl, :decimal],
554
+ [:unrealized_pnl, :decimal], # TODO: Check for Double.MAX_VALUE
555
+ [:realized_pnl, :decimal], # TODO: Check for Double.MAX_VALUE
556
556
  [:account_name, :string]
557
557
  end
558
558
 
@@ -209,7 +209,7 @@ module IB
209
209
 
210
210
  # @data={:id => int: ticker_id - Must be a unique value. When the market data
211
211
  # returns, it will be identified by this tag,
212
- # :contract => Datatypes::Contract, requested contract.
212
+ # :contract => Models::Contract, requested contract.
213
213
  # :tick_list => String: comma delimited list of requested tick groups:
214
214
  # Group ID - Description - Requested Tick Types
215
215
  # 100 - Option Volume (currently for stocks) - 29, 30
@@ -277,7 +277,18 @@ module IB
277
277
  # '30 min'
278
278
  # '1 hour'
279
279
  # '1 day'
280
- # :what_to_show => Symbol: one of :trades, :midpoint, :bid, or :ask -
280
+ # :what_to_show => Symbol:
281
+ # Determines the nature of data being extracted. Valid values:
282
+ #one of :trades, :midpoint, :bid, or :ask -
283
+ # � TRADES
284
+ #� MIDPOINT
285
+ #� BID
286
+ #� ASK
287
+ #� BID_ASK
288
+ #� HISTORICAL_VOLATILITY
289
+ #� OPTION_IMPLIED_VOLATILITY
290
+ #� OPTION_VOLUME
291
+ #� OPTION_OPEN_INTEREST
281
292
  # converts to "TRADES," "MIDPOINT," "BID," or "ASK."
282
293
  # :use_rth => int: 0 - all data available during the time span requested
283
294
  # is returned, even data bars covering time intervals where the
@@ -50,22 +50,67 @@ module IB
50
50
  :client_id, # int: The id of the client that placed this order.
51
51
  :perm_id, # int: TWS id used to identify orders, remains
52
52
  # the same over TWS sessions.
53
- :action, # String: Identifies the side. Valid values: BUY/SELL/SSHORT
53
+ :action, # String: Identifies the side: BUY/SELL/SSHORT
54
54
  :total_quantity, # int: The order quantity.
55
+
55
56
  :order_type, # String: Identifies the order type. Valid values are:
56
- # MKT / MKTCLS / LMT / LMTCLS / PEGMKT / SCALE
57
- # STP / STPLMT / TRAIL / REL / VWAP / TRAILLIMIT
57
+ # Limit Risk:
58
+ # MTL Market-to-Limit
59
+ # MKT PRT Market with Protection
60
+ # QUOTE Request for Quote
61
+ # STP Stop
62
+ # STP LMT Stop Limit
63
+ # TRAIL Trailing Stop
64
+ # TRAIL LIMIT Trailing Stop Limit
65
+ # TRAIL LIT Trailing Limit if Touched
66
+ # TRAIL MIT Trailing Market If Touched
67
+ # Speed of Execution:
68
+ # MKT Market
69
+ # MIT Market-if-Touched
70
+ # MOC Market-on-Close MKTCLSL ?
71
+ # MOO Market-on-Open
72
+ # PEG MKT Pegged-to-Market
73
+ # REL Relative
74
+ # Price Improvement:
75
+ # BOX TOP Box Top
76
+ # LOC Limit-on-Close LMTCLS ?
77
+ # LOO Limit-on-Open
78
+ # LIT Limit if Touched
79
+ # PEG MID Pegged-to-Midpoint
80
+ # VWAP VWAP-Guaranteed
81
+ # Advanced Trading:
82
+ # OCA One-Cancels-All
83
+ # VOL Volatility
84
+ # SCALE Scale
85
+ # Other (no abbreviation):
86
+ # Bracket
87
+ # At Auction
88
+ # Discretionary
89
+ # Sweep-to-Fill
90
+ # Price Improvement Auction
91
+ # Block
92
+ # Hidden
93
+ # Iceberg/Reserve
94
+ # All-or-None
95
+ # Fill-or-Kill
96
+
58
97
  :limit_price, # double: This is the LIMIT price, used for limit,
59
98
  # stop-limit and relative orders. In all other cases
60
99
  # specify zero. For relative orders with no limit price,
61
100
  # also specify zero.
101
+
62
102
  :aux_price, # double: This is the STOP price for stop-limit orders,
63
103
  # and the offset amount for relative orders. In all other
64
104
  # cases, specify zero.
65
105
  #:shares_allocation, # deprecated sharesAllocation field
66
106
 
67
107
  # Extended order fields
68
- :tif, # String: Time in Force - DAY / GTC / IOC / GTD
108
+ :tif, # String: Time to Market:
109
+ # DAY
110
+ # GAT Good-after-Time/Date
111
+ # GTD Good-till-Date/Time
112
+ # GTC Good-till-Canceled
113
+ # IOC Immediate-or-Cancel
69
114
  :oca_group, # String: one cancels all group name
70
115
  :oca_type, # int: Tells how to handle remaining orders in an OCA group
71
116
  # when one order or part of an order executes. Valid values:
@@ -249,6 +294,21 @@ module IB
249
294
 
250
295
  :warning_text # String: Displays a warning message if warranted.
251
296
 
297
+ # IB uses weird String with Java Double.MAX_VALUE to indicate no value here
298
+ def init_margin= val
299
+ @init_margin = val == "1.7976931348623157E308" ? nil : val
300
+ end
301
+
302
+ # IB uses weird String with Java Double.MAX_VALUE to indicate no value here
303
+ def maint_margin= val
304
+ @maint_margin = val == "1.7976931348623157E308" ? nil : val
305
+ end
306
+
307
+ # IB uses weird String with Java Double.MAX_VALUE to indicate no value here
308
+ def equity_with_loan= val
309
+ @equity_with_loan = val == "1.7976931348623157E308" ? nil : val
310
+ end
311
+
252
312
  def initialize opts = {}
253
313
  # Assign defaults first!
254
314
  @outside_rth = false
@@ -377,8 +437,8 @@ module IB
377
437
  end
378
438
 
379
439
  def to_human
380
- "<Order: #{@status} #{@order_type} #{@action} #{@total_quantity} @ #{@limit_price}" +
381
- " #{@tif} id/perm: #{@id}/#{@perm_id}>"
440
+ "<Order: #{order_type} #{tif} #{action} #{total_quantity} #{status} #{limit_price}" +
441
+ " id: #{id}/#{perm_id} from: #{client_id}/#{account}>"
382
442
  end
383
443
  end # class Order
384
444
  end # module Models
metadata CHANGED
@@ -2,116 +2,125 @@
2
2
  name: ib-ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.13
5
+ version: 0.5.14
6
6
  platform: ruby
7
7
  authors:
8
- - Paul Legato
9
- - arvicco
8
+ - Paul Legato
9
+ - arvicco
10
10
  autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-01-03 00:00:00 +03:00
15
- default_executable:
14
+ date: 2012-01-28 00:00:00 Z
16
15
  dependencies:
17
- - !ruby/object:Gem::Dependency
18
- name: bundler
19
- prerelease: false
20
- requirement: &id001 !ruby/object:Gem::Requirement
21
- none: false
22
- requirements:
23
- - - ">="
24
- - !ruby/object:Gem::Version
25
- version: 1.0.13
26
- type: :runtime
27
- version_requirements: *id001
28
- - !ruby/object:Gem::Dependency
29
- name: rspec
30
- prerelease: false
31
- requirement: &id002 !ruby/object:Gem::Requirement
32
- none: false
33
- requirements:
34
- - - ">="
35
- - !ruby/object:Gem::Version
36
- version: 2.5.0
37
- type: :development
38
- version_requirements: *id002
16
+ - !ruby/object:Gem::Dependency
17
+ name: bundler
18
+ prerelease: false
19
+ requirement: &id001 !ruby/object:Gem::Requirement
20
+ none: false
21
+ requirements:
22
+ - - ">="
23
+ - !ruby/object:Gem::Version
24
+ version: 1.0.20
25
+ type: :runtime
26
+ version_requirements: *id001
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ prerelease: false
30
+ requirement: &id002 !ruby/object:Gem::Requirement
31
+ none: false
32
+ requirements:
33
+ - - ">="
34
+ - !ruby/object:Gem::Version
35
+ version: 2.5.0
36
+ type: :development
37
+ version_requirements: *id002
38
+ - !ruby/object:Gem::Dependency
39
+ name: my_scripts
40
+ prerelease: false
41
+ requirement: &id003 !ruby/object:Gem::Requirement
42
+ none: false
43
+ requirements:
44
+ - - ">="
45
+ - !ruby/object:Gem::Version
46
+ version: "0"
47
+ type: :development
48
+ version_requirements: *id003
39
49
  description: Ruby Implementation of the Interactive Brokers TWS API
40
50
  email:
41
- - pjlegato@gmail.com
42
- - arvitallian@gmail.com
51
+ - pjlegato@gmail.com
52
+ - arvitallian@gmail.com
43
53
  executables:
44
- - account_info
45
- - contract_details
46
- - depth_of_market
47
- - global_cancel
48
- - historic_data
49
- - historic_data_cli
50
- - list_orders
51
- - market_data
52
- - option_data
53
- - place_order
54
- - template
55
- - time_and_sales
54
+ - account_info
55
+ - contract_details
56
+ - depth_of_market
57
+ - global_cancel
58
+ - historic_data
59
+ - historic_data_cli
60
+ - list_orders
61
+ - market_data
62
+ - option_data
63
+ - place_order
64
+ - template
65
+ - time_and_sales
56
66
  extensions: []
57
67
 
58
68
  extra_rdoc_files: []
59
69
 
60
70
  files:
61
- - bin/account_info
62
- - bin/contract_details
63
- - bin/depth_of_market
64
- - bin/global_cancel
65
- - bin/historic_data
66
- - bin/historic_data_cli
67
- - bin/list_orders
68
- - bin/market_data
69
- - bin/option_data
70
- - bin/place_order
71
- - bin/template
72
- - bin/time_and_sales
73
- - lib/ib-ruby/connection.rb
74
- - lib/ib-ruby/constants.rb
75
- - lib/ib-ruby/logger.rb
76
- - lib/ib-ruby/messages/incoming.rb
77
- - lib/ib-ruby/messages/outgoing.rb
78
- - lib/ib-ruby/messages.rb
79
- - lib/ib-ruby/models/bar.rb
80
- - lib/ib-ruby/models/combo_leg.rb
81
- - lib/ib-ruby/models/contract/bag.rb
82
- - lib/ib-ruby/models/contract/option.rb
83
- - lib/ib-ruby/models/contract.rb
84
- - lib/ib-ruby/models/execution.rb
85
- - lib/ib-ruby/models/model.rb
86
- - lib/ib-ruby/models/order.rb
87
- - lib/ib-ruby/models.rb
88
- - lib/ib-ruby/socket.rb
89
- - lib/ib-ruby/symbols/forex.rb
90
- - lib/ib-ruby/symbols/futures.rb
91
- - lib/ib-ruby/symbols/options.rb
92
- - lib/ib-ruby/symbols/stocks.rb
93
- - lib/ib-ruby/symbols.rb
94
- - lib/ib-ruby/version.rb
95
- - lib/ib-ruby.rb
96
- - spec/ib-ruby/connection_spec.rb
97
- - spec/ib-ruby/models/combo_leg_spec.rb
98
- - spec/ib-ruby/models/contract_spec.rb
99
- - spec/ib-ruby/models/order_spec.rb
100
- - spec/ib-ruby_spec.rb
101
- - spec/spec_helper.rb
102
- - tasks/common.rake
103
- - tasks/doc.rake
104
- - tasks/gem.rake
105
- - tasks/git.rake
106
- - tasks/spec.rake
107
- - tasks/version.rake
108
- - Rakefile
109
- - README.md
110
- - LICENSE
111
- - VERSION
112
- - HISTORY
113
- - .gitignore
114
- has_rdoc: true
71
+ - bin/account_info
72
+ - bin/contract_details
73
+ - bin/depth_of_market
74
+ - bin/global_cancel
75
+ - bin/historic_data
76
+ - bin/historic_data_cli
77
+ - bin/list_orders
78
+ - bin/market_data
79
+ - bin/option_data
80
+ - bin/place_order
81
+ - bin/template
82
+ - bin/time_and_sales
83
+ - lib/ib-ruby.rb
84
+ - lib/ib-ruby/connection.rb
85
+ - lib/ib-ruby/constants.rb
86
+ - lib/ib-ruby/logger.rb
87
+ - lib/ib-ruby/messages.rb
88
+ - lib/ib-ruby/models.rb
89
+ - lib/ib-ruby/socket.rb
90
+ - lib/ib-ruby/symbols.rb
91
+ - lib/ib-ruby/version.rb
92
+ - lib/ib-ruby/messages/incoming.rb
93
+ - lib/ib-ruby/messages/outgoing.rb
94
+ - lib/ib-ruby/models/bar.rb
95
+ - lib/ib-ruby/models/combo_leg.rb
96
+ - lib/ib-ruby/models/contract.rb
97
+ - lib/ib-ruby/models/execution.rb
98
+ - lib/ib-ruby/models/model.rb
99
+ - lib/ib-ruby/models/order.rb
100
+ - lib/ib-ruby/models/contract/bag.rb
101
+ - lib/ib-ruby/models/contract/option.rb
102
+ - lib/ib-ruby/symbols/forex.rb
103
+ - lib/ib-ruby/symbols/futures.rb
104
+ - lib/ib-ruby/symbols/options.rb
105
+ - lib/ib-ruby/symbols/stocks.rb
106
+ - spec/ib-ruby_spec.rb
107
+ - spec/spec_helper.rb
108
+ - spec/ib-ruby/connection_spec.rb
109
+ - spec/ib-ruby/models/combo_leg_spec.rb
110
+ - spec/ib-ruby/models/contract_spec.rb
111
+ - spec/ib-ruby/models/order_spec.rb
112
+ - tasks/common.rake
113
+ - tasks/doc.rake
114
+ - tasks/gem.rake
115
+ - tasks/git.rake
116
+ - tasks/spec.rake
117
+ - tasks/version.rake
118
+ - Rakefile
119
+ - README.md
120
+ - LICENSE
121
+ - VERSION
122
+ - HISTORY
123
+ - .gitignore
115
124
  homepage: https://github.com/pjlegato/ib-ruby
116
125
  licenses: []
117
126
 
@@ -119,30 +128,31 @@ post_install_message:
119
128
  rdoc_options: []
120
129
 
121
130
  require_paths:
122
- - lib
131
+ - lib
123
132
  required_ruby_version: !ruby/object:Gem::Requirement
124
133
  none: false
125
134
  requirements:
126
- - - ">="
127
- - !ruby/object:Gem::Version
128
- version: "0"
135
+ - - ">="
136
+ - !ruby/object:Gem::Version
137
+ version: "0"
129
138
  required_rubygems_version: !ruby/object:Gem::Requirement
130
139
  none: false
131
140
  requirements:
132
- - - ">="
133
- - !ruby/object:Gem::Version
134
- version: "0"
141
+ - - ">="
142
+ - !ruby/object:Gem::Version
143
+ version: "0"
135
144
  requirements: []
136
145
 
137
146
  rubyforge_project:
138
- rubygems_version: 1.6.2
147
+ rubygems_version: 1.8.15
139
148
  signing_key:
140
149
  specification_version: 3
141
150
  summary: Ruby Implementation of the Interactive Brokers TWS API
142
151
  test_files:
143
- - spec/ib-ruby/connection_spec.rb
144
- - spec/ib-ruby/models/combo_leg_spec.rb
145
- - spec/ib-ruby/models/contract_spec.rb
146
- - spec/ib-ruby/models/order_spec.rb
147
- - spec/ib-ruby_spec.rb
148
- - spec/spec_helper.rb
152
+ - spec/ib-ruby_spec.rb
153
+ - spec/spec_helper.rb
154
+ - spec/ib-ruby/connection_spec.rb
155
+ - spec/ib-ruby/models/combo_leg_spec.rb
156
+ - spec/ib-ruby/models/contract_spec.rb
157
+ - spec/ib-ruby/models/order_spec.rb
158
+ has_rdoc: