ib-ruby 0.7.10 → 0.7.11

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
@@ -177,3 +177,7 @@
177
177
  == 0.7.10 / 2012-04-25
178
178
 
179
179
  * Small fixes for DB backend and serialization
180
+
181
+ == 0.7.11 / 2012-04-25
182
+
183
+ * DB schema extended
data/TODO CHANGED
@@ -1,24 +1,18 @@
1
1
  Plan:
2
2
 
3
- 0. Extract OrderState/UnderComp objects, for better record keeping
4
-
5
- 1. Add ActiveRecord backend to all Models
6
-
7
- 2. Make ActiveModel-like attributes Hash for easy attributes updating
8
-
9
- 3. IB#send_message method should accept block, thus compressing subscribe/send_message
3
+ 1. IB#send_message method should accept block, thus compressing subscribe/send_message
10
4
  pair into a single call - to simplify DSL.
11
5
 
12
- 4. IB Connection uses delays to prevent hitting 50 msgs/sec limit:
6
+ 2. IB Connection uses delays to prevent hitting 50 msgs/sec limit:
13
7
  http://finance.groups.yahoo.com/group/TWSAPI/message/25413
14
8
 
15
- 5. IB Connection reconnects gracefully in case if TWS disconnects/reconnects
9
+ 3. IB Connection reconnects gracefully in case if TWS disconnects/reconnects
16
10
 
17
- 6. @received_at timestamp in messages
11
+ 4. Messages should be Models as well (audit trail), @received_at timestamp in messages
18
12
 
19
- 7. Detailed message documentation
13
+ 5. Detailed message documentation
20
14
 
21
- 8. Move Float values to Decimal (roundoff errors showed in spec!)
15
+ 6. Move Float values to Decimal (roundoff errors showed in spec!)
22
16
 
23
17
 
24
18
  Done:
@@ -33,6 +27,10 @@ Done:
33
27
 
34
28
  5. Flow handlers: Connection#wait_for / Connection#received?
35
29
 
30
+ 6. Add ActiveRecord backend to all Models
31
+
32
+ 7. Make ActiveModel-like attributes Hash and serialization for tableless Models
33
+
36
34
 
37
35
  Ideas for future:
38
36
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.7.10
1
+ 0.7.11
@@ -3,6 +3,7 @@ class AddOrders < ActiveRecord::Migration
3
3
  def change
4
4
  # OrderState represents dynamic (changeable) info about a single Order
5
5
  create_table(:orders) do |t|
6
+ t.references :contract # Optional link of Order to its contract
6
7
 
7
8
  t.integer :local_id # int: Order id associated with client (volatile).
8
9
  t.integer :client_id # int: The id of the client that placed this order.
@@ -66,18 +66,20 @@ module IB
66
66
 
67
67
  ### Associations
68
68
 
69
- has_one :contract_detail
69
+ has_many :orders # Placed for this Contract
70
70
 
71
- has_one :underlying # for Delta-Neutral Combo contracts only!
72
- alias under_comp underlying
73
- alias under_comp= underlying=
71
+ has_one :contract_detail # Volatile info about this Contract
74
72
 
75
- has_many :combo_legs
73
+ has_many :combo_legs # for Combo/BAG Contracts only
76
74
  alias legs combo_legs
77
75
  alias legs= combo_legs=
78
76
  alias combo_legs_description legs_description
79
77
  alias combo_legs_description= legs_description=
80
78
 
79
+ has_one :underlying # for Delta-Neutral Combo Contracts only
80
+ alias under_comp underlying
81
+ alias under_comp= underlying=
82
+
81
83
 
82
84
  ### Extra validations
83
85
  validates_inclusion_of :sec_type, :in => CODES[:sec_type].keys,
@@ -227,6 +227,10 @@ module IB
227
227
  ##serialize :leg_prices
228
228
  ##serialize :combo_params
229
229
 
230
+ # Order is always placed for a contract. Here, we explicitly set this link.
231
+ belongs_to :contract
232
+
233
+ # Order has a collection of Executions if it was filled
230
234
  has_many :executions
231
235
 
232
236
  # Order has a collection of OrderStates, last one is always current
@@ -302,7 +306,11 @@ module IB
302
306
  :algo_strategy => '',
303
307
  :transmit => true,
304
308
  :what_if => false,
305
- :order_state => IB::OrderState.new(:status => 'New')
309
+ :order_state => IB::OrderState.new(:status => 'New',
310
+ :filled => 0,
311
+ :remaining => 0,
312
+ :price => 0,
313
+ :average_price => 0)
306
314
  end
307
315
 
308
316
  #after_initialize do #opts = {}
@@ -63,14 +63,7 @@ module IB
63
63
  validates_numericality_of :local_id, :perm_id, :client_id, :parent_id, :filled,
64
64
  :remaining, :only_integer => true, :allow_nil => true
65
65
 
66
- def default_attributes
67
- super.merge :filled => 0,
68
- :remaining => 0,
69
- :price => 0.0,
70
- :average_price => 0.0
71
- end
72
-
73
- ## Testing Order state:
66
+ ## Testing Order state:
74
67
 
75
68
  def new?
76
69
  status.empty? || status == 'New'
data/spec/TODO CHANGED
@@ -3,8 +3,8 @@ TODO: Add more scenarios:
3
3
  1. RealTimeBars
4
4
  2. BondContractData
5
5
  3. RequestScannerParameters + RequestScannerSubscription
6
- 4. RequestFundamentalData
7
6
  5. ExerciseOptions
8
7
  6. RequestMarketData + special tick list
9
8
  7. RequestNewsBulletins
10
9
  8. RequestImpliedVolatility / RequestOptionPrice
10
+ 9. Test more associations/associated collections
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: ib-ruby
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.7.10
5
+ version: 0.7.11
6
6
  platform: ruby
7
7
  authors:
8
8
  - Paul Legato