wdevauld-ib-ruby 0.2 → 0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/History.txt +3 -0
- data/README.txt +6 -1
- data/bin/AccountInfo +3 -7
- data/bin/HistoricToCSV +4 -22
- data/bin/RequestHistoricData +8 -19
- data/bin/RequestMarketData +3 -6
- data/bin/SimpleTimeAndSales +3 -6
- data/lib/ib-ruby.rb +1 -1
- data/lib/ib-ruby/datatypes.rb +5 -7
- data/lib/ib-ruby/symbols/forex.rb +1 -6
- data/lib/ib-ruby/symbols/futures.rb +1 -6
- data/test/test_ib-ruby.rb +2 -3
- metadata +2 -2
data/History.txt
CHANGED
data/README.txt
CHANGED
@@ -21,17 +21,22 @@ Copyright (C) 2009 Wes Devauld
|
|
21
21
|
First, start up Interactive Broker's Trader Work Station. Ensure it is configured to allow API connections on localhost
|
22
22
|
|
23
23
|
>> require 'ib-ruby'
|
24
|
-
>> ib_connection = IB
|
24
|
+
>> ib_connection = IB::IB.new()
|
25
25
|
|
26
26
|
== REQUIREMENTS:
|
27
27
|
|
28
28
|
* FIXME List all the requirements
|
29
29
|
|
30
30
|
== INSTALL:
|
31
|
+
=== From Gem ===
|
31
32
|
|
32
33
|
* Ensure that http://gems.github.com is in your gem sources
|
33
34
|
* sudo gem install wdevauld-ib-ruby
|
34
35
|
|
36
|
+
=== From Source ===
|
37
|
+
* git clone http://github.com/wdevauld/ib-ruby
|
38
|
+
* cd ib-ruby; rake gem:install
|
39
|
+
|
35
40
|
== LICENSE:
|
36
41
|
|
37
42
|
This library is free software; you can redistribute it and/or modify
|
data/bin/AccountInfo
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
#
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2009 Wes Devauld
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -16,13 +16,9 @@
|
|
16
16
|
# License along with this library; if not, write to the Free Software
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
18
|
# 02110-1301 USA
|
19
|
-
#
|
20
|
-
|
21
|
-
$:.push(File.dirname(__FILE__) + "/../")
|
22
19
|
|
23
|
-
require
|
24
|
-
|
25
|
-
require 'symbols/futures'
|
20
|
+
require File.expand_path(
|
21
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'ib-ruby'))
|
26
22
|
|
27
23
|
# First, connect to IB TWS.
|
28
24
|
ib = IB::IB.new
|
data/bin/HistoricToCSV
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
#
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2009 Wes Devauld
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -17,29 +17,11 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
18
|
# 02110-1301 USA
|
19
19
|
#
|
20
|
-
|
20
|
+
# TODO Fix the Historical command line client
|
21
21
|
#
|
22
|
-
# This program demonstrates how to download historic data and write it
|
23
|
-
# to a CSV file.
|
24
|
-
#
|
25
|
-
# To use, set CSV_FILE to the file you want to write (which will be
|
26
|
-
# overwritten automatically if it already exists), set the contract
|
27
|
-
# data, duration, data type (trades, bid, ask, midpoint), etc. as you
|
28
|
-
# like, and run the program.
|
29
|
-
#
|
30
|
-
# Note that it does not detect when the historic data from the server
|
31
|
-
# has stopped arriving automatically. This limitation will be
|
32
|
-
# addressed soon. For now, just press <Enter> when the data stream on
|
33
|
-
# the console stops, and the output file will be closed and the
|
34
|
-
# program terminated.
|
35
|
-
#
|
36
|
-
|
37
|
-
$:.push(File.dirname(__FILE__) + "/../")
|
38
|
-
|
39
|
-
require 'ib'
|
40
|
-
require 'datatypes'
|
41
|
-
require 'symbols/futures'
|
42
22
|
|
23
|
+
require File.expand_path(
|
24
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'ib-ruby'))
|
43
25
|
|
44
26
|
### Configurable Options
|
45
27
|
|
data/bin/RequestHistoricData
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
#
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2009 Wes Devauld
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -17,28 +17,17 @@
|
|
17
17
|
# Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA
|
18
18
|
# 02110-1301 USA
|
19
19
|
#
|
20
|
-
# >> YOUR USE OF THIS PROGRAM IS ENTIRELY AT YOUR OWN RISK. <<
|
21
|
-
# >> IT MAY CONTAIN POTENTIALLY COSTLY BUGS, ERRORS, ETC., BOTH KNOWN AND UNKNOWN. <<
|
22
|
-
#
|
23
|
-
|
24
|
-
$:.push(File.dirname(__FILE__) + "/../")
|
25
|
-
|
26
|
-
# IB-Ruby libraries
|
27
|
-
require 'ib'
|
28
|
-
require 'datatypes'
|
29
|
-
require 'symbols/futures'
|
30
20
|
|
31
|
-
|
32
|
-
|
21
|
+
require File.expand_path(
|
22
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'ib-ruby'))
|
33
23
|
|
34
|
-
# Gems - requires duration and getopt.
|
35
24
|
require 'rubygems'
|
25
|
+
require 'time'
|
36
26
|
require 'duration'
|
37
27
|
require 'getopt/long'
|
38
28
|
|
39
|
-
|
40
|
-
require "getopt/long"
|
41
29
|
include Getopt
|
30
|
+
|
42
31
|
opt = Getopt::Long.getopts(
|
43
32
|
["--help", BOOLEAN],
|
44
33
|
["--end", REQUIRED],
|
@@ -245,13 +234,13 @@ ib = IB::IB.new
|
|
245
234
|
|
246
235
|
|
247
236
|
# Default level is quiet, only warnings printed.
|
248
|
-
IB::IBLogger.level = Logger::Severity::ERROR
|
237
|
+
# IB::IBLogger.level = Logger::Severity::ERROR
|
249
238
|
|
250
239
|
# For verbose printing of each message:
|
251
|
-
IB::IBLogger.level = Logger::Severity::INFO if VERBOSE
|
240
|
+
# IB::IBLogger.level = Logger::Severity::INFO if VERBOSE
|
252
241
|
|
253
242
|
# For very verbose debug messages:
|
254
|
-
IB::IBLogger.level = Logger::Severity::DEBUG if VERYVERBOSE
|
243
|
+
# IB::IBLogger.level = Logger::Severity::DEBUG if VERYVERBOSE
|
255
244
|
|
256
245
|
puts "datetime,open,high,low,close,volume,wap,has_gaps" if !opt["header"].nil?
|
257
246
|
|
data/bin/RequestMarketData
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
#
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2009 Wes Devauld
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -18,11 +18,8 @@
|
|
18
18
|
# 02110-1301 USA
|
19
19
|
#
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
require 'ib'
|
24
|
-
require 'datatypes'
|
25
|
-
require 'symbols/forex'
|
21
|
+
require File.expand_path(
|
22
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'ib-ruby'))
|
26
23
|
|
27
24
|
#
|
28
25
|
# Definition of what we want market data for. We have to keep track
|
data/bin/SimpleTimeAndSales
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
#!/usr/bin/env ruby -w
|
2
2
|
#
|
3
|
-
# Copyright (C)
|
3
|
+
# Copyright (C) 2009 Wes Devauld
|
4
4
|
#
|
5
5
|
# This library is free software; you can redistribute it and/or modify
|
6
6
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -18,11 +18,8 @@
|
|
18
18
|
# 02110-1301 USA
|
19
19
|
#
|
20
20
|
|
21
|
-
|
22
|
-
|
23
|
-
require 'ib'
|
24
|
-
require 'datatypes'
|
25
|
-
require 'symbols/futures'
|
21
|
+
require File.expand_path(
|
22
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'ib-ruby'))
|
26
23
|
|
27
24
|
# First, connect to IB TWS.
|
28
25
|
ib = IB::IB.new
|
data/lib/ib-ruby.rb
CHANGED
data/lib/ib-ruby/datatypes.rb
CHANGED
@@ -21,12 +21,8 @@
|
|
21
21
|
# TODO: Implement equals() according to the criteria in IB's Java client.
|
22
22
|
#
|
23
23
|
|
24
|
-
require 'Logger'
|
25
|
-
|
26
24
|
module IB
|
27
25
|
|
28
|
-
logger = Logger.new(STDERR)
|
29
|
-
|
30
26
|
module Datatypes
|
31
27
|
attr_reader :created_at
|
32
28
|
|
@@ -200,9 +196,11 @@ module IB
|
|
200
196
|
end
|
201
197
|
|
202
198
|
def expiry=(x)
|
203
|
-
|
204
|
-
|
205
|
-
|
199
|
+
x = x.to_s
|
200
|
+
if x.nil? || ! (x =~ /\d{6,8}/) then
|
201
|
+
raise ArgumentError.new("Invalid expiry \"#{x}\" (must be in format YYYYMM or YYYYMMDD)")
|
202
|
+
end
|
203
|
+
@expiry = x
|
206
204
|
end
|
207
205
|
|
208
206
|
def sec_type=(x)
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (C)
|
2
|
+
# Copyright (C) 2009 Wes Devauld
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or modify
|
5
5
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -23,11 +23,6 @@
|
|
23
23
|
# you may find useful there.
|
24
24
|
#
|
25
25
|
|
26
|
-
$:.push(File.dirname(__FILE__) + "/../")
|
27
|
-
|
28
|
-
require 'ib'
|
29
|
-
require 'datatypes'
|
30
|
-
|
31
26
|
module IB
|
32
27
|
module Symbols
|
33
28
|
Forex =
|
@@ -1,5 +1,5 @@
|
|
1
1
|
#
|
2
|
-
# Copyright (C)
|
2
|
+
# Copyright (C) 2009 Wes Devauld
|
3
3
|
#
|
4
4
|
# This library is free software; you can redistribute it and/or modify
|
5
5
|
# it under the terms of the GNU Lesser General Public License as
|
@@ -29,11 +29,6 @@
|
|
29
29
|
# you may find useful there.
|
30
30
|
#
|
31
31
|
|
32
|
-
$:.push(File.dirname(__FILE__) + "/../")
|
33
|
-
|
34
|
-
require 'ib'
|
35
|
-
require 'datatypes'
|
36
|
-
|
37
32
|
module IB
|
38
33
|
module Symbols
|
39
34
|
|
data/test/test_ib-ruby.rb
CHANGED
@@ -18,11 +18,10 @@
|
|
18
18
|
# 02110-1301 USA
|
19
19
|
#
|
20
20
|
|
21
|
-
|
21
|
+
require File.expand_path(
|
22
|
+
File.join(File.dirname(__FILE__), '..', 'lib', 'ib-ruby'))
|
22
23
|
|
23
24
|
require 'test/unit'
|
24
|
-
require 'ib'
|
25
|
-
require 'datatypes'
|
26
25
|
|
27
26
|
class ContractTests < Test::Unit::TestCase
|
28
27
|
def test_plain_instantiation
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: wdevauld-ib-ruby
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: "0.
|
4
|
+
version: "0.3"
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Wes Devauld
|
@@ -9,7 +9,7 @@ autorequire:
|
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
|
12
|
-
date: 2009-06-
|
12
|
+
date: 2009-06-18 00:00:00 -07:00
|
13
13
|
default_executable:
|
14
14
|
dependencies:
|
15
15
|
- !ruby/object:Gem::Dependency
|