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
@@ -0,0 +1,77 @@
1
+ <%= form_for(@contract) do |f| %>
2
+ <% if @contract.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@contract.errors.count, "error") %> prohibited this contract from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @contract.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 :con_id %><br />
16
+ <%= f.number_field :con_id %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :sec_type %><br />
20
+ <%= f.text_field :sec_type %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :strike %><br />
24
+ <%= f.text_field :strike %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :currency %><br />
28
+ <%= f.text_field :currency %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :sec_id %><br />
32
+ <%= f.text_field :sec_id %>
33
+ </div>
34
+ <div class="field">
35
+ <%= f.label :sec_id_type %><br />
36
+ <%= f.text_field :sec_id_type %>
37
+ </div>
38
+ <div class="field">
39
+ <%= f.label :legs_description %><br />
40
+ <%= f.text_field :legs_description %>
41
+ </div>
42
+ <div class="field">
43
+ <%= f.label :symbol %><br />
44
+ <%= f.text_field :symbol %>
45
+ </div>
46
+ <div class="field">
47
+ <%= f.label :local_symbol %><br />
48
+ <%= f.text_field :local_symbol %>
49
+ </div>
50
+ <div class="field">
51
+ <%= f.label :multiplier %><br />
52
+ <%= f.number_field :multiplier %>
53
+ </div>
54
+ <div class="field">
55
+ <%= f.label :expiry %><br />
56
+ <%= f.text_field :expiry %>
57
+ </div>
58
+ <div class="field">
59
+ <%= f.label :exchange %><br />
60
+ <%= f.text_field :exchange %>
61
+ </div>
62
+ <div class="field">
63
+ <%= f.label :primary_exchange %><br />
64
+ <%= f.text_field :primary_exchange %>
65
+ </div>
66
+ <div class="field">
67
+ <%= f.label :include_expired %><br />
68
+ <%= f.check_box :include_expired %>
69
+ </div>
70
+ <div class="field">
71
+ <%= f.label :right %><br />
72
+ <%= f.text_field :right %>
73
+ </div>
74
+ <div class="actions">
75
+ <%= f.submit %>
76
+ </div>
77
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing contract</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @contract %> |
6
+ <%= link_to 'Back', contracts_path %>
@@ -0,0 +1,53 @@
1
+ <h1>Listing contracts</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Con</th>
6
+ <th>Sec type</th>
7
+ <th>Strike</th>
8
+ <th>Currency</th>
9
+ <th>Sec</th>
10
+ <th>Sec id type</th>
11
+ <th>Legs description</th>
12
+ <th>Symbol</th>
13
+ <th>Local symbol</th>
14
+ <th>Multiplier</th>
15
+ <th>Expiry</th>
16
+ <th>Exchange</th>
17
+ <th>Primary exchange</th>
18
+ <th>Include expired</th>
19
+ <th>Right</th>
20
+ <th>Type</th>
21
+ <th></th>
22
+ <th></th>
23
+ <th></th>
24
+ </tr>
25
+
26
+ <% @contracts.each do |contract| %>
27
+ <tr>
28
+ <td><%= contract.con_id %></td>
29
+ <td><%= contract.sec_type %></td>
30
+ <td><%= contract.strike %></td>
31
+ <td><%= contract.currency %></td>
32
+ <td><%= contract.sec_id %></td>
33
+ <td><%= contract.sec_id_type %></td>
34
+ <td><%= contract.legs_description %></td>
35
+ <td><%= contract.symbol %></td>
36
+ <td><%= contract.local_symbol %></td>
37
+ <td><%= contract.multiplier %></td>
38
+ <td><%= contract.expiry %></td>
39
+ <td><%= contract.exchange %></td>
40
+ <td><%= contract.primary_exchange %></td>
41
+ <td><%= contract.include_expired %></td>
42
+ <td><%= contract.right %></td>
43
+ <td><%= contract.type %></td>
44
+ <td><%= link_to 'Show', contract %></td>
45
+ <td><%= link_to 'Edit', edit_contract_path(contract) %></td>
46
+ <td><%= link_to 'Destroy', contract, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
47
+ </tr>
48
+ <% end %>
49
+ </table>
50
+
51
+ <br />
52
+
53
+ <%= link_to 'New Contract', new_contract_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New contract</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', contracts_path %>
@@ -0,0 +1,85 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Con:</b>
5
+ <%= @contract.con_id %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Sec type:</b>
10
+ <%= @contract.sec_type %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Strike:</b>
15
+ <%= @contract.strike %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Currency:</b>
20
+ <%= @contract.currency %>
21
+ </p>
22
+
23
+ <p>
24
+ <b>Sec:</b>
25
+ <%= @contract.sec_id %>
26
+ </p>
27
+
28
+ <p>
29
+ <b>Sec id type:</b>
30
+ <%= @contract.sec_id_type %>
31
+ </p>
32
+
33
+ <p>
34
+ <b>Legs description:</b>
35
+ <%= @contract.legs_description %>
36
+ </p>
37
+
38
+ <p>
39
+ <b>Symbol:</b>
40
+ <%= @contract.symbol %>
41
+ </p>
42
+
43
+ <p>
44
+ <b>Local symbol:</b>
45
+ <%= @contract.local_symbol %>
46
+ </p>
47
+
48
+ <p>
49
+ <b>Multiplier:</b>
50
+ <%= @contract.multiplier %>
51
+ </p>
52
+
53
+ <p>
54
+ <b>Expiry:</b>
55
+ <%= @contract.expiry %>
56
+ </p>
57
+
58
+ <p>
59
+ <b>Exchange:</b>
60
+ <%= @contract.exchange %>
61
+ </p>
62
+
63
+ <p>
64
+ <b>Primary exchange:</b>
65
+ <%= @contract.primary_exchange %>
66
+ </p>
67
+
68
+ <p>
69
+ <b>Include expired:</b>
70
+ <%= @contract.include_expired %>
71
+ </p>
72
+
73
+ <p>
74
+ <b>Right:</b>
75
+ <%= @contract.right %>
76
+ </p>
77
+
78
+ <p>
79
+ <b>Type:</b>
80
+ <%= @contract.type %>
81
+ </p>
82
+
83
+
84
+ <%= link_to 'Edit', edit_contract_path(@contract) %> |
85
+ <%= link_to 'Back', contracts_path %>
@@ -0,0 +1,77 @@
1
+ <%= form_for(@execution) do |f| %>
2
+ <% if @execution.errors.any? %>
3
+ <div id="error_explanation">
4
+ <h2><%= pluralize(@execution.errors.count, "error") %> prohibited this execution from being saved:</h2>
5
+
6
+ <ul>
7
+ <% @execution.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 :order_id %><br />
16
+ <%= f.number_field :order_id %>
17
+ </div>
18
+ <div class="field">
19
+ <%= f.label :local_id %><br />
20
+ <%= f.number_field :local_id %>
21
+ </div>
22
+ <div class="field">
23
+ <%= f.label :client_id %><br />
24
+ <%= f.number_field :client_id %>
25
+ </div>
26
+ <div class="field">
27
+ <%= f.label :perm_id %><br />
28
+ <%= f.number_field :perm_id %>
29
+ </div>
30
+ <div class="field">
31
+ <%= f.label :order_ref %><br />
32
+ <%= f.text_field :order_ref %>
33
+ </div>
34
+ <div class="field">
35
+ <%= f.label :exec_id %><br />
36
+ <%= f.text_field :exec_id %>
37
+ </div>
38
+ <div class="field">
39
+ <%= f.label :side %><br />
40
+ <%= f.text_field :side %>
41
+ </div>
42
+ <div class="field">
43
+ <%= f.label :quantity %><br />
44
+ <%= f.number_field :quantity %>
45
+ </div>
46
+ <div class="field">
47
+ <%= f.label :cumulative_quantity %><br />
48
+ <%= f.number_field :cumulative_quantity %>
49
+ </div>
50
+ <div class="field">
51
+ <%= f.label :price %><br />
52
+ <%= f.text_field :price %>
53
+ </div>
54
+ <div class="field">
55
+ <%= f.label :average_price %><br />
56
+ <%= f.text_field :average_price %>
57
+ </div>
58
+ <div class="field">
59
+ <%= f.label :exchange %><br />
60
+ <%= f.text_field :exchange %>
61
+ </div>
62
+ <div class="field">
63
+ <%= f.label :account_name %><br />
64
+ <%= f.text_field :account_name %>
65
+ </div>
66
+ <div class="field">
67
+ <%= f.label :liquidation %><br />
68
+ <%= f.check_box :liquidation %>
69
+ </div>
70
+ <div class="field">
71
+ <%= f.label :time %><br />
72
+ <%= f.text_field :time %>
73
+ </div>
74
+ <div class="actions">
75
+ <%= f.submit %>
76
+ </div>
77
+ <% end %>
@@ -0,0 +1,6 @@
1
+ <h1>Editing execution</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Show', @execution %> |
6
+ <%= link_to 'Back', executions_path %>
@@ -0,0 +1,51 @@
1
+ <h1>Listing executions</h1>
2
+
3
+ <table>
4
+ <tr>
5
+ <th>Order</th>
6
+ <th>Local</th>
7
+ <th>Client</th>
8
+ <th>Perm</th>
9
+ <th>Order ref</th>
10
+ <th>Exec</th>
11
+ <th>Side</th>
12
+ <th>Quantity</th>
13
+ <th>Cumulative quantity</th>
14
+ <th>Price</th>
15
+ <th>Average price</th>
16
+ <th>Exchange</th>
17
+ <th>Account name</th>
18
+ <th>Liquidation</th>
19
+ <th>Time</th>
20
+ <th></th>
21
+ <th></th>
22
+ <th></th>
23
+ </tr>
24
+
25
+ <% @executions.each do |execution| %>
26
+ <tr>
27
+ <td><%= execution.order_id %></td>
28
+ <td><%= execution.local_id %></td>
29
+ <td><%= execution.client_id %></td>
30
+ <td><%= execution.perm_id %></td>
31
+ <td><%= execution.order_ref %></td>
32
+ <td><%= execution.exec_id %></td>
33
+ <td><%= execution.side %></td>
34
+ <td><%= execution.quantity %></td>
35
+ <td><%= execution.cumulative_quantity %></td>
36
+ <td><%= execution.price %></td>
37
+ <td><%= execution.average_price %></td>
38
+ <td><%= execution.exchange %></td>
39
+ <td><%= execution.account_name %></td>
40
+ <td><%= execution.liquidation %></td>
41
+ <td><%= execution.time %></td>
42
+ <td><%= link_to 'Show', execution %></td>
43
+ <td><%= link_to 'Edit', edit_execution_path(execution) %></td>
44
+ <td><%= link_to 'Destroy', execution, :method => :delete, :data => { :confirm => 'Are you sure?' } %></td>
45
+ </tr>
46
+ <% end %>
47
+ </table>
48
+
49
+ <br />
50
+
51
+ <%= link_to 'New Execution', new_execution_path %>
@@ -0,0 +1,5 @@
1
+ <h1>New execution</h1>
2
+
3
+ <%= render 'form' %>
4
+
5
+ <%= link_to 'Back', executions_path %>
@@ -0,0 +1,80 @@
1
+ <p id="notice"><%= notice %></p>
2
+
3
+ <p>
4
+ <b>Order:</b>
5
+ <%= @execution.order_id %>
6
+ </p>
7
+
8
+ <p>
9
+ <b>Local:</b>
10
+ <%= @execution.local_id %>
11
+ </p>
12
+
13
+ <p>
14
+ <b>Client:</b>
15
+ <%= @execution.client_id %>
16
+ </p>
17
+
18
+ <p>
19
+ <b>Perm:</b>
20
+ <%= @execution.perm_id %>
21
+ </p>
22
+
23
+ <p>
24
+ <b>Order ref:</b>
25
+ <%= @execution.order_ref %>
26
+ </p>
27
+
28
+ <p>
29
+ <b>Exec:</b>
30
+ <%= @execution.exec_id %>
31
+ </p>
32
+
33
+ <p>
34
+ <b>Side:</b>
35
+ <%= @execution.side %>
36
+ </p>
37
+
38
+ <p>
39
+ <b>Quantity:</b>
40
+ <%= @execution.quantity %>
41
+ </p>
42
+
43
+ <p>
44
+ <b>Cumulative quantity:</b>
45
+ <%= @execution.cumulative_quantity %>
46
+ </p>
47
+
48
+ <p>
49
+ <b>Price:</b>
50
+ <%= @execution.price %>
51
+ </p>
52
+
53
+ <p>
54
+ <b>Average price:</b>
55
+ <%= @execution.average_price %>
56
+ </p>
57
+
58
+ <p>
59
+ <b>Exchange:</b>
60
+ <%= @execution.exchange %>
61
+ </p>
62
+
63
+ <p>
64
+ <b>Account name:</b>
65
+ <%= @execution.account_name %>
66
+ </p>
67
+
68
+ <p>
69
+ <b>Liquidation:</b>
70
+ <%= @execution.liquidation %>
71
+ </p>
72
+
73
+ <p>
74
+ <b>Time:</b>
75
+ <%= @execution.time %>
76
+ </p>
77
+
78
+
79
+ <%= link_to 'Edit', edit_execution_path(@execution) %> |
80
+ <%= link_to 'Back', executions_path %>