ib-ruby 0.4.20 → 0.4.22
Sign up to get free protection for your applications and to get access to all the features.
- data/HISTORY +8 -0
- data/README.rdoc +16 -8
- data/VERSION +1 -1
- data/bin/historic_data +1 -2
- data/bin/time_and_sales +0 -4
- data/lib/ib-ruby/constants.rb +12 -3
- data/lib/ib-ruby/messages/incoming.rb +6 -9
- data/lib/ib-ruby/messages/outgoing.rb +46 -14
- data/lib/ib-ruby/models/contract.rb +0 -28
- data/lib/ib-ruby/models/order.rb +12 -0
- data/lib/ib-ruby/symbols/forex.rb +40 -41
- data/lib/ib-ruby/symbols/futures.rb +6 -8
- data/lib/ib-ruby/symbols/options.rb +2 -4
- data/lib/ib-ruby/symbols/stocks.rb +2 -2
- metadata +2 -9
- data/lib/legacy/bin/account_info_old +0 -36
- data/lib/legacy/bin/historic_data_old +0 -81
- data/lib/legacy/bin/market_data_old +0 -68
- data/lib/legacy/datatypes.rb +0 -485
- data/lib/legacy/ib-ruby.rb +0 -10
- data/lib/legacy/ib.rb +0 -226
- data/lib/legacy/messages.rb +0 -1458
data/HISTORY
CHANGED
data/README.rdoc
CHANGED
@@ -7,14 +7,11 @@ that is in turn forked from http://github.com/pjlegato/ib-ruby by Paul Legato.
|
|
7
7
|
|
8
8
|
== DESCRIPTION:
|
9
9
|
|
10
|
-
Ruby Implementation of the Interactive Broker' TWS API
|
11
|
-
|
12
|
-
The goal of this fork is to modernize library structure (Bundler/Gemfile/etc) and
|
13
|
-
then roll out a new version based on latest IB TWS API v.965.
|
10
|
+
Ruby Implementation of the Interactive Broker' TWS API v.965.
|
14
11
|
|
15
12
|
== FEATURES/PROBLEMS:
|
16
13
|
|
17
|
-
* This is a
|
14
|
+
* This is a BETA release, and should not be used for live trading.
|
18
15
|
Any features contained with are AS-IS and may not work in all conditions
|
19
16
|
* This code is not sanctioned or supported by Interactive Brokers
|
20
17
|
|
@@ -41,9 +38,20 @@ Ensure it is configured to allow API connections on localhost.
|
|
41
38
|
|
42
39
|
>> require 'ib-ruby'
|
43
40
|
>> ib = IB::Connection.new
|
44
|
-
>> ib.subscribe(
|
45
|
-
>> ib.
|
46
|
-
|
41
|
+
>> ib.subscribe(:Alert, :AccountValue) { |msg| puts msg.to_human }
|
42
|
+
>> ib.send :RequestAccountData, :subscribe => true
|
43
|
+
|
44
|
+
Essentially, all interaction of your code and TWS can be described as an exchange
|
45
|
+
of messages. You subscribe to message types you're interested in using
|
46
|
+
IB::Connection#subscribe and request data from TWS using IB::Connection#send.
|
47
|
+
The code blocks (or procs) given to #subscribe will be executed when a message of
|
48
|
+
requested type is received, with the received message as its argument.
|
49
|
+
|
50
|
+
Use sample scripts in /bin folder as an example of how common tasks can be
|
51
|
+
achieved using ib-ruby.
|
52
|
+
|
53
|
+
See /lib/ib-ruby/messages for a full list of TWS incoming/outgoing messages and
|
54
|
+
their attributes. Original TWS docs and code samples can be found in /misc folder.
|
47
55
|
|
48
56
|
== LICENSE:
|
49
57
|
|
data/VERSION
CHANGED
@@ -1 +1 @@
|
|
1
|
-
0.4.
|
1
|
+
0.4.22
|
data/bin/historic_data
CHANGED
@@ -26,7 +26,7 @@ Timeout = 10 # How long to wait for messages from TWS before exiting, sec
|
|
26
26
|
ib = IB::Connection.new
|
27
27
|
|
28
28
|
# Subscribe to TWS alerts/errors
|
29
|
-
ib.subscribe(
|
29
|
+
ib.subscribe(:Alert) { |msg| puts msg.to_human }
|
30
30
|
|
31
31
|
# Now, subscribe to HistoricalData incoming events. The code passed in the block
|
32
32
|
# will be executed when a message of that type is received, with the received
|
@@ -41,7 +41,6 @@ ib.subscribe(IB::Messages::Incoming::HistoricalData) do |msg|
|
|
41
41
|
@last_msg_time = Time.now.to_i
|
42
42
|
|
43
43
|
STDERR.puts " " + datum.to_s unless Quiet
|
44
|
-
#STDOUT.puts "#{datum.date},#{datum.open},#{datum.high},#{datum.low},#{datum.close},#{datum.volume}"
|
45
44
|
end
|
46
45
|
end
|
47
46
|
|
data/bin/time_and_sales
CHANGED
@@ -40,10 +40,6 @@ def show_sales_and_size(msg)
|
|
40
40
|
"#{msg.data[:size]} at #{msg.data[:price]}" : msg.to_human)
|
41
41
|
end
|
42
42
|
|
43
|
-
def show_size(msg)
|
44
|
-
return if msg.type != :last_size || msg.data[:size] < MIN_SIZE
|
45
|
-
end
|
46
|
-
|
47
43
|
# Now, subscribe to TickerPrice and TickerSize events. The code passed in the block
|
48
44
|
# will be executed when a message of that type is received, with the received message
|
49
45
|
# as its argument. In this case, we just print out the tick.
|
data/lib/ib-ruby/constants.rb
CHANGED
@@ -7,15 +7,24 @@ module IB
|
|
7
7
|
# 2 => "PROFILES",
|
8
8
|
# 3 =>"ALIASES"}
|
9
9
|
|
10
|
-
# Enumeration of data types
|
11
|
-
DATA_TYPES = [:trades, :midpoint, :bid, :ask]
|
12
|
-
|
13
10
|
# Enumeration of bar size types for convenience.
|
14
11
|
# Bar sizes less than 30 seconds do not work for some securities.
|
15
12
|
BAR_SIZES = ['1 sec', '5 secs', '15 secs', '30 secs',
|
16
13
|
'1 min', '2 mins', '3 mins', '5 mins',
|
17
14
|
'15 mins', '30 mins', '1 hour', '1 day']
|
18
15
|
|
16
|
+
# Enumeration of data types
|
17
|
+
DATA_TYPES = [:trades, :midpoint, :bid, :ask]
|
18
|
+
|
19
|
+
# Valid security types (sec_type attribute)
|
20
|
+
SECURITY_TYPES = {:stock => "STK",
|
21
|
+
:option => "OPT",
|
22
|
+
:future => "FUT",
|
23
|
+
:index => "IND",
|
24
|
+
:futures_option => "FOP",
|
25
|
+
:forex => "CASH",
|
26
|
+
:bag => "BAG"}
|
27
|
+
|
19
28
|
# Tick types as received in TickPrice and TickSize messages (enumeration)
|
20
29
|
TICK_TYPES = {
|
21
30
|
# int id => :Description # Corresponding API Event/Function/Method
|
@@ -446,10 +446,10 @@ module IB
|
|
446
446
|
under_comp_present = (@socket.read_int == 1)
|
447
447
|
|
448
448
|
if under_comp_present
|
449
|
-
@contract.under_comp =
|
450
|
-
|
451
|
-
|
452
|
-
|
449
|
+
@contract.under_comp = true
|
450
|
+
@contract.under_con_id = @socket.read_int
|
451
|
+
@contract.under_delta = @socket.read_decimal
|
452
|
+
@contract.under_price = @socket.read_decimal
|
453
453
|
end
|
454
454
|
|
455
455
|
@order.algo_strategy = @socket.read_string
|
@@ -597,7 +597,6 @@ module IB
|
|
597
597
|
# :results - an Array of Historical Data Bars
|
598
598
|
# :start_date
|
599
599
|
# :end_date
|
600
|
-
# :completed_indicator - string in stupid legacy format
|
601
600
|
class HistoricalData < AbstractMessage
|
602
601
|
@message_id = 17
|
603
602
|
|
@@ -608,9 +607,6 @@ module IB
|
|
608
607
|
[:end_date, :string],
|
609
608
|
[:count, :int]
|
610
609
|
|
611
|
-
@data[:completed_indicator] =
|
612
|
-
"finished-#{@data[:start_date]}-#{@data[:end_date]}"
|
613
|
-
|
614
610
|
@data[:results] = Array.new(@data[:count]) do |index|
|
615
611
|
Models::Bar.new :date => @socket.read_string,
|
616
612
|
:open => @socket.read_decimal,
|
@@ -625,7 +621,8 @@ module IB
|
|
625
621
|
end
|
626
622
|
|
627
623
|
def to_human
|
628
|
-
"<HistoricalData: req id #{@data[:id]}, #{@data[:item_count]
|
624
|
+
"<HistoricalData: req id #{@data[:id]}, #{@data[:item_count]
|
625
|
+
} items, from #{@data[:start_date_str]} to #{@data[:end_date_str]}>"
|
629
626
|
end
|
630
627
|
end # HistoricalData
|
631
628
|
|
@@ -368,10 +368,19 @@ module IB
|
|
368
368
|
|
369
369
|
# data = { :id => ticker_id (int),
|
370
370
|
# :contract => Contract,
|
371
|
-
# :exercise_action => int,
|
372
|
-
# :exercise_quantity => int,
|
371
|
+
# :exercise_action => int, 1 = exercise, 2 = lapse
|
372
|
+
# :exercise_quantity => int, The number of contracts to be exercised
|
373
373
|
# :account => string,
|
374
|
-
# :override => int
|
374
|
+
# :override => int: Specifies whether your setting will override the
|
375
|
+
# system's natural action. For example, if your action
|
376
|
+
# is "exercise" and the option is not in-the-money, by
|
377
|
+
# natural action the option would not exercise. If you
|
378
|
+
# have override set to "yes" the natural action would be
|
379
|
+
# overridden and the out-of-the money option would be
|
380
|
+
# exercised. Values are:
|
381
|
+
# � 0 = do not override
|
382
|
+
# � 1 = override
|
383
|
+
# }
|
375
384
|
class ExerciseOptions < AbstractMessage
|
376
385
|
@message_id = 21
|
377
386
|
|
@@ -385,7 +394,9 @@ module IB
|
|
385
394
|
end
|
386
395
|
end # ExerciseOptions
|
387
396
|
|
388
|
-
# Data format is { :id => order_id (int),
|
397
|
+
# Data format is { :id => order_id (int),
|
398
|
+
# :contract => Contract,
|
399
|
+
# :order => Order }
|
389
400
|
class PlaceOrder < AbstractMessage
|
390
401
|
@message_id = 3
|
391
402
|
@version = 31
|
@@ -457,29 +468,50 @@ module IB
|
|
457
468
|
@data[:order].clearing_intent,
|
458
469
|
@data[:order].not_held,
|
459
470
|
@data[:contract].serialize_under_comp,
|
460
|
-
@data[:
|
471
|
+
@data[:order].serialize_algo,
|
461
472
|
@data[:order].what_if]
|
462
473
|
end
|
463
474
|
end # PlaceOrder
|
464
475
|
|
465
|
-
#
|
476
|
+
# When this message is sent, TWS responds with ExecutionData messages, each
|
477
|
+
# containing the execution report that meets the specified criteria.
|
478
|
+
# @data={:id => int: :request_id,
|
479
|
+
# :client_id => int: Filter the results based on the clientId.
|
480
|
+
# :acct_code => Filter the results based on based on account code.
|
481
|
+
# Note: this is only relevant for Financial Advisor accts.
|
482
|
+
# :sec_type => Filter the results based on the order security type.
|
483
|
+
# :time => Filter the results based on execution reports received
|
484
|
+
# after the specified time - format "yyyymmdd-hh:mm:ss"
|
485
|
+
# :symbol => Filter the results based on the order symbol.
|
486
|
+
# :exchange => Filter the results based on the order exchange
|
487
|
+
# :side => Filter the results based on the order action: BUY/SELL/SSHORT
|
466
488
|
class RequestExecutions < AbstractMessage
|
467
489
|
@message_id = 7
|
468
490
|
@version = 3
|
469
491
|
|
470
492
|
def encode
|
493
|
+
|
471
494
|
[super,
|
472
|
-
@data[:
|
473
|
-
@data[:
|
474
|
-
@data[:
|
475
|
-
@data[:
|
476
|
-
@data[:
|
477
|
-
@data[:
|
478
|
-
@data[:
|
495
|
+
@data[:client_id],
|
496
|
+
@data[:acct_code],
|
497
|
+
@data[:time], # Valid format for time is "yyyymmdd-hh:mm:ss"
|
498
|
+
@data[:symbol],
|
499
|
+
@data[:sec_type],
|
500
|
+
@data[:exchange],
|
501
|
+
@data[:side]]
|
479
502
|
end # encode
|
480
503
|
end # RequestExecutions
|
481
504
|
|
482
|
-
#
|
505
|
+
# Send this message to receive Reuters global fundamental data. There must be
|
506
|
+
# a subscription to Reuters Fundamental set up in Account Management before
|
507
|
+
# you can receive this data.
|
508
|
+
# data = { :id => int: :request_id,
|
509
|
+
# :contract => Contract,
|
510
|
+
# :report_type => String: one of the following:
|
511
|
+
# Estimates
|
512
|
+
# Financial Statements
|
513
|
+
# Summary
|
514
|
+
# }
|
483
515
|
class RequestFundamentalData < AbstractMessage
|
484
516
|
@message_id = 52
|
485
517
|
|
@@ -6,15 +6,6 @@ module IB
|
|
6
6
|
module Models
|
7
7
|
class Contract < Model
|
8
8
|
|
9
|
-
# Valid security types (sec_type attribute)
|
10
|
-
SECURITY_TYPES = {:stock => "STK",
|
11
|
-
:option => "OPT",
|
12
|
-
:future => "FUT",
|
13
|
-
:index => "IND",
|
14
|
-
:futures_option => "FOP",
|
15
|
-
:forex => "CASH",
|
16
|
-
:bag => "BAG"}
|
17
|
-
|
18
9
|
BAG_SEC_TYPE = "BAG"
|
19
10
|
|
20
11
|
# Fields are Strings unless noted otherwise
|
@@ -237,25 +228,6 @@ module IB
|
|
237
228
|
end
|
238
229
|
end
|
239
230
|
|
240
|
-
def serialize_algo(*args)
|
241
|
-
raise "Unimplemented"
|
242
|
-
#if (m_serverVersion >= MIN_SERVER_VER_ALGO_ORDERS) {
|
243
|
-
# send( order.m_algoStrategy);
|
244
|
-
# if( !IsEmpty(order.m_algoStrategy)) {
|
245
|
-
# java.util.Vector algoParams = order.m_algoParams;
|
246
|
-
# int algoParamsCount = algoParams == null ? 0 : algoParams.size();
|
247
|
-
# send( algoParamsCount);
|
248
|
-
# if( algoParamsCount > 0) {
|
249
|
-
# for( int i = 0; i < algoParamsCount; ++i) {
|
250
|
-
# TagValue tagValue = (TagValue)algoParams.get(i);
|
251
|
-
# send( tagValue.m_tag);
|
252
|
-
# send( tagValue.m_value);
|
253
|
-
# }
|
254
|
-
# }
|
255
|
-
# }
|
256
|
-
#}
|
257
|
-
end
|
258
|
-
|
259
231
|
# Some messages send open_close too, some don't. WTF.
|
260
232
|
def serialize_combo_legs(type = :short)
|
261
233
|
# No idea what "BAG" means. Copied from the Java code.
|
data/lib/ib-ruby/models/order.rb
CHANGED
@@ -228,6 +228,8 @@ module IB
|
|
228
228
|
@delta_neutral_order_type = ''
|
229
229
|
@what_if = false
|
230
230
|
@not_held = false
|
231
|
+
@algo_strategy = ''
|
232
|
+
@algo_params = []
|
231
233
|
|
232
234
|
# TODO: Initialize with nil instead of Max_Value, or change
|
233
235
|
# Order sending code in IB::Messages::Outgoing::PlaceOrder
|
@@ -257,6 +259,16 @@ module IB
|
|
257
259
|
super opts
|
258
260
|
end
|
259
261
|
|
262
|
+
def serialize_algo(*args)
|
263
|
+
if algo_strategy.empty? || algo_strategy.nil?
|
264
|
+
['']
|
265
|
+
else
|
266
|
+
[algo_strategy,
|
267
|
+
algo_params.size,
|
268
|
+
algo_params.to_a]
|
269
|
+
end
|
270
|
+
end
|
271
|
+
|
260
272
|
end # class Order
|
261
273
|
end # module Models
|
262
274
|
end # module IB
|
@@ -1,4 +1,3 @@
|
|
1
|
-
|
2
1
|
# Note that the :description field is particular to ib-ruby, and is NOT part of the standard TWS API.
|
3
2
|
# It is never transmitted to IB. It's purely used clientside, and you can store any arbitrary string that
|
4
3
|
# you may find useful there.
|
@@ -6,64 +5,64 @@ module IB
|
|
6
5
|
module Symbols
|
7
6
|
Forex = {
|
8
7
|
:audusd => Models::Contract.new(:symbol => "AUD",
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
8
|
+
:exchange => "IDEALPRO",
|
9
|
+
:currency => "USD",
|
10
|
+
:sec_type => SECURITY_TYPES[:forex],
|
11
|
+
:description => "AUDUSD"),
|
13
12
|
|
14
13
|
:gbpusd => Models::Contract.new(:symbol => "GBP",
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
14
|
+
:exchange => "IDEALPRO",
|
15
|
+
:currency => "USD",
|
16
|
+
:sec_type => SECURITY_TYPES[:forex],
|
17
|
+
:description => "GBPUSD"),
|
19
18
|
|
20
19
|
:euraud => Models::Contract.new(:symbol => "EUR",
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
20
|
+
:exchange => "IDEALPRO",
|
21
|
+
:currency => "AUD",
|
22
|
+
:sec_type => SECURITY_TYPES[:forex],
|
23
|
+
:description => "EURAUD"),
|
25
24
|
|
26
25
|
:eurgbp => Models::Contract.new(:symbol => "EUR",
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
26
|
+
:exchange => "IDEALPRO",
|
27
|
+
:currency => "GBP",
|
28
|
+
:sec_type => SECURITY_TYPES[:forex],
|
29
|
+
:description => "EURGBP"),
|
31
30
|
|
32
31
|
:eurjpy => Models::Contract.new(:symbol => "EUR",
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
32
|
+
:exchange => "IDEALPRO",
|
33
|
+
:currency => "JPY",
|
34
|
+
:sec_type => SECURITY_TYPES[:forex],
|
35
|
+
:description => "EURJPY"),
|
37
36
|
|
38
37
|
:eurusd => Models::Contract.new(:symbol => "EUR",
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
38
|
+
:exchange => "IDEALPRO",
|
39
|
+
:currency => "USD",
|
40
|
+
:sec_type => SECURITY_TYPES[:forex],
|
41
|
+
:description => "EURUSD"),
|
43
42
|
|
44
43
|
:eurcad => Models::Contract.new(:symbol => "EUR",
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
44
|
+
:exchange => "IDEALPRO",
|
45
|
+
:currency => "CAD",
|
46
|
+
:sec_type => SECURITY_TYPES[:forex],
|
47
|
+
:description => "EURCAD"),
|
49
48
|
|
50
49
|
:usdchf => Models::Contract.new(:symbol => "USD",
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
50
|
+
:exchange => "IDEALPRO",
|
51
|
+
:currency => "CHF",
|
52
|
+
:sec_type => SECURITY_TYPES[:forex],
|
53
|
+
:description => "USDCHF"),
|
55
54
|
|
56
55
|
:usdcad => Models::Contract.new(:symbol => "USD",
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
56
|
+
:exchange => "IDEALPRO",
|
57
|
+
:currency => "CAD",
|
58
|
+
:sec_type => SECURITY_TYPES[:forex],
|
59
|
+
:description => "USDCAD"),
|
61
60
|
|
62
61
|
:usdjpy => Models::Contract.new(:symbol => "USD",
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
62
|
+
:exchange => "IDEALPRO",
|
63
|
+
:currency => "JPY",
|
64
|
+
:sec_type => SECURITY_TYPES[:forex],
|
65
|
+
:description => "USDJPY")
|
67
66
|
}
|
68
67
|
end # Contracts
|
69
68
|
end
|
@@ -18,8 +18,6 @@ module IB
|
|
18
18
|
# N.B. This will not work as expected near/after expiration during that month, as
|
19
19
|
# volume rolls over to the next quarter even though the current month is still valid!
|
20
20
|
#
|
21
|
-
|
22
|
-
|
23
21
|
def self.next_quarter_month(time)
|
24
22
|
sprintf("%02d", [3, 6, 9, 12].find { |month| month >= time.month })
|
25
23
|
end
|
@@ -41,14 +39,14 @@ module IB
|
|
41
39
|
:expiry => self.next_expiry(Time.now),
|
42
40
|
:exchange => "ECBOT",
|
43
41
|
:currency => "USD",
|
44
|
-
:sec_type =>
|
42
|
+
:sec_type => SECURITY_TYPES[:future],
|
45
43
|
:description => "Mini Dow Jones Industrial"),
|
46
44
|
|
47
45
|
:es => Models::Contract.new(:symbol => "ES",
|
48
46
|
:expiry => self.next_expiry(Time.now),
|
49
47
|
:exchange => "GLOBEX",
|
50
48
|
:currency => "USD",
|
51
|
-
:sec_type =>
|
49
|
+
:sec_type => SECURITY_TYPES[:future],
|
52
50
|
:multiplier => 50,
|
53
51
|
:description => "E-Mini S&P 500"),
|
54
52
|
|
@@ -56,7 +54,7 @@ module IB
|
|
56
54
|
:expiry => self.next_expiry(Time.now),
|
57
55
|
:exchange => "GLOBEX",
|
58
56
|
:currency => "USD",
|
59
|
-
:sec_type =>
|
57
|
+
:sec_type => SECURITY_TYPES[:future],
|
60
58
|
:multiplier => 62500,
|
61
59
|
:description => "British Pounds"),
|
62
60
|
|
@@ -64,7 +62,7 @@ module IB
|
|
64
62
|
:expiry => self.next_expiry(Time.now),
|
65
63
|
:exchange => "GLOBEX",
|
66
64
|
:currency => "USD",
|
67
|
-
:sec_type =>
|
65
|
+
:sec_type => SECURITY_TYPES[:future],
|
68
66
|
:multiplier => 12500,
|
69
67
|
:description => "Euro FX"),
|
70
68
|
|
@@ -72,7 +70,7 @@ module IB
|
|
72
70
|
:expiry => self.next_expiry(Time.now),
|
73
71
|
:exchange => "GLOBEX",
|
74
72
|
:currency => "USD",
|
75
|
-
:sec_type =>
|
73
|
+
:sec_type => SECURITY_TYPES[:future],
|
76
74
|
:multiplier => 12500000,
|
77
75
|
:description => "Japanese Yen"),
|
78
76
|
|
@@ -80,7 +78,7 @@ module IB
|
|
80
78
|
:expiry => self.next_expiry(Time.now),
|
81
79
|
:exchange => "HKFE",
|
82
80
|
:currency => "HKD",
|
83
|
-
:sec_type =>
|
81
|
+
:sec_type => SECURITY_TYPES[:future],
|
84
82
|
:multiplier => 50,
|
85
83
|
:description => "Hang Seng Index")
|
86
84
|
}
|
@@ -10,19 +10,17 @@ module IB
|
|
10
10
|
Options =
|
11
11
|
{:wfc20 => Models::Contract.new(:symbol => "WFC",
|
12
12
|
:exchange => "SMART",
|
13
|
-
#:currency => "USD",
|
14
13
|
:expiry => "201110",
|
15
14
|
:right => "CALL",
|
16
15
|
:strike => 20.0,
|
17
|
-
:sec_type =>
|
16
|
+
:sec_type => SECURITY_TYPES[:option],
|
18
17
|
:description => "Wells Fargo 20 Call 2011-10"),
|
19
18
|
:z50 => Models::Contract.new(:symbol => "Z",
|
20
19
|
:exchange => "LIFFE",
|
21
|
-
#:currency => "USD",
|
22
20
|
:expiry => "201110",
|
23
21
|
:right => "CALL",
|
24
22
|
:strike => 50.0,
|
25
|
-
:sec_type =>
|
23
|
+
:sec_type => SECURITY_TYPES[:option],
|
26
24
|
:description => " FTSE-100 index 50 Call 2011-10"),
|
27
25
|
|
28
26
|
}
|
@@ -11,12 +11,12 @@ module IB
|
|
11
11
|
{:wfc => Models::Contract.new(:symbol => "WFC",
|
12
12
|
:exchange => "NYSE",
|
13
13
|
:currency => "USD",
|
14
|
-
:sec_type =>
|
14
|
+
:sec_type => SECURITY_TYPES[:stock],
|
15
15
|
:description => "Wells Fargo"),
|
16
16
|
:wrong => Models::Contract.new(:symbol => "QEEUUE",
|
17
17
|
:exchange => "NYSE",
|
18
18
|
:currency => "USD",
|
19
|
-
:sec_type =>
|
19
|
+
:sec_type => SECURITY_TYPES[:stock],
|
20
20
|
:description => "Inexistent stock"),
|
21
21
|
}
|
22
22
|
end
|
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: ib-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.4.
|
5
|
+
version: 0.4.22
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- arvicco
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-09-
|
13
|
+
date: 2011-09-20 00:00:00 +04:00
|
14
14
|
default_executable:
|
15
15
|
dependencies:
|
16
16
|
- !ruby/object:Gem::Dependency
|
@@ -81,13 +81,6 @@ files:
|
|
81
81
|
- lib/ib-ruby/symbols/stocks.rb
|
82
82
|
- lib/ib-ruby/symbols.rb
|
83
83
|
- lib/ib-ruby.rb
|
84
|
-
- lib/legacy/bin/account_info_old
|
85
|
-
- lib/legacy/bin/historic_data_old
|
86
|
-
- lib/legacy/bin/market_data_old
|
87
|
-
- lib/legacy/datatypes.rb
|
88
|
-
- lib/legacy/ib-ruby.rb
|
89
|
-
- lib/legacy/ib.rb
|
90
|
-
- lib/legacy/messages.rb
|
91
84
|
- lib/version.rb
|
92
85
|
- spec/ib-ruby/models/contract_spec.rb
|
93
86
|
- spec/ib-ruby/models/order_spec.rb
|
@@ -1,36 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This script connects to IB API, subscribes to account info and prints out
|
4
|
-
# messages received from IB (update every 3 minute or so)
|
5
|
-
|
6
|
-
require 'pathname'
|
7
|
-
LIB_DIR = (Pathname.new(__FILE__).dirname + '../lib/').realpath.to_s
|
8
|
-
$LOAD_PATH.unshift LIB_DIR unless $LOAD_PATH.include?(LIB_DIR)
|
9
|
-
|
10
|
-
require 'rubygems'
|
11
|
-
require 'bundler/setup'
|
12
|
-
require 'ib-ruby'
|
13
|
-
|
14
|
-
# First, connect to IB TWS.
|
15
|
-
ib = IB::IB.new
|
16
|
-
|
17
|
-
# Uncomment this for verbose debug messages:
|
18
|
-
# IB::IBLogger.level = Logger::Severity::DEBUG
|
19
|
-
|
20
|
-
## Subscribe to the messages that TWS sends in response to account data request
|
21
|
-
ib.subscribe(IB::IncomingMessages::AccountValue) { |msg| puts msg.to_human }
|
22
|
-
|
23
|
-
ib.subscribe(IB::IncomingMessages::PortfolioValue) { |msg| puts msg.to_human }
|
24
|
-
|
25
|
-
ib.subscribe(IB::IncomingMessages::AccountUpdateTime) { |msg| puts msg.to_human }
|
26
|
-
|
27
|
-
ib.dispatch(IB::OutgoingMessages::RequestAccountData.new(:subscribe => true,
|
28
|
-
:account_code => ''))
|
29
|
-
|
30
|
-
puts "\nSubscribing to IB account data"
|
31
|
-
puts "\n******** Press <Enter> to cancel... *********\n\n"
|
32
|
-
gets
|
33
|
-
puts "Cancelling account data subscription.."
|
34
|
-
|
35
|
-
ib.dispatch(IB::OutgoingMessages::RequestAccountData.new(:subscribe => false,
|
36
|
-
:account_code => ''))
|