ib-ruby 0.5.14 → 0.5.15

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
data/HISTORY CHANGED
@@ -101,3 +101,7 @@
101
101
  == 0.5.14 / 2012-01-28
102
102
 
103
103
  * Bump after Rebundling
104
+
105
+ == 0.5.15 / 2012-02-01
106
+
107
+ * Docs improvement
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.14
1
+ 0.5.15
data/bin/account_info CHANGED
@@ -26,7 +26,7 @@ ib.send_message :RequestAccountData, :subscribe => true
26
26
 
27
27
  puts "\nSubscribing to IB account data"
28
28
  puts "\n******** Press <Enter> to cancel... *********\n\n"
29
- gets
29
+ STDIN.gets
30
30
  puts "Cancelling account data subscription.."
31
31
 
32
32
  ib.send_message :RequestAccountData, :subscribe => false
@@ -11,15 +11,19 @@ require 'rubygems'
11
11
  require 'bundler/setup'
12
12
  require 'ib-ruby'
13
13
 
14
+ p ARGV
15
+
14
16
  # First, connect to IB TWS.
15
17
  ib = IB::Connection.new
16
18
 
17
19
  # Subscribe to TWS alerts/errors and order-related messages
18
20
  ib.subscribe(:Alert, :OpenOrder, :OrderStatus) { |msg| puts msg.to_human }
19
21
 
20
- ib.send_message :RequestGlobalCancel
22
+ ib.send_message :RequestGlobalCancel if ARGV.empty?
23
+
24
+ ARGV.each { |order_id| ib.send_message :CancelOrder, :id => order_id.to_i }
21
25
 
22
26
  ib.send_message :RequestAllOpenOrders
23
27
 
24
28
  puts "\n******** Press <Enter> to cancel... *********\n\n"
25
- gets
29
+ STDIN.gets
data/bin/depth_of_market CHANGED
@@ -40,7 +40,7 @@ end
40
40
 
41
41
  puts "\nSubscribed to market data"
42
42
  puts "\n******** Press <Enter> to cancel... *********\n\n"
43
- gets
43
+ STDIN.gets
44
44
  puts "Cancelling market data subscription.."
45
45
 
46
46
  @market.each_pair { |id, contract| ib.send_message :CancelMarketDepth, :id => id }
data/bin/list_orders CHANGED
@@ -27,4 +27,4 @@ end
27
27
  ib.send_message :RequestAllOpenOrders
28
28
 
29
29
  puts "\n******** Press <Enter> to cancel... *********\n\n"
30
- gets
30
+ STDIN.gets
data/bin/market_data CHANGED
@@ -38,7 +38,7 @@ end
38
38
 
39
39
  puts "\nSubscribed to market data"
40
40
  puts "\n******** Press <Enter> to cancel... *********\n\n"
41
- gets
41
+ STDIN.gets
42
42
  puts "Cancelling market data subscription.."
43
43
 
44
44
  @market.each_pair { |id, _| ib.send_message :CancelMarketData, :id => id }
data/bin/option_data CHANGED
@@ -41,7 +41,7 @@ end
41
41
 
42
42
  puts "\nSubscribed to market data"
43
43
  puts "\n******** Press <Enter> to cancel... *********\n\n"
44
- gets
44
+ STDIN.gets
45
45
  puts "Cancelling market data subscription.."
46
46
 
47
47
  @market.each_pair { |id, contract| ib.send_message :CancelMarketData, :id => id }
data/bin/place_order CHANGED
@@ -30,4 +30,4 @@ ib.place_order buy_order, wfc
30
30
  ib.send_message :RequestAllOpenOrders
31
31
 
32
32
  puts "\n******** Press <Enter> to cancel... *********\n\n"
33
- gets
33
+ STDIN.gets
data/bin/time_and_sales CHANGED
@@ -52,7 +52,7 @@ end
52
52
 
53
53
  puts "\nSubscribed to TWS market data"
54
54
  puts "\n******** Press <Enter> to cancel... *********\n\n"
