ib-ruby 0.8.1 → 0.8.3
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/.gitignore +0 -1
- data/HISTORY +5 -0
- data/README.md +47 -53
- data/Rakefile +2 -1
- data/VERSION +1 -1
- data/app/assets/javascripts/ib/application.js +15 -0
- data/app/assets/javascripts/ib/underlyings.js +2 -0
- data/app/assets/stylesheets/ib/application.css +13 -0
- data/app/assets/stylesheets/ib/underlyings.css +4 -0
- data/app/assets/stylesheets/scaffold.css +56 -0
- data/app/controllers/ib/application_controller.rb +5 -0
- data/app/controllers/ib/underlyings_controller.rb +87 -0
- data/app/helpers/ib/application_helper.rb +4 -0
- data/app/helpers/ib/underlyings_helper.rb +4 -0
- data/app/models/ib/underlying.rb +5 -0
- data/app/views/ib/underlyings/_form.html.erb +33 -0
- data/app/views/ib/underlyings/edit.html.erb +6 -0
- data/app/views/ib/underlyings/index.html.erb +29 -0
- data/app/views/ib/underlyings/new.html.erb +5 -0
- data/app/views/ib/underlyings/show.html.erb +25 -0
- data/app/views/layouts/ib/application.html.erb +14 -0
- data/config/routes.rb +6 -0
- data/db/config.yml +19 -0
- data/db/migrate/{101_add_executions.rb → 101_add_ib_executions.rb} +2 -2
- data/db/migrate/{111_add_bars.rb → 111_add_ib_bars.rb} +2 -2
- data/db/migrate/{121_add_order_states.rb → 121_add_ib_order_states.rb} +2 -2
- data/db/migrate/{131_add_orders.rb → 131_add_ib_orders.rb} +2 -2
- data/db/migrate/{141_add_combo_legs.rb → 141_add_ib_combo_legs.rb} +2 -2
- data/db/migrate/{151_add_underlyings.rb → 151_add_ib_underlyings.rb} +2 -2
- data/db/migrate/{161_add_contract_details.rb → 161_add_ib_contract_details.rb} +2 -2
- data/db/migrate/{171_add_contracts.rb → 171_add_ib_contracts.rb} +2 -2
- data/db/schema.rb +245 -0
- data/lib/ib/base.rb +97 -0
- data/lib/ib/base_properties.rb +140 -0
- data/lib/{ib-ruby → ib}/connection.rb +2 -2
- data/lib/{ib-ruby → ib}/constants.rb +0 -0
- data/lib/{ib-ruby → ib}/db.rb +9 -5
- data/lib/ib/engine.rb +35 -0
- data/lib/{ib-ruby → ib}/errors.rb +0 -0
- data/lib/{ib-ruby → ib}/extensions.rb +2 -2
- data/lib/{ib-ruby → ib}/logger.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/abstract_message.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/abstract_message.rb +1 -1
- data/lib/{ib-ruby → ib}/messages/incoming/alert.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/contract_data.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/delta_neutral_validation.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/execution_data.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/historical_data.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/market_depths.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/next_valid_id.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/open_order.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/order_status.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/portfolio_value.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/real_time_bar.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/scanner_data.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming/ticks.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/incoming.rb +14 -14
- data/lib/{ib-ruby → ib}/messages/outgoing/abstract_message.rb +1 -1
- data/lib/{ib-ruby → ib}/messages/outgoing/bar_requests.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/outgoing/place_order.rb +0 -0
- data/lib/{ib-ruby → ib}/messages/outgoing.rb +5 -5
- data/lib/ib/messages.rb +8 -0
- data/lib/ib/model.rb +8 -0
- data/lib/ib/models.rb +10 -0
- data/lib/ib/requires.rb +9 -0
- data/lib/{ib-ruby → ib}/socket.rb +0 -0
- data/lib/{ib-ruby → ib}/symbols/forex.rb +1 -1
- data/lib/{ib-ruby → ib}/symbols/futures.rb +2 -2
- data/lib/{ib-ruby → ib}/symbols/options.rb +1 -1
- data/lib/{ib-ruby → ib}/symbols/stocks.rb +1 -1
- data/lib/ib/symbols.rb +9 -0
- data/lib/{ib-ruby → ib}/version.rb +0 -0
- data/lib/ib-ruby.rb +2 -24
- data/lib/ib.rb +23 -0
- data/lib/models/ib/bag.rb +51 -0
- data/lib/models/ib/bar.rb +41 -0
- data/lib/models/ib/combo_leg.rb +102 -0
- data/lib/models/ib/contract.rb +287 -0
- data/lib/models/ib/contract_detail.rb +68 -0
- data/lib/models/ib/execution.rb +62 -0
- data/lib/models/ib/option.rb +60 -0
- data/lib/models/ib/order.rb +389 -0
- data/lib/models/ib/order_state.rb +126 -0
- data/lib/models/ib/underlying.rb +35 -0
- data/spec/README.md +34 -2
- data/spec/TODO +5 -1
- data/spec/comb.rb +13 -0
- data/spec/db.rb +1 -1
- data/spec/db_helper.rb +3 -3
- data/spec/dummy.rb +13 -0
- data/spec/gw.rb +4 -0
- data/spec/{ib-ruby → ib}/connection_spec.rb +0 -0
- data/spec/{ib-ruby → ib}/messages/incoming/alert_spec.rb +0 -0
- data/spec/{ib-ruby → ib}/messages/incoming/open_order_spec.rb +0 -0
- data/spec/{ib-ruby → ib}/messages/incoming/order_status_spec.rb +16 -17
- data/spec/{ib-ruby → ib}/messages/outgoing/account_data_spec.rb +0 -0
- data/spec/{ib-ruby → ib}/messages/outgoing/market_data_type_spec.rb +0 -0
- data/spec/integration/historic_data_spec.rb +3 -3
- data/spec/integration/orders/trades_spec.rb +1 -1
- data/spec/{ib-ruby/models → models/ib}/bag_spec.rb +2 -7
- data/spec/{ib-ruby/models → models/ib}/bar_spec.rb +1 -6
- data/spec/{ib-ruby/models → models/ib}/combo_leg_spec.rb +2 -12
- data/spec/{ib-ruby/models → models/ib}/contract_detail_spec.rb +3 -8
- data/spec/{ib-ruby/models → models/ib}/contract_spec.rb +4 -12
- data/spec/{ib-ruby/models → models/ib}/execution_spec.rb +2 -7
- data/spec/{ib-ruby/models → models/ib}/option_spec.rb +1 -6
- data/spec/{ib-ruby/models → models/ib}/order_spec.rb +5 -10
- data/spec/{ib-ruby/models → models/ib}/order_state_spec.rb +2 -7
- data/spec/{ib-ruby/models → models/ib}/underlying_spec.rb +3 -7
- data/spec/my.rb +5 -0
- data/spec/spec_helper.rb +62 -36
- metadata +417 -544
- data/lib/ib-ruby/messages.rb +0 -8
- data/lib/ib-ruby/models/bag.rb +0 -54
- data/lib/ib-ruby/models/bar.rb +0 -43
- data/lib/ib-ruby/models/combo_leg.rb +0 -104
- data/lib/ib-ruby/models/contract.rb +0 -287
- data/lib/ib-ruby/models/contract_detail.rb +0 -70
- data/lib/ib-ruby/models/execution.rb +0 -64
- data/lib/ib-ruby/models/model.rb +0 -105
- data/lib/ib-ruby/models/model_properties.rb +0 -146
- data/lib/ib-ruby/models/option.rb +0 -62
- data/lib/ib-ruby/models/order.rb +0 -389
- data/lib/ib-ruby/models/order_state.rb +0 -128
- data/lib/ib-ruby/models/underlying.rb +0 -36
- data/lib/ib-ruby/models.rb +0 -15
- data/lib/ib-ruby/symbols.rb +0 -9
- data/spec/test.rb +0 -61
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'model_helper'
|
|
2
2
|
|
|
3
|
-
describe IB::
|
|
3
|
+
describe IB::OrderState,
|
|
4
4
|
:props =>
|
|
5
5
|
{:local_id => 23,
|
|
6
6
|
:perm_id => 173276893,
|
|
@@ -42,11 +42,6 @@ describe IB::Models::OrderState,
|
|
|
42
42
|
it_behaves_like 'Self-equal Model'
|
|
43
43
|
it_behaves_like 'Model with invalid defaults'
|
|
44
44
|
|
|
45
|
-
it 'has class name shortcut' do
|
|
46
|
-
IB::OrderState.should == IB::Models::OrderState
|
|
47
|
-
IB::OrderState.new.should == IB::Models::OrderState.new
|
|
48
|
-
end
|
|
49
|
-
|
|
50
45
|
context '#update_missing' do
|
|
51
46
|
let(:nil_state) { IB::OrderState.new(:filled => nil, :remaining => nil,
|
|
52
47
|
:price => nil, :average_price => nil) }
|
|
@@ -108,4 +103,4 @@ describe IB::Models::OrderState,
|
|
|
108
103
|
subject.should_not be_submitted
|
|
109
104
|
end
|
|
110
105
|
|
|
111
|
-
end # describe IB::
|
|
106
|
+
end # describe IB::OrderState
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
require 'model_helper'
|
|
2
2
|
|
|
3
|
-
describe IB::
|
|
3
|
+
describe IB::Underlying,
|
|
4
4
|
:props =>
|
|
5
5
|
{:con_id => 234567,
|
|
6
6
|
:delta => 0.55,
|
|
@@ -17,13 +17,9 @@ describe IB::Models::Underlying,
|
|
|
17
17
|
:assigns =>
|
|
18
18
|
{[:con_id, :delta, :price] => numeric_assigns,
|
|
19
19
|
|
|
20
|
-
} do
|
|
20
|
+
} do
|
|
21
21
|
|
|
22
22
|
it_behaves_like 'Self-equal Model'
|
|
23
23
|
it_behaves_like 'Model with invalid defaults'
|
|
24
24
|
|
|
25
|
-
|
|
26
|
-
IB::Underlying.should == IB::Models::Underlying
|
|
27
|
-
IB::Underlying.new.should == IB::Models::Underlying.new
|
|
28
|
-
end
|
|
29
|
-
end # describe IB::Contract
|
|
25
|
+
end # describe IB::ib/
|
data/spec/my.rb
ADDED
data/spec/spec_helper.rb
CHANGED
|
@@ -1,61 +1,87 @@
|
|
|
1
1
|
require 'rspec'
|
|
2
|
-
require 'ib
|
|
2
|
+
require 'ib'
|
|
3
3
|
|
|
4
|
-
|
|
4
|
+
# Configure top level option indicating how the test suite should be run
|
|
5
5
|
|
|
6
|
-
# Top (test suite) level metadata
|
|
7
6
|
OPTS ||= {
|
|
8
|
-
|
|
9
|
-
|
|
7
|
+
:verbose => false, #true, # Run test suite in a verbose mode ?
|
|
8
|
+
:brokertron => false, # Use mock (Brokertron) instead of paper account ?
|
|
9
|
+
:db => IB.db_backed?,
|
|
10
|
+
:rails => IB.rails?
|
|
10
11
|
}
|
|
11
12
|
|
|
12
13
|
if OPTS[:brokertron]
|
|
14
|
+
puts "Using Brokerton free.brokertron.com mock service."
|
|
13
15
|
# Connection to mock (Brokertron) account
|
|
14
|
-
OPTS[:connection] =
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
16
|
+
OPTS[:connection] = {
|
|
17
|
+
:client_id => 1111, # Client id that identifies the test suit
|
|
18
|
+
:host => 'free.brokertron.com',
|
|
19
|
+
:port => 10501
|
|
20
|
+
}
|
|
19
21
|
else
|
|
20
22
|
# Connection to IB PAPER ACCOUNT
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
23
|
+
ACCOUNT ||= 'DU60320'
|
|
24
|
+
HOST ||= '127.0.0.1'
|
|
25
|
+
PORT ||= 7496
|
|
26
|
+
|
|
27
|
+
OPTS[:connection] = {
|
|
28
|
+
:account => ACCOUNT, # Your IB PAPER ACCOUNT, tests will only run against it
|
|
29
|
+
:host => HOST, # Where your TWS/gateway is located, likely '127.0.0.1'
|
|
30
|
+
:port => PORT, # 4001 for Gateway, 7496 for TWS GUI
|
|
31
|
+
:client_id => 1111, # Client id that identifies the test suit
|
|
32
|
+
:reuters => true # Subscription to Reuters data enabled ?
|
|
33
|
+
}
|
|
28
34
|
end
|
|
29
35
|
|
|
30
36
|
RSpec.configure do |config|
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
when :us_trading_hours
|
|
36
|
-
# 09:30 - 16:00 (ET) Mon-Fri 14:30 - 21:00 (UTC)
|
|
37
|
-
!(t.wday >= 1 && t.wday <= 5 && t.hour >= 15 && t.hour <= 21)
|
|
38
|
-
when :forex_trading_hours
|
|
39
|
-
# 17:15 - 17:00 (ET) Sunday-Friday Forex 22:15 - 22:00 (UTC)
|
|
40
|
-
!(t.wday > 0 && t.wday < 5 || t.wday == 5 && t.hour < 22)
|
|
41
|
-
end
|
|
42
|
-
end,
|
|
43
|
-
|
|
44
|
-
:db => proc { |condition| !IB::DB == condition }, # true/false
|
|
45
|
-
|
|
46
|
-
:reuters => proc { |condition| !OPTS[:connection][:reuters] == condition } # true/false
|
|
47
|
-
}
|
|
37
|
+
|
|
38
|
+
puts "Running specs '#{config.pattern}' with OPTS:"
|
|
39
|
+
pp OPTS
|
|
40
|
+
|
|
48
41
|
# config.filter = { :focus => true }
|
|
49
42
|
# config.include(UserExampleHelpers)
|
|
50
43
|
# config.mock_with :mocha
|
|
51
44
|
# config.mock_with :flexmock
|
|
52
45
|
# config.mock_with :rr
|
|
53
46
|
|
|
54
|
-
|
|
47
|
+
config.exclusion_filter = {
|
|
48
|
+
:if => proc do |condition|
|
|
49
|
+
t = Time.now.utc
|
|
50
|
+
case condition # NB: excludes if condition is false!
|
|
51
|
+
when :us_trading_hours
|
|
52
|
+
# 09:30 - 16:00 (ET) Mon-Fri 14:30 - 21:00 (UTC)
|
|
53
|
+
!(t.wday >= 1 && t.wday <= 5 && t.hour >= 15 && t.hour <= 21)
|
|
54
|
+
when :forex_trading_hours
|
|
55
|
+
# 17:15 - 17:00 (ET) Sunday-Friday Forex 22:15 - 22:00 (UTC)
|
|
56
|
+
!(t.wday > 0 && t.wday < 5 || t.wday == 5 && t.hour < 22)
|
|
57
|
+
end
|
|
58
|
+
end,
|
|
59
|
+
|
|
60
|
+
:db => proc { |condition| IB.db_backed? != condition }, # true/false
|
|
61
|
+
|
|
62
|
+
:rails => proc { |condition| IB.rails? != condition }, # true/false
|
|
63
|
+
|
|
64
|
+
:reuters => proc { |condition| !OPTS[:connection][:reuters] == condition }, # true/false
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
if OPTS[:db]
|
|
68
|
+
require 'database_cleaner'
|
|
69
|
+
|
|
55
70
|
config.before(:suite) do
|
|
56
71
|
DatabaseCleaner.strategy = :truncation
|
|
57
72
|
DatabaseCleaner.clean
|
|
58
73
|
end
|
|
74
|
+
|
|
75
|
+
config.after(:suite) do
|
|
76
|
+
DatabaseCleaner.clean
|
|
77
|
+
end
|
|
59
78
|
end
|
|
60
|
-
end
|
|
61
79
|
|
|
80
|
+
if OPTS[:rails]
|
|
81
|
+
config.include IB::Engine.routes.url_helpers,
|
|
82
|
+
:example_group => {:file_path => /\brails_spec\//}
|
|
83
|
+
|
|
84
|
+
config.include Capybara::DSL,
|
|
85
|
+
:example_group => { :file_path => /\brails_spec\//}
|
|
86
|
+
end
|
|
87
|
+
end
|