ib-ruby 0.5.10 → 0.5.11

Sign up to get free protection for your applications and to get access to all the features.
data/HISTORY CHANGED
@@ -85,3 +85,7 @@
85
85
  == 0.5.10 / 2011-12-19
86
86
 
87
87
  * Bag Contract subclass added
88
+
89
+ == 0.5.11 / 2011-12-20
90
+
91
+ * Release Connection.current API
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.5.10
1
+ 0.5.11
data/bin/list_orders CHANGED
@@ -15,7 +15,14 @@ require 'ib-ruby'
15
15
  ib = IB::Connection.new :client_id => 0
16
16
 
17
17
  # Subscribe to TWS alerts/errors and order-related messages
18
- ib.subscribe(:Alert, :OpenOrder, :OrderStatus) { |msg| puts msg.to_human }
18
+ @counter = 0
19
+
20
+ ib.subscribe(:Alert, :OrderStatus) { |msg| puts msg.to_human }
21
+
22
+ ib.subscribe(:OpenOrder) do |msg|
23
+ @counter += 1
24
+ puts "#{@counter}: #{msg.to_human}"
25
+ end
19
26
 
20
27
  ib.send_message :RequestAllOpenOrders
21
28
 
@@ -27,6 +27,11 @@ module IB
27
27
  :reader => true
28
28
  }
29
29
 
30
+ # Singleton to make active Connection universally accessible as IB::Connection.current
31
+ class << self
32
+ attr_accessor :current
33
+ end
34
+
30
35
  attr_reader :server # Info about IB server and server connection state
31
36
  attr_accessor :next_order_id # Next valid order id
32
37
 
@@ -39,6 +44,7 @@ module IB
39
44
 
40
45
  connect if @options[:connect]
41
46
  start_reader if @options[:reader]
47
+ Connection.current = self
42
48
  end
43
49
 
44
50
  # Message subscribers. Key is the message class to listen for.
@@ -5,6 +5,10 @@ module IB
5
5
  # is not really a contract, but a combination (combo) of securities. AKA basket
6
6
  # or bag of securities.
7
7
  class ComboLeg < Model
8
+ # General Notes:
9
+ # 1. The exchange for the leg definition must match that of the combination order.
10
+ # The exception is for a STK leg definition, which must specify the SMART exchange.
11
+
8
12
  # // open/close leg value is same as combo
9
13
  # Specifies whether the order is an open or close order. Valid values are:
10
14
  SAME = 0 # Same as the parent security. The only option for retail customers.
@@ -3,10 +3,15 @@ require 'ib-ruby/models/contract'
3
3
  module IB
4
4
  module Models
5
5
  class Contract
6
+
6
7
  # "BAG" is not really a contract, but a combination (combo) of securities.
7
8
  # AKA basket or bag of securities. Individual securities in combo are represented
8
9
  # by ComboLeg objects.
9
10
  class Bag < Contract
11
+ # General Notes:
12
+ # 1. :exchange for the leg definition must match that of the combination order.
13
+ # The exception is for a STK legs, which must specify the SMART exchange.
14
+ # 2. :symbol => "USD" For combo Contract, this is an arbitrary value (like �USD�)
10
15
 
11
16
  def initialize opts = {}
12
17
  super opts
@@ -26,7 +31,9 @@ module IB
26
31
  end
27
32
 
28
33
  end # class Bag
34
+
29
35
  TYPES[IB::SECURITY_TYPES[:bag]] = Bag
36
+
30
37
  end # class Contract
31
38
  end # module Models
32
39
  end # module IB
@@ -6,6 +6,15 @@ module IB
6
6
  module Models
7
7
  class Order < Model
8
8
 
9
+ # General Notes:
10
+ # 1. Placing Orders by con_id - When you place an order by con_id, you must
11
+ # provide the con_id AND the exchange. If you provide extra fields when placing
12
+ # an order by conid, the order may not work.
13
+
14
+ # 2. Order IDs - Each order you place must have a unique Order ID. We recommend
15
+ # that you increment your own Order IDs to avoid conflicts between orders placed
16
+ # from your API application.
17
+
9
18
  # Constants used in Order objects. Drawn from Order.java
10
19
  Origin_Customer = 0
11
20
  Origin_Firm = 1
@@ -345,7 +354,7 @@ module IB
345
354
 
346
355
  def to_human
347
356
  "<Order: #{@status} #{@order_type} #{@action} #{@total_quantity} @ #{@limit_price}" +
348
- " #{@tif} id/perm: #{@id}/#{@perm_id}>"
357
+ " #{@tif} id/perm: #{@id}/#{@perm_id}>"
349
358
  end
350
359
  end # class Order
351
360
  end # module Models
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.10
5
+ version: 0.5.11
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: 2011-12-19 00:00:00 -08:00
14
+ date: 2011-12-20 00:00:00 -08:00
15
15
  default_executable:
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency