ib-ruby 0.8.4 → 0.8.5

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.
Files changed (118) hide show
  1. data/.gitignore +3 -0
  2. data/HISTORY +3 -0
  3. data/README.md +29 -9
  4. data/VERSION +1 -1
  5. data/app/assets/javascripts/ib/bars.js +2 -0
  6. data/app/assets/javascripts/ib/executions.js +2 -0
  7. data/app/assets/javascripts/ib/order_states.js +2 -0
  8. data/app/assets/stylesheets/ib/bars.css +4 -0
  9. data/app/assets/stylesheets/ib/executions.css +4 -0
  10. data/app/assets/stylesheets/ib/order_states.css +4 -0
  11. data/app/controllers/ib/bars_controller.rb +87 -0
  12. data/app/controllers/ib/combo_legs_controller.rb +87 -0
  13. data/app/controllers/ib/contract_details_controller.rb +87 -0
  14. data/app/controllers/ib/contracts_controller.rb +87 -0
  15. data/app/controllers/ib/executions_controller.rb +87 -0
  16. data/app/controllers/ib/order_states_controller.rb +87 -0
  17. data/app/controllers/ib/orders_controller.rb +87 -0
  18. data/app/helpers/ib/bars_helper.rb +4 -0
  19. data/app/helpers/ib/combo_legs_helper.rb +4 -0
  20. data/app/helpers/ib/contract_details_helper.rb +4 -0
  21. data/app/helpers/ib/contracts_helper.rb +4 -0
  22. data/app/helpers/ib/executions_helper.rb +4 -0
  23. data/app/helpers/ib/order_states_helper.rb +4 -0
  24. data/app/helpers/ib/orders_helper.rb +4 -0
  25. data/app/views/ib/bars/_form.html.erb +57 -0
  26. data/app/views/ib/bars/edit.html.erb +6 -0
  27. data/app/views/ib/bars/index.html.erb +41 -0
  28. data/app/views/ib/bars/new.html.erb +5 -0
  29. data/app/views/ib/bars/show.html.erb +55 -0
  30. data/app/views/ib/combo_legs/_form.html.erb +53 -0
  31. data/app/views/ib/combo_legs/edit.html.erb +6 -0
  32. data/app/views/ib/combo_legs/index.html.erb +39 -0
  33. data/app/views/ib/combo_legs/new.html.erb +5 -0
  34. data/app/views/ib/combo_legs/show.html.erb +55 -0
  35. data/app/views/ib/contract_details/_form.html.erb +141 -0
  36. data/app/views/ib/contract_details/edit.html.erb +6 -0
  37. data/app/views/ib/contract_details/index.html.erb +83 -0
  38. data/app/views/ib/contract_details/new.html.erb +5 -0
  39. data/app/views/ib/contract_details/show.html.erb +160 -0
  40. data/app/views/ib/contracts/_form.html.erb +77 -0
  41. data/app/views/ib/contracts/edit.html.erb +6 -0
  42. data/app/views/ib/contracts/index.html.erb +53 -0
  43. data/app/views/ib/contracts/new.html.erb +5 -0
  44. data/app/views/ib/contracts/show.html.erb +85 -0
  45. data/app/views/ib/executions/_form.html.erb +77 -0
  46. data/app/views/ib/executions/edit.html.erb +6 -0
  47. data/app/views/ib/executions/index.html.erb +51 -0
  48. data/app/views/ib/executions/new.html.erb +5 -0
  49. data/app/views/ib/executions/show.html.erb +80 -0
  50. data/app/views/ib/order_states/_form.html.erb +93 -0
  51. data/app/views/ib/order_states/edit.html.erb +6 -0
  52. data/app/views/ib/order_states/index.html.erb +59 -0
  53. data/app/views/ib/order_states/new.html.erb +5 -0
  54. data/app/views/ib/order_states/show.html.erb +100 -0
  55. data/app/views/ib/orders/_form.html.erb +353 -0
  56. data/app/views/ib/orders/edit.html.erb +6 -0
  57. data/app/views/ib/orders/index.html.erb +193 -0
  58. data/app/views/ib/orders/new.html.erb +5 -0
  59. data/app/views/ib/orders/show.html.erb +435 -0
  60. data/bin/scaffold.rb +29 -0
  61. data/config/routes.rb +8 -1
  62. data/db/config.yml +5 -0
  63. data/db/migrate/101_add_ib_executions.rb +3 -0
  64. data/db/migrate/111_add_ib_bars.rb +6 -0
  65. data/db/migrate/121_add_ib_order_states.rb +8 -0
  66. data/db/migrate/131_add_ib_orders.rb +24 -0
  67. data/db/migrate/141_add_ib_combo_legs.rb +6 -0
  68. data/db/migrate/151_add_ib_underlyings.rb +3 -0
  69. data/db/migrate/161_add_ib_contract_details.rb +11 -0
  70. data/db/migrate/171_add_ib_contracts.rb +8 -1
  71. data/db/schema.rb +6 -5
  72. data/lib/ib/base.rb +3 -1
  73. data/lib/ib/base_properties.rb +26 -15
  74. data/lib/ib/connection.rb +3 -2
  75. data/lib/ib/errors.rb +16 -9
  76. data/lib/ib/extensions.rb +6 -4
  77. data/lib/ib/symbols.rb +10 -3
  78. data/lib/ib/symbols/forex.rb +49 -64
  79. data/lib/ib/symbols/futures.rb +2 -3
  80. data/lib/ib/symbols/options.rb +2 -1
  81. data/lib/ib/symbols/stocks.rb +2 -1
  82. data/lib/models/ib/bar.rb +6 -2
  83. data/lib/models/ib/combo_leg.rb +4 -3
  84. data/lib/models/ib/contract.rb +9 -5
  85. data/lib/models/ib/contract_detail.rb +1 -1
  86. data/lib/models/ib/execution.rb +3 -1
  87. data/lib/models/ib/order.rb +22 -20
  88. data/lib/models/ib/order_state.rb +4 -2
  89. data/lib/models/ib/underlying.rb +3 -4
  90. data/spec/README.md +12 -10
  91. data/spec/ib/symbols/symbols_spec.rb +10 -0
  92. data/spec/integration_helper.rb +1 -1
  93. data/spec/model_helper.rb +9 -8
  94. data/spec/models/ib/combo_leg_spec.rb +29 -28
  95. data/spec/models/ib/contract_detail_spec.rb +4 -1
  96. data/spec/models/ib/contract_spec.rb +66 -58
  97. data/spec/models/ib/execution_spec.rb +50 -44
  98. data/spec/models/ib/order_spec.rb +2 -2
  99. data/spec/order_helper.rb +5 -4
  100. data/spec/spec_helper.rb +3 -3
  101. metadata +59 -35
  102. data/app/models/ib/underlying.rb +0 -5
  103. data/bin/account_info +0 -29
  104. data/bin/cancel_orders +0 -27
  105. data/bin/contract_details +0 -35
  106. data/bin/depth_of_market +0 -43
  107. data/bin/fa_accounts +0 -22
  108. data/bin/fundamental_data +0 -39
  109. data/bin/historic_data +0 -51
  110. data/bin/historic_data_cli +0 -182
  111. data/bin/list_orders +0 -28
  112. data/bin/market_data +0 -41
  113. data/bin/option_data +0 -44
  114. data/bin/place_combo_order +0 -58
  115. data/bin/place_order +0 -27
  116. data/bin/template +0 -18
  117. data/bin/tick_data +0 -26
  118. data/bin/time_and_sales +0 -53
