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.
- data/.gitignore +3 -0
- data/HISTORY +3 -0
- data/README.md +29 -9
- data/VERSION +1 -1
- data/app/assets/javascripts/ib/bars.js +2 -0
- data/app/assets/javascripts/ib/executions.js +2 -0
- data/app/assets/javascripts/ib/order_states.js +2 -0
- data/app/assets/stylesheets/ib/bars.css +4 -0
- data/app/assets/stylesheets/ib/executions.css +4 -0
- data/app/assets/stylesheets/ib/order_states.css +4 -0
- data/app/controllers/ib/bars_controller.rb +87 -0
- data/app/controllers/ib/combo_legs_controller.rb +87 -0
- data/app/controllers/ib/contract_details_controller.rb +87 -0
- data/app/controllers/ib/contracts_controller.rb +87 -0
- data/app/controllers/ib/executions_controller.rb +87 -0
- data/app/controllers/ib/order_states_controller.rb +87 -0
- data/app/controllers/ib/orders_controller.rb +87 -0
- data/app/helpers/ib/bars_helper.rb +4 -0
- data/app/helpers/ib/combo_legs_helper.rb +4 -0
- data/app/helpers/ib/contract_details_helper.rb +4 -0
- data/app/helpers/ib/contracts_helper.rb +4 -0
- data/app/helpers/ib/executions_helper.rb +4 -0
- data/app/helpers/ib/order_states_helper.rb +4 -0
- data/app/helpers/ib/orders_helper.rb +4 -0
- data/app/views/ib/bars/_form.html.erb +57 -0
- data/app/views/ib/bars/edit.html.erb +6 -0
- data/app/views/ib/bars/index.html.erb +41 -0
- data/app/views/ib/bars/new.html.erb +5 -0
- data/app/views/ib/bars/show.html.erb +55 -0
- data/app/views/ib/combo_legs/_form.html.erb +53 -0
- data/app/views/ib/combo_legs/edit.html.erb +6 -0
- data/app/views/ib/combo_legs/index.html.erb +39 -0
- data/app/views/ib/combo_legs/new.html.erb +5 -0
- data/app/views/ib/combo_legs/show.html.erb +55 -0
- data/app/views/ib/contract_details/_form.html.erb +141 -0
- data/app/views/ib/contract_details/edit.html.erb +6 -0
- data/app/views/ib/contract_details/index.html.erb +83 -0
- data/app/views/ib/contract_details/new.html.erb +5 -0
- data/app/views/ib/contract_details/show.html.erb +160 -0
- data/app/views/ib/contracts/_form.html.erb +77 -0
- data/app/views/ib/contracts/edit.html.erb +6 -0
- data/app/views/ib/contracts/index.html.erb +53 -0
- data/app/views/ib/contracts/new.html.erb +5 -0
- data/app/views/ib/contracts/show.html.erb +85 -0
- data/app/views/ib/executions/_form.html.erb +77 -0
- data/app/views/ib/executions/edit.html.erb +6 -0
- data/app/views/ib/executions/index.html.erb +51 -0
- data/app/views/ib/executions/new.html.erb +5 -0
- data/app/views/ib/executions/show.html.erb +80 -0
- data/app/views/ib/order_states/_form.html.erb +93 -0
- data/app/views/ib/order_states/edit.html.erb +6 -0
- data/app/views/ib/order_states/index.html.erb +59 -0
- data/app/views/ib/order_states/new.html.erb +5 -0
- data/app/views/ib/order_states/show.html.erb +100 -0
- data/app/views/ib/orders/_form.html.erb +353 -0
- data/app/views/ib/orders/edit.html.erb +6 -0
- data/app/views/ib/orders/index.html.erb +193 -0
- data/app/views/ib/orders/new.html.erb +5 -0
- data/app/views/ib/orders/show.html.erb +435 -0
- data/bin/scaffold.rb +29 -0
- data/config/routes.rb +8 -1
- data/db/config.yml +5 -0
- data/db/migrate/101_add_ib_executions.rb +3 -0
- data/db/migrate/111_add_ib_bars.rb +6 -0
- data/db/migrate/121_add_ib_order_states.rb +8 -0
- data/db/migrate/131_add_ib_orders.rb +24 -0
- data/db/migrate/141_add_ib_combo_legs.rb +6 -0
- data/db/migrate/151_add_ib_underlyings.rb +3 -0
- data/db/migrate/161_add_ib_contract_details.rb +11 -0
- data/db/migrate/171_add_ib_contracts.rb +8 -1
- data/db/schema.rb +6 -5
- data/lib/ib/base.rb +3 -1
- data/lib/ib/base_properties.rb +26 -15
- data/lib/ib/connection.rb +3 -2
- data/lib/ib/errors.rb +16 -9
- data/lib/ib/extensions.rb +6 -4
- data/lib/ib/symbols.rb +10 -3
- data/lib/ib/symbols/forex.rb +49 -64
- data/lib/ib/symbols/futures.rb +2 -3
- data/lib/ib/symbols/options.rb +2 -1
- data/lib/ib/symbols/stocks.rb +2 -1
- data/lib/models/ib/bar.rb +6 -2
- data/lib/models/ib/combo_leg.rb +4 -3
- data/lib/models/ib/contract.rb +9 -5
- data/lib/models/ib/contract_detail.rb +1 -1
- data/lib/models/ib/execution.rb +3 -1
- data/lib/models/ib/order.rb +22 -20
- data/lib/models/ib/order_state.rb +4 -2
- data/lib/models/ib/underlying.rb +3 -4
- data/spec/README.md +12 -10
- data/spec/ib/symbols/symbols_spec.rb +10 -0
- data/spec/integration_helper.rb +1 -1
- data/spec/model_helper.rb +9 -8
- data/spec/models/ib/combo_leg_spec.rb +29 -28
- data/spec/models/ib/contract_detail_spec.rb +4 -1
- data/spec/models/ib/contract_spec.rb +66 -58
- data/spec/models/ib/execution_spec.rb +50 -44
- data/spec/models/ib/order_spec.rb +2 -2
- data/spec/order_helper.rb +5 -4
- data/spec/spec_helper.rb +3 -3
- metadata +59 -35
- data/app/models/ib/underlying.rb +0 -5
- data/bin/account_info +0 -29
- data/bin/cancel_orders +0 -27
- data/bin/contract_details +0 -35
- data/bin/depth_of_market +0 -43
- data/bin/fa_accounts +0 -22
- data/bin/fundamental_data +0 -39
- data/bin/historic_data +0 -51
- data/bin/historic_data_cli +0 -182
- data/bin/list_orders +0 -28
- data/bin/market_data +0 -41
- data/bin/option_data +0 -44
- data/bin/place_combo_order +0 -58
- data/bin/place_order +0 -27
- data/bin/template +0 -18
- data/bin/tick_data +0 -26
- 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,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,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,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 %>
|