ib-ruby 0.8.4 → 0.8.5

Sign up to get free protection for your applications and to get access to all the features.
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
@@ -0,0 +1,87 @@
1
+ require_dependency "ib/application_controller"
2
+
3
+ module Ib
4
+ class ExecutionsController < ApplicationController
5
+ # GET /executions
6
+ # GET /executions.json
7
+ def index
8
+ @executions = Execution.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @executions }
13
+ end
14
+ end
15
+
16
+ # GET /executions/1
17
+ # GET /executions/1.json
18
+ def show
19
+ @execution = Execution.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @execution }
24
+ end
25
+ end
26
+
27
+ # GET /executions/new
28
+ # GET /executions/new.json
29
+ def new
30
+ @execution = Execution.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @execution }
35
+ end
36
+ end
37
+
38
+ # GET /executions/1/edit
39
+ def edit
40
+ @execution = Execution.find(params[:id])
41
+ end
42
+
43
+ # POST /executions
44
+ # POST /executions.json
45
+ def create
46
+ @execution = Execution.new(params[:execution])
47
+
48
+ respond_to do |format|
49
+ if @execution.save
50
+ format.html { redirect_to @execution, :notice => 'Execution was successfully created.' }
51
+ format.json { render :json => @execution, :status => :created, :location => @execution }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @execution.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /executions/1
60
+ # PUT /executions/1.json
61
+ def update
62
+ @execution = Execution.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @execution.update_attributes(params[:execution])
66
+ format.html { redirect_to @execution, :notice => 'Execution was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @execution.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /executions/1
76
+ # DELETE /executions/1.json
77
+ def destroy
78
+ @execution = Execution.find(params[:id])
79
+ @execution.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to executions_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 OrderStatesController < ApplicationController
5
+ # GET /order_states
6
+ # GET /order_states.json
7
+ def index
8
+ @order_states = OrderState.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @order_states }
13
+ end
14
+ end
15
+
16
+ # GET /order_states/1
17
+ # GET /order_states/1.json
18
+ def show
19
+ @order_state = OrderState.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @order_state }
24
+ end
25
+ end
26
+
27
+ # GET /order_states/new
28
+ # GET /order_states/new.json
29
+ def new
30
+ @order_state = OrderState.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @order_state }
35
+ end
36
+ end
37
+
38
+ # GET /order_states/1/edit
39
+ def edit
40
+ @order_state = OrderState.find(params[:id])
41
+ end
42
+
43
+ # POST /order_states
44
+ # POST /order_states.json
45
+ def create
46
+ @order_state = OrderState.new(params[:order_state])
47
+
48
+ respond_to do |format|
49
+ if @order_state.save
50
+ format.html { redirect_to @order_state, :notice => 'Order state was successfully created.' }
51
+ format.json { render :json => @order_state, :status => :created, :location => @order_state }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @order_state.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /order_states/1
60
+ # PUT /order_states/1.json
61
+ def update
62
+ @order_state = OrderState.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @order_state.update_attributes(params[:order_state])
66
+ format.html { redirect_to @order_state, :notice => 'Order state was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @order_state.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /order_states/1
76
+ # DELETE /order_states/1.json
77
+ def destroy
78
+ @order_state = OrderState.find(params[:id])
79
+ @order_state.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to order_states_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 OrdersController < ApplicationController
5
+ # GET /orders
6
+ # GET /orders.json
7
+ def index
8
+ @orders = Order.all
9
+
10
+ respond_to do |format|
11
+ format.html # index.html.erb
12
+ format.json { render :json => @orders }
13
+ end
14
+ end
15
+
16
+ # GET /orders/1
17
+ # GET /orders/1.json
18
+ def show
19
+ @order = Order.find(params[:id])
20
+
21
+ respond_to do |format|
22
+ format.html # show.html.erb
23
+ format.json { render :json => @order }
24
+ end
25
+ end
26
+
27
+ # GET /orders/new
28
+ # GET /orders/new.json
29
+ def new
30
+ @order = Order.new
31
+
32
+ respond_to do |format|
33
+ format.html # new.html.erb
34
+ format.json { render :json => @order }
35
+ end
36
+ end
37
+
38
+ # GET /orders/1/edit
39
+ def edit
40
+ @order = Order.find(params[:id])
41
+ end
42
+
43
+ # POST /orders
44
+ # POST /orders.json
45
+ def create
46
+ @order = Order.new(params[:order])
47
+
48
+ respond_to do |format|
49
+ if @order.save
50
+ format.html { redirect_to @order, :notice => 'Order was successfully created.' }
51
+ format.json { render :json => @order, :status => :created, :location => @order }
52
+ else
53
+ format.html { render :action => "new" }
54
+ format.json { render :json => @order.errors, :status => :unprocessable_entity }
55
+ end
56
+ end
57
+ end
58
+
59
+ # PUT /orders/1
60
+ # PUT /orders/1.json
61
+ def update
62
+ @order = Order.find(params[:id])
63
+
64
+ respond_to do |format|
65
+ if @order.update_attributes(params[:order])
66
+ format.html { redirect_to @order, :notice => 'Order was successfully updated.' }
67
+ format.json { head :no_content }
68
+ else
69
+ format.html { render :action => "edit" }
70
+ format.json { render :json => @order.errors, :status => :unprocessable_entity }
71
+ end
72
+ end
73
+ end
74
+
75
+ # DELETE /orders/1
76
+ # DELETE /orders/1.json
77
+ def destroy
78
+ @order = Order.find(params[:id])
79
+ @order.destroy
80
+
81
+ respond_to do |format|
82
+ format.html { redirect_to orders_url }
83
+ format.json { head :no_content }
84
+ end
85
+ end
86
+ end
87
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module BarsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module ComboLegsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module ContractDetailsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module ContractsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module ExecutionsHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module OrderStatesHelper
3
+ end
4
+ end
@@ -0,0 +1,4 @@
1
+ module Ib
2
+ module OrdersHelper
3
+ end
4
+ end
@@ -0,0 +1,57 @@
1
+ <%= form_for(@bar) do |f| %>
2
+ <% if @bar.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@bar.errors.count, "error") %> prohibited this bar from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @bar.errors.full_messages.each do |msg| %>
8
+ <li><%= msg %></li>
9
+ <% end %>
10
+ </ul>
11
+ </div>
12
+ <% end %>
13
+
14
+ <div class="field">
15
+ <%= f.label :contract_id %><br />
16
+ <%= f.number_field :contract_id %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :open %><br />
20
+ <%= f.text_field :open %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :high %><br />
24
+ <%= f.text_field :high %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :low %><br />
28
+ <%= f.text_field :low %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :close %><br />
32
+ <%= f.text_field :close %>
33
+ </div>
34
+ <div class="field">
35
+ <%= f.label :wap %><br />
36
+ <%= f.text_field :wap %>
37
+ </div>
38
+ <div class="field">
39
+ <%= f.label :volume %><br />
40
+ <%= f.number_field :volume %>
41
+ </div>
42
+ <div class="field">
43
+ <%= f.label :trades %><br />
44
+ <%= f.number_field :trades %>
45
+ </div>
46
+ <div class="field">
47
+ <%= f.label :has_gaps %><br />
48
+ <%= f.check_box :has_gaps %>
49
+ </div>
50
+ <div class="field">
51
+ <%= f.label :time %><br />
52
+ <%= f.text_field :time %>
53
+ </div>
54
+ <div class="actions">
55
+ <%= f.submit %>
56
+ </div>
57
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing bar</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @bar %> |
6
+ <%= link_to 'Back', bars_path %>
@@ -0,0 +1,41 @@
1
+ <h1>Listing bars</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Contract</th>
6
+ <th>Open</th>
7
+ <th>High</th>
8
+ <th>Low</th>
9
+ <th>Close</th>
10
+ <th>Wap</th>
11
+ <th>Volume</th>
12
+ <th>Trades</th>
13
+ <th>Gaps?</th>
14
+ <th>Time</th>
15
+ <th></th>
16
+ <th></th>
17
+ <th></th>
18
+ </tr>
19
+
20
+ <% @bars.each do |bar| %>
21
+ <tr>
22
+ <td><%= bar.contract_id %></td>
23
+ <td><%= bar.open %></td>
24
+ <td><%= bar.high %></td>
25
+ <td><%= bar.low %></td>
26
+ <td><%= bar.close %></td>
27
+ <td><%= bar.wap %></td>
28
+ <td><%= bar.volume %></td>
29
+ <td><%= bar.trades %></td>
30
+ <td><%= bar.has_gaps %></td>
31
+ <td><%= bar.time %></td>
32
+ <td><%= link_to 'Show', bar %></td>
33
+ <td><%= link_to 'Edit', edit_bar_path(bar) %></td>
34
+ <td><%= link_to 'Destroy', bar, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
35
+ </tr>
36
+ <% end %>
37
+ </table>
38
+
39
+ <br />
40
+
41
+ <%= link_to 'New Bar', new_bar_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New bar</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', bars_path %>
@@ -0,0 +1,55 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Contract:</b>
5
+ <%= @bar.contract_id %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Open:</b>
10
+ <%= @bar.open %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>High:</b>
15
+ <%= @bar.high %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Low:</b>
20
+ <%= @bar.low %>
21
+ </p>
22
+
23
+ <p>
24
+ <b>Close:</b>
25
+ <%= @bar.close %>
26
+ </p>
27
+
28
+ <p>
29
+ <b>Wap:</b>
30
+ <%= @bar.wap %>
31
+ </p>
32
+
33
+ <p>
34
+ <b>Volume:</b>
35
+ <%= @bar.volume %>
36
+ </p>
37
+
38
+ <p>
39
+ <b>Trades:</b>
40
+ <%= @bar.trades %>
41
+ </p>
42
+
43
+ <p>
44
+ <b>Has gaps:</b>
45
+ <%= @bar.has_gaps %>
46
+ </p>
47
+
48
+ <p>
49
+ <b>Time:</b>
50
+ <%= @bar.time %>
51
+ </p>
52
+
53
+
54
+ <%= link_to 'Edit', edit_bar_path(@bar) %> |
55
+ <%= link_to 'Back', bars_path %>