55
- gets
55
+ STDIN.gets
56
56
  puts "Unsubscribing from TWS market data.."
57
57
 
58
58
  @market.each_pair { |id, contract| ib.send_message :CancelMarketData, :id => id }
@@ -4,7 +4,7 @@ require "logger"
4
4
  def log *args
5
5
  @@logger ||= Logger.new(STDOUT).tap do |logger|
6
6
  logger.formatter = proc do |level, time, prog, msg|
7
- "#{time.strftime('%H:%M:%S.%3N')} #{msg}\n"
7
+ "#{time.strftime('%H:%M:%S.%N')} #{msg}\n"
8
8
  end
9
9
  logger.level = Logger::INFO
10
10
  end
@@ -481,7 +481,7 @@ module IB
481
481
  @order.trail_stop_price = @socket.read_decimal
482
482
  @order.basis_points = @socket.read_decimal
483
483
  @order.basis_points_type = @socket.read_int
484
- @contract.combo_legs_description = @socket.read_string
484
+ @contract.legs_description = @socket.read_string
485
485
  @order.scale_init_level_size = @socket.read_int_max
486
486
  @order.scale_subs_level_size = @socket.read_int_max
487
487
  @order.scale_price_increment = @socket.read_decimal_max
@@ -243,7 +243,7 @@ module IB
243
243
  end
244
244
  [super,
245
245
  @data[:contract].serialize_long(:con_id),
246
- @data[:contract].serialize_combo_legs,
246
+ @data[:contract].serialize_legs,
247
247
  @data[:contract].serialize_under_comp,
248
248
  tick_list,
249
249
  @data[:snapshot] || false]
@@ -351,7 +351,7 @@ module IB
351
351
  @data[:use_rth],
352
352
  @data[:what_to_show].to_s.upcase,
353
353
  @data[:format_date],
354
- contract.serialize_combo_legs]
354
+ contract.serialize_legs]
355
355
  end
356
356
  end # RequestHistoricalData
357
357
 
@@ -24,8 +24,8 @@ module IB
24
24
 
25
25
  def to_human
26
26
  "<Bag: " + [symbol, exchange, currency].join(" ") + " legs: " +