data/.gitignore CHANGED
@@ -35,3 +35,6 @@ tmp
35
35
 
36
36
  # Yard cache files - used for the autogenerated documentation
37
37
  .yardoc
38
+
39
+ # 'scratch' files
40
+ test_code.rb
data/HISTORY CHANGED
@@ -198,3 +198,6 @@
198
198
 
199
199
  * Working Rails Engine integration
200
200
 
201
+ == 0.8.5 / 2012-08-11
202
+
203
+ * Complete Rails Engine, TWS 929 support
data/README.md CHANGED
@@ -70,7 +70,7 @@ other API implementations. The choice is yours.
70
70
  | 0.5.21 | 918-920 | 965 |
71
71
  | 0.6.1 | 921-923 | 966 |
72
72
  | 0.7.1 | 924-925 | 966 |
73
- | 0.8.1+ | 926-927 | 967 |
73
+ | 0.8.1+ | 926-929 | 967 |
74
74
 
75
75
  4. Start Interactive Broker's Trader Work Station or Gateway before your code
76
76
  attempts to connect to it. Note that TWS and Gateway listen to different ports,
@@ -119,9 +119,11 @@ See `lib/ib/messages` for a full list of supported incoming/outgoing messages
119
119
  and their attributes. The original TWS docs and code samples can also be found
120
120
  in `misc` directory.
121
121
 
122
- The sample scripts in `bin` directory provide examples of how common tasks
123
- can be achieved using ib-ruby. You may also want to look into `spec/integration`
124
- directory for more scenarios and examples of handling IB messages.
122
+ Sample scripts in `example` directory demonstrate common ib-ruby use cases. Examples
123
+ show you how to access account info, print real time quotes, retrieve historic or
124
+ fundamental data, request options calculations, place, list, and cancel orders.
125
+ You may also want to look into `spec/integration` directory for more scenarios,
126
+ use cases and examples of handling IB messages.
125
127
 
126
128
  ## RAILS INTEGRATION:
127
129
 
@@ -185,13 +187,31 @@ JRuby head (ruby-1.9.3-p203-compatible mode). It is not JRuby-specific though, a
185
187
  for either JRuby or MRI, please report an [issue](https://github.com/ib-ruby/ib-ruby/issues/new)
186
188
  and we will work on it.
187
189
 
190
+ Please keep in mind that when using Ruby 1.8.7, you need to either explicitly:
191
+ ``` ruby
192
+ require 'rubygems'
193
+ require 'ib'
194
+ ```
195
+
196
+ or set the environment variable "RUBYOPT" to "-rubygems":
197
+
198
+ set RUBYOPT=-rubygems
199
+
188
200
  ## CONTRIBUTING:
189
201
 
190
- 1. Fork it
191
- 2. Create your feature branch (`git checkout -b my-new-feature`)
192
- 3. Commit your changes (`git commit -am 'Added some feature'`)
193
- 4. Push to the branch (`git push origin my-new-feature`)
194
- 5. Create new Pull Request
202
+ If you want to contribute to ib-ruby development:
203
+
204
+ 1. Make a fresh fork of ib-ruby (Fork button on top of Github GUI)
205
+ 2. Clone your fork locally (git clone /your fork private URL/)
206
+ 3. Add main ib-ruby repo as upstream (git remote add upstream git://github.com/ib-ruby/ib-ruby.git)
207
+ 4. Create your feature branch (git checkout -b my-new-feature)
208
+ 5. Modify code as you see fit
209
+ 6. Commit your changes (git commit -am 'Added some feature')
210
+ 7. Pull in latest upstream changes (git fetch upstream -v; git merge upstream/master)
211
+ 8. Push to the branch (git push origin my-new-feature)
212
+ 9. Go to your Github fork and create new Pull Request via Github GUI
213
+
214
+ ... then proceed from step 6 for more code modifications...
195
215
 
196
216
  ## LICENSE:
197
217
 
data/VERSION CHANGED
@@ -1 +1 @@
1
- 0.8.4
1
+ 0.8.5
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,2 @@
1
+ // Place all the behaviors and hooks related to the matching controller here.
2
+ // All this logic will automatically be available in application.js.
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,4 @@
1
+ /*
2
+ Place all the styles related to the matching controller here.
3
+ They will automatically be included in application.css.
4
+ */
@@ -0,0 +1,87 @@
1
+ require_dependency "ib/application_controller"
2
+
3
+ module Ib
4
+ class BarsController < ApplicationController
5
+ # GET /bars
6
+ # GET /bars.json
7
+ def index
8
+ @bars = Bar.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @bars }
13
+ end
14
+ end
15
+
16
+ # GET /bars/1
17
+ # GET /bars/1.json
18
+ def show
19
+ @bar = Bar.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @bar }
24
+ end
25
+ end
26
+
27
+ # GET /bars/new
28
+ # GET /bars/new.json
29
+ def new
30
+ @bar = Bar.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @bar }
35
+ end
36
+ end
37
+
38
+ # GET /bars/1/edit
39
+ def edit
40
+ @bar = Bar.find(params[:id])
41
+ end
42
+
43
+ # POST /bars
44
+ # POST /bars.json
45
+ def create
46
+ @bar = Bar.new(params[:bar])
47
+
48
+ respond_to do |format|
49
+ if @bar.save
50
+ format.html { redirect_to @bar, :notice => 'Bar was successfully created.' }
51
+ format.json { render :json => @bar, :status => :created, :location => @bar }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @bar.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /bars/1
60
+ # PUT /bars/1.json
61
+ def update
62
+ @bar = Bar.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @bar.update_attributes(params[:bar])
66
+ format.html { redirect_to @bar, :notice => 'Bar was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @bar.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /bars/1
76
+ # DELETE /bars/1.json
77
+ def destroy
78
+ @bar = Bar.find(params[:id])
79
+ @bar.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to bars_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,87 @@
1
+ require_dependency "ib/application_controller"
2
+
3
+ module Ib
4
+ class ComboLegsController < ApplicationController
5
+ # GET /combo_legs
6
+ # GET /combo_legs.json
7
+ def index
8
+ @combo_legs = ComboLeg.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @combo_legs }
13
+ end
14
+ end
15
+
16
+ # GET /combo_legs/1
17
+ # GET /combo_legs/1.json
18
+ def show
19
+ @combo_leg = ComboLeg.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @combo_leg }
24
+ end
25
+ end
26
+
27
+ # GET /combo_legs/new
28
+ # GET /combo_legs/new.json
29
+ def new
30
+ @combo_leg = ComboLeg.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @combo_leg }
35
+ end
36
+ end
37
+
38
+ # GET /combo_legs/1/edit
39
+ def edit
40
+ @combo_leg = ComboLeg.find(params[:id])
41
+ end
42
+
43
+ # POST /combo_legs
44
+ # POST /combo_legs.json
45
+ def create
46
+ @combo_leg = ComboLeg.new(params[:combo_leg])
47
+
48
+ respond_to do |format|
49
+ if @combo_leg.save
50
+ format.html { redirect_to @combo_leg, :notice => 'Combo leg was successfully created.' }
51
+ format.json { render :json => @combo_leg, :status => :created, :location => @combo_leg }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @combo_leg.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /combo_legs/1
60
+ # PUT /combo_legs/1.json
61
+ def update
62
+ @combo_leg = ComboLeg.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @combo_leg.update_attributes(params[:combo_leg])
66
+ format.html { redirect_to @combo_leg, :notice => 'Combo leg was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @combo_leg.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /combo_legs/1
76
+ # DELETE /combo_legs/1.json
77
+ def destroy
78
+ @combo_leg = ComboLeg.find(params[:id])
79
+ @combo_leg.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to combo_legs_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,87 @@
1
+ require_dependency "ib/application_controller"
2
+
3
+ module Ib
4
+ class ContractDetailsController < ApplicationController
5
+ # GET /contract_details
6
+ # GET /contract_details.json
7
+ def index
8
+ @contract_details = ContractDetail.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @contract_details }
13
+ end
14
+ end
15
+
16
+ # GET /contract_details/1
17
+ # GET /contract_details/1.json
18
+ def show
19
+ @contract_detail = ContractDetail.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @contract_detail }
24
+ end
25
+ end
26
+
27
+ # GET /contract_details/new
28
+ # GET /contract_details/new.json
29
+ def new
30
+ @contract_detail = ContractDetail.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @contract_detail }
35
+ end
36
+ end
37
+
38
+ # GET /contract_details/1/edit
39
+ def edit
40
+ @contract_detail = ContractDetail.find(params[:id])
41
+ end
42
+
43
+ # POST /contract_details
44
+ # POST /contract_details.json
45
+ def create
46
+ @contract_detail = ContractDetail.new(params[:contract_detail])
47
+
48
+ respond_to do |format|
49
+ if @contract_detail.save
50
+ format.html { redirect_to @contract_detail, :notice => 'Contract detail was successfully created.' }
51
+ format.json { render :json => @contract_detail, :status => :created, :location => @contract_detail }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @contract_detail.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /contract_details/1
60
+ # PUT /contract_details/1.json
61
+ def update
62
+ @contract_detail = ContractDetail.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @contract_detail.update_attributes(params[:contract_detail])
66
+ format.html { redirect_to @contract_detail, :notice => 'Contract detail was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @contract_detail.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /contract_details/1
76
+ # DELETE /contract_details/1.json
77
+ def destroy
78
+ @contract_detail = ContractDetail.find(params[:id])
79
+ @contract_detail.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to contract_details_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,87 @@
1
+ require_dependency "ib/application_controller"
2
+
3
+ module Ib
4
+ class ContractsController < ApplicationController
5
+ # GET /contracts
6
+ # GET /contracts.json
7
+ def index
8
+ @contracts = Contract.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @contracts }
13
+ end
14
+ end
15
+
16
+ # GET /contracts/1
17
+ # GET /contracts/1.json
18
+ def show
19
+ @contract = Contract.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @contract }
24
+ end
25
+ end
26
+
27
+ # GET /contracts/new
28
+ # GET /contracts/new.json
29
+ def new
30
+ @contract = Contract.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @contract }
35
+ end
36
+ end
37
+
38
+ # GET /contracts/1/edit
39
+ def edit
40
+ @contract = Contract.find(params[:id])
41
+ end
42
+
43
+ # POST /contracts
44
+ # POST /contracts.json
45
+ def create
46
+ @contract = Contract.new(params[:contract])
47
+
48
+ respond_to do |format|
49
+ if @contract.save
50
+ format.html { redirect_to @contract, :notice => 'Contract was successfully created.' }
51
+ format.json { render :json => @contract, :status => :created, :location => @contract }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @contract.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /contracts/1
60
+ # PUT /contracts/1.json
61
+ def update
62
+ @contract = Contract.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @contract.update_attributes(params[:contract])
66
+ format.html { redirect_to @contract, :notice => 'Contract was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @contract.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /contracts/1
76
+ # DELETE /contracts/1.json
77
+ def destroy
78
+ @contract = Contract.find(params[:id])
79
+ @contract.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to contracts_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end