27
- (@combo_legs_description ||
28
- @combo_legs.map do |leg|
27
+ (@legs_description ||
28
+ @legs.map do |leg|
29
29
  "#{leg.action} #{leg.ratio} * #{leg.con_id}"
30
30
  end.join('|')) + ">"
31
31
  end
@@ -64,8 +64,8 @@ module IB
64
64
  :sec_id, # Unique identifier of the given secIdType.
65
65
 
66
66
  # COMBOS
67
- :combo_legs_description, # received in open order for all combos
68
- :combo_legs # Dynamic memory structure used to store the leg
67
+ :legs_description, # received in open order for all combos
68
+ :legs # Dynamic memory structure used to store the leg
69
69
  # definitions for this contract.
70
70
 
71
71
  # ContractDetails fields are bundled into Contract proper, as it should be
@@ -123,9 +123,12 @@ module IB
123
123
  :under_delta, # double: The underlying stock or future delta.
124
124
  :under_price # double: The price of the underlying.
125
125
 
126
- # NB :description field is entirely local to ib-ruby, and not part of TWS.
127
- # You can use it to store whatever arbitrary data you want.
128
- attr_accessor :description
126
+ attr_accessor :description # NB: local to ib-ruby, not part of TWS.
127
+
128
+ alias combo_legs legs
129
+ alias combo_legs= legs=
130
+ alias combo_legs_description legs_description
131
+ alias combo_legs_description= legs_description=
129
132
 
130
133
  def initialize opts = {}
131
134
  # Assign defaults to properties first!
@@ -133,7 +136,7 @@ module IB
133
136
  @strike = 0
134
137
  @sec_type = ''
135
138
  @include_expired = false
136
- @combo_legs = Array.new
139
+ @legs = Array.new
137
140
 
138
141
  # These properties are from ContractDetails
139
142
  @summary = self
@@ -181,7 +184,7 @@ module IB
181
184
  end
182
185
 
183
186
  def reset
184
- @combo_legs = Array.new
187
+ @legs = Array.new
185
188
  @strike = 0
186
189
  end
187
190
 
@@ -243,11 +246,10 @@ module IB
243
246
  # "BAG" is not really a contract, but a combination (combo) of securities.
244
247
  # AKA basket or bag of securities. Individual securities in combo are represented
245
248
  # by ComboLeg objects.
246
- def serialize_combo_legs *fields
249
+ def serialize_legs *fields
247
250
  return [] unless sec_type.upcase == "BAG"
248
- return [0] if combo_legs.empty? || combo_legs.nil?
249
- [combo_legs.size,
250
- combo_legs.map { |leg| leg.serialize *fields }]
251
+ return [0] if legs.empty? || legs.nil?
252
+ [legs.size, legs.map { |leg| leg.serialize *fields }]
251
253
  end
252
254
 
253
255
  def to_s
@@ -136,9 +136,18 @@ module IB
136
136
  # two consecutive bid or ask prices.
137
137
  # 2 - "last" method, stops are triggered based on the last price.
138
138
  # 3 - double last method.
139
- # 4 - bid/ask method.
140
- # 7 - last or bid/ask method.
141
- # 8 - mid-point method.
139
+ # 4 - bid/ask method. For a buy order, a single occurrence of the
140
+ # bid price must be at or above the trigger price. For a sell
141
+ # order, a single occurrence of the ask price must be at or
142
+ # below the trigger price.
143
+ # 7 - last or bid/ask method. For a buy order, a single bid price
144
+ # or the last price must be at or above the trigger price.
145
+ # For a sell order, a single ask price or the last price
146
+ # must be at or below the trigger price.
147
+ # 8 - mid-point method, where the midpoint must be at or above
148
+ # (for a buy) or at or below (for a sell) the trigger price,
149
+ # and the spread between the bid and ask must be less than
150
+ # 0.1% of the midpoint
142
151
 
143
152
  :outside_rth, # bool: allows orders to also trigger or fill outside
144
153
  # of regular trading hours. (WAS: ignore_rth)
@@ -275,6 +284,7 @@ module IB
275
284
  # � Cancelled - indicates that the balance of your order has been
276
285
  # confirmed canceled by the IB system. This could occur unexpectedly
277
286
  # when IB or the destination has rejected your order.
287
+ # � ApiCancelled - canceled via API
278
288
  # � Filled - indicates that the order has been completely filled.
279
289
  # � Inactive - indicates that the order has been accepted by the system
280
290
  # (simulated orders) or an exchange (native orders) but that currently
@@ -374,7 +384,7 @@ module IB
374
384
  trigger_method,
375
385
  outside_rth, # was: ignore_rth
376
386
  hidden,
377
- contract.serialize_combo_legs(:extended),
387
+ contract.serialize_legs(:extended),
378
388
  '', # deprecated shares_allocation field
379
389
  discretionary_amount,
380
390
  good_after_time,
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ib-ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.5.14
5
+ version: 0.5.15
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Legato
@@ -11,7 +11,7 @@ autorequire:
11
11
  bindir: bin
12
12
  cert_chain: []
13
13
 
14
- date: 2012-01-28 00:00:00 Z
14
+ date: 2012-02-01 00:00:00 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: bundler
@@ -52,9 +52,9 @@ email:
52
52
  - arvitallian@gmail.com
53
53
  executables:
54
54
  - account_info
55
+ - cancel_orders
55
56
  - contract_details
56
57
  - depth_of_market
57
- - global_cancel
58
58
  - historic_data
59
59
  - historic_data_cli
60
60
  - list_orders
@@ -69,9 +69,9 @@ extra_rdoc_files: []
69
69
 
70
70
  files:
71
71
  - bin/account_info
72
+ - bin/cancel_orders
72
73
  - bin/contract_details
73
74
  - bin/depth_of_market
74
- - bin/global_cancel
75
75
  - bin/historic_data
76
76
  - bin/historic_data_cli
77
77
  - bin/list_orders