ib-api 972.0 → 972.4
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.
- checksums.yaml +4 -4
- data/Gemfile.lock +36 -37
- data/README.md +48 -3
- data/VERSION +1 -1
- data/api.gemspec +1 -1
- data/bin/console +4 -8
- data/changelog.md +12 -0
- data/lib/ib/base_properties.rb +3 -4
- data/lib/ib/connection.rb +18 -16
- data/lib/ib/logger.rb +1 -1
- data/lib/ib/messages/incoming.rb +1 -1
- data/lib/ib/messages/incoming/abstract_message.rb +7 -7
- data/lib/ib/messages/incoming/account_value.rb +5 -1
- data/lib/ib/messages/incoming/contract_data.rb +0 -2
- data/lib/ib/messages/incoming/historical_data.rb +25 -5
- data/lib/ib/messages/incoming/ticks.rb +21 -60
- data/lib/ib/messages/outgoing.rb +4 -2
- data/lib/ib/messages/outgoing/abstract_message.rb +3 -3
- data/lib/ib/messages/outgoing/bar_requests.rb +4 -5
- data/lib/ib/messages/outgoing/request_marketdata.rb +10 -7
- data/lib/ib/models.rb +1 -1
- data/lib/ib/support.rb +32 -15
- data/lib/logging.rb +45 -0
- data/lib/models/ib/account.rb +0 -13
- data/lib/models/ib/bag.rb +7 -1
- data/lib/models/ib/bar.rb +1 -1
- data/lib/models/ib/combo_leg.rb +22 -0
- data/lib/models/ib/contract.rb +44 -32
- data/lib/models/ib/contract_detail.rb +13 -7
- data/lib/models/ib/index.rb +1 -1
- data/lib/models/ib/option.rb +8 -2
- data/lib/models/ib/option_detail.rb +19 -3
- data/lib/models/ib/order.rb +5 -0
- data/lib/models/ib/spread.rb +168 -0
- data/lib/models/ib/stock.rb +9 -3
- data/lib/models/ib/underlying.rb +4 -1
- data/lib/requires.rb +10 -3
- metadata +9 -20
- data/example/README.md +0 -76
- data/example/account_info +0 -54
- data/example/account_positions +0 -30
- data/example/account_summary +0 -88
- data/example/cancel_orders +0 -74
- data/example/fa_accounts +0 -25
- data/example/fundamental_data +0 -40
- data/example/historic_data_cli +0 -186
- data/example/list_orders +0 -45
- data/example/portfolio_csv +0 -81
- data/example/scanner_data +0 -62
- data/example/template +0 -19
- data/example/tick_data +0 -28
data/lib/models/ib/stock.rb
CHANGED
@@ -1,14 +1,20 @@
|
|
1
|
-
require_relative 'contract'
|
1
|
+
#require_relative 'contract'
|
2
2
|
module IB
|
3
3
|
class Stock < IB::Contract
|
4
4
|
validates_format_of :sec_type, :with => /\Astock\z/,
|
5
5
|
:message => "should be a Stock"
|
6
|
+
validates_format_of :symbol, with: /\A.*\z/,
|
7
|
+
message: 'should not be blank'
|
6
8
|
def default_attributes
|
7
9
|
super.merge :sec_type => :stock, currency:'USD', exchange:'SMART'
|
8
10
|
end
|
9
11
|
|
10
|
-
def to_human
|
11
|
-
att = [ symbol,
|
12
|
+
def to_human
|
13
|
+
att = [ symbol,
|
14
|
+
currency, ( exchange == 'SMART' ? nil: exchange ),
|
15
|
+
(primary_exchange.present? && !primary_exchange.empty? ? primary_exchange : nil),
|
16
|
+
@description.present? ? " (#{@description}) " : nil,
|
17
|
+
].compact
|
12
18
|
"<Stock: " + att.join(" ") + ">"
|
13
19
|
end
|
14
20
|
|
data/lib/models/ib/underlying.rb
CHANGED
@@ -1,4 +1,7 @@
|
|
1
1
|
module IB
|
2
|
+
if defined?(Underlying)
|
3
|
+
puts "Underlying already a #{defined?(Underlying)}"
|
4
|
+
else
|
2
5
|
|
3
6
|
# Calculated characteristics of underlying Contract (volatile)
|
4
7
|
class Underlying < IB::Model
|
@@ -30,5 +33,5 @@ module IB
|
|
30
33
|
|
31
34
|
end # class Underlying
|
32
35
|
UnderComp = Underlying
|
33
|
-
|
36
|
+
end
|
34
37
|
end # module IB
|
data/lib/requires.rb
CHANGED
@@ -7,6 +7,13 @@ require 'ib/errors'
|
|
7
7
|
require 'ib/constants'
|
8
8
|
require 'ib/connection'
|
9
9
|
|
10
|
-
|
11
|
-
|
12
|
-
|
10
|
+
# An external model- or database-driver provides the base class for models
|
11
|
+
# if the constant DB is defined
|
12
|
+
#
|
13
|
+
# basically IB::Model has to be assigned to the substitute base class
|
14
|
+
# the database-driver requires models and messages at the appropoate time
|
15
|
+
unless defined?(DB)
|
16
|
+
require 'ib/model'
|
17
|
+
require 'ib/models'
|
18
|
+
require 'ib/messages'
|
19
|
+
end
|
metadata
CHANGED
@@ -1,29 +1,29 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: ib-api
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: '972.
|
4
|
+
version: '972.4'
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Hartmut Bischoff
|
8
8
|
autorequire:
|
9
9
|
bindir: exe
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2021-05-13 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
15
15
|
requirement: !ruby/object:Gem::Requirement
|
16
16
|
requirements:
|
17
|
-
- - "
|
17
|
+
- - ">="
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '
|
19
|
+
version: '0'
|
20
20
|
type: :development
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
|
-
- - "
|
24
|
+
- - ">="
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '
|
26
|
+
version: '0'
|
27
27
|
- !ruby/object:Gem::Dependency
|
28
28
|
name: rake
|
29
29
|
requirement: !ruby/object:Gem::Requirement
|
@@ -103,19 +103,6 @@ files:
|
|
103
103
|
- bin/console.yml
|
104
104
|
- bin/setup
|
105
105
|
- changelog.md
|
106
|
-
- example/README.md
|
107
|
-
- example/account_info
|
108
|
-
- example/account_positions
|
109
|
-
- example/account_summary
|
110
|
-
- example/cancel_orders
|
111
|
-
- example/fa_accounts
|
112
|
-
- example/fundamental_data
|
113
|
-
- example/historic_data_cli
|
114
|
-
- example/list_orders
|
115
|
-
- example/portfolio_csv
|
116
|
-
- example/scanner_data
|
117
|
-
- example/template
|
118
|
-
- example/tick_data
|
119
106
|
- lib/extensions/class-extensions.rb
|
120
107
|
- lib/ib-api.rb
|
121
108
|
- lib/ib/base.rb
|
@@ -155,6 +142,7 @@ files:
|
|
155
142
|
- lib/ib/socket.rb
|
156
143
|
- lib/ib/support.rb
|
157
144
|
- lib/ib/version.rb
|
145
|
+
- lib/logging.rb
|
158
146
|
- lib/models/ib/account.rb
|
159
147
|
- lib/models/ib/account_value.rb
|
160
148
|
- lib/models/ib/bag.rb
|
@@ -172,6 +160,7 @@ files:
|
|
172
160
|
- lib/models/ib/order.rb
|
173
161
|
- lib/models/ib/order_state.rb
|
174
162
|
- lib/models/ib/portfolio_value.rb
|
163
|
+
- lib/models/ib/spread.rb
|
175
164
|
- lib/models/ib/stock.rb
|
176
165
|
- lib/models/ib/underlying.rb
|
177
166
|
- lib/models/ib/vertical.rb
|
@@ -196,7 +185,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
196
185
|
- !ruby/object:Gem::Version
|
197
186
|
version: '0'
|
198
187
|
requirements: []
|
199
|
-
rubygems_version: 3.
|
188
|
+
rubygems_version: 3.2.3
|
200
189
|
signing_key:
|
201
190
|
specification_version: 4
|
202
191
|
summary: Ruby Implementation of the Interactive Brokers TWS API
|
data/example/README.md
DELETED
@@ -1,76 +0,0 @@
|
|
1
|
-
## IB-RUBY EXAMPLES:
|
2
|
-
|
3
|
-
This folder contains sample scripts that demonstrate common ib-ruby use cases.
|
4
|
-
The scripts show you how to access account info, print real time quotes, retrieve
|
5
|
-
historic or fundamental data, request options calculations, place, list, and cancel orders.
|
6
|
-
You may also want to look into `spec/integration` directory for more scenarios,
|
7
|
-
use cases and examples of handling IB messages.
|
8
|
-
|
9
|
-
Normally you run these examples like this:
|
10
|
-
|
11
|
-
$ ruby example/list_orders
|
12
|
-
|
13
|
-
The examples are executable.
|
14
|
-
If you're on Unix-like platform, they can be called directly ( » ./{script} «)
|
15
|
-
|
16
|
-
The Examples assume a running Gateway-Application on Localhost. Please use a Demo-Account or run
|
17
|
-
the API in »read-only-mode«
|
18
|
-
|
19
|
-
## EXAMPLE DESCRIPTION:
|
20
|
-
|
21
|
-
*account_info* - Request your account info, current positions, portfolio values and so on
|
22
|
-
|
23
|
-
$ ruby example/account_info # or cd example; ./account_info
|
24
|
-
|
25
|
-
For Financial Advisors, you need to add the managed account you want info for:
|
26
|
-
|
27
|
-
$ ruby example/account_info U123456
|
28
|
-
|
29
|
-
*cancel_orders* - Cancel either all open orders, or specific order(s), by their (local) ids. Examples:
|
30
|
-
|
31
|
-
$ ruby example/cancel_orders
|
32
|
-
$ ruby example/cancel_orders 492 495
|
33
|
-
|
34
|
-
*contract_details* - Obtain detailed descriptions for specific Stock, Option, Forex, Futures and Bond contracts.
|
35
|
-
|
36
|
-
*contract_sample details* - Define Contract samples provided by java and python API-implementations
|
37
|
-
|
38
|
-
*depth_of_market* - Receive a stream of MarketDepth change events for Stock, Forex and Future symbols.
|
39
|
-
|
40
|
-
*fa_accounts* - Get info about accounts under management (for Financial Advisors).
|
41
|
-
|
42
|
-
*flex_query* - Run a pre-defined Flex query, receive and print Flex report. Example:
|
43
|
-
|
44
|
-
$ ruby example/flex_query 12345 # Flex query id pre-defined in Account Management
|
45
|
-
|
46
|
-
*fundamental_data* - Request and print fundamental data report for a specific stock.
|
47
|
-
|
48
|
-
*historic_data* - Receive 5 days of 1-hour trade data for Stock, Forex and Future symbols.
|
49
|
-
|
50
|
-
*historic_data_cli* - CLI script for historic data downloading. It has many options, for detailed help run:
|
51
|
-
|
52
|
-
$ ruby example/historic_data_cli
|
53
|
-
|
54
|
-
*list_orders* - List all open API orders.
|
55
|
-
|
56
|
-
*market_data* - Receive a stream of trade events for multiple Forex symbols.
|
57
|
-
|
58
|
-
*option_data* - Receive a stream of underlying, price and greeks calculations for multiple Option symbols.
|
59
|
-
|
60
|
-
*place_braket_order* - Place a braket order for Stock.
|
61
|
-
|
62
|
-
*place_combo_order* - Place an Option combo order (Google butterfly).
|
63
|
-
|
64
|
-
*place_order* - Place a simple limit order to buy Stock.
|
65
|
-
|
66
|
-
*portfolio_csv* - Exports your IB portfolio in a CSV format. Usage:
|
67
|
-
|
68
|
-
$ ruby example/portfolio_csv [account] > my_portfolio.csv
|
69
|
-
|
70
|
-
*real_time_data* - Subscribe to real time data for specific symbol.
|
71
|
-
|
72
|
-
*template* - A blank example to start a new script (setting up all the dependencies).
|
73
|
-
|
74
|
-
*tick_data* - Subscribe to extended tick types for a single stock symbol.
|
75
|
-
|
76
|
-
*time_and_sales* - Print out Time&Sales format for Futures symbols.
|
data/example/account_info
DELETED
@@ -1,54 +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 'bundler/setup'
|
7
|
-
require 'ib-api'
|
8
|
-
|
9
|
-
# Only for Advisor accounts: you can provide account_code such as U666777 (otherwise the last account is used)
|
10
|
-
account_code = ARGV[0] || ''
|
11
|
-
|
12
|
-
include IB
|
13
|
-
# Connect to IB TWS
|
14
|
-
accounts = []
|
15
|
-
ib = Connection.new client_id: 1113, port: 4002 do | gw | # :port => 7497 # TWS
|
16
|
-
|
17
|
-
# Subscribe to TWS alerts/errors and account-related messages
|
18
|
-
# that TWS sends in response to account data request
|
19
|
-
gw.subscribe(:Alert) do |msg|
|
20
|
-
## if an account is not given. but required, (Error 321 indicates this)
|
21
|
-
## fetch data from the last account detected. (The first is most probably the Advisor-Account)
|
22
|
-
if msg.code == 321
|
23
|
-
gw.send_message :RequestAccountData, :subscribe => true, :account_code => accounts.last
|
24
|
-
else
|
25
|
-
puts msg.to_human
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
## Print Account+Portfolio-Values
|
30
|
-
gw.subscribe(:AccountValue,
|
31
|
-
:PortfolioValue, :AccountUpdateTime) { |msg| puts msg.to_human }
|
32
|
-
|
33
|
-
## Just in case: put account-names into accounts-array
|
34
|
-
gw.subscribe(:ManagedAccounts){ |msg| accounts = msg.accounts_list.split ',' }
|
35
|
-
|
36
|
-
# Set log level
|
37
|
-
gw.logger.level = Logger::FATAL # DEBUG #FATAL
|
38
|
-
end
|
39
|
-
|
40
|
-
ib.send_message :RequestAccountData, :subscribe => true, :account_code => account_code
|
41
|
-
|
42
|
-
puts "\nSubscribing to IB account data"
|
43
|
-
|
44
|
-
## print message after recieving account-data
|
45
|
-
Thread.new do
|
46
|
-
sleep 3
|
47
|
-
puts "\n******** Press <Enter> to quit *********\n\n"
|
48
|
-
end
|
49
|
-
|
50
|
-
STDIN.gets
|
51
|
-
puts "Cancelling account data subscription.."
|
52
|
-
|
53
|
-
ib.send_message :RequestAccountData, :subscribe => false
|
54
|
-
sleep 2
|
data/example/account_positions
DELETED
@@ -1,30 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This script connects to IB API and subscribes to Position Values which are updated regulary
|
4
|
-
|
5
|
-
require 'bundler/setup'
|
6
|
-
require 'ib-api'
|
7
|
-
|
8
|
-
|
9
|
-
# connect to IB TWS.
|
10
|
-
|
11
|
-
|
12
|
-
ib = IB::Connection.new( :client_id => 1110) do | gw | #, :port => 7496 # TWS)
|
13
|
-
## Subcribe to forseable events before the connection is completed
|
14
|
-
## Subscribe to TWS alerts/errors
|
15
|
-
gw.subscribe(:Alert, :PositionData){ |msg| puts msg.to_human }
|
16
|
-
gw.logger.level = Logger::FATAL # DEBUG -- INFO -- WARN -- ERROR -- FATAL
|
17
|
-
end
|
18
|
-
|
19
|
-
Thread.new do
|
20
|
-
sleep 1
|
21
|
-
puts "\n******** Press <Enter> to quit *********\n\n"
|
22
|
-
end
|
23
|
-
# request the AccountSummary
|
24
|
-
ib.send_message :RequestPositions
|
25
|
-
|
26
|
-
STDIN.gets
|
27
|
-
puts "\n *** canceling Reqest ..."
|
28
|
-
ib.send_message :CancelPositions
|
29
|
-
sleep 1
|
30
|
-
puts "done."
|
data/example/account_summary
DELETED
@@ -1,88 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This script connects to IB API and subscribes to Account Summary Updates for certain tags
|
4
|
-
|
5
|
-
require 'bundler/setup'
|
6
|
-
require 'ib-api'
|
7
|
-
|
8
|
-
# Definition of what we want listed
|
9
|
-
# possible tags
|
10
|
-
# NetLiquidation,
|
11
|
-
# TotalCashValue - Total cash including futures pnl
|
12
|
-
# SettledCash - For cash accounts, this is the same as
|
13
|
-
# TotalCashValue
|
14
|
-
# AccruedCash - Net accrued interest
|
15
|
-
# BuyingPower - The maximum amount of marginable US stocks the
|
16
|
-
# account can buy
|
17
|
-
# EquityWithLoanValue - Cash + stocks + bonds + mutual funds
|
18
|
-
# PreviousDayEquityWithLoanValue,
|
19
|
-
# GrossPositionValue - The sum of the absolute value of all stock
|
20
|
-
# and equity option positions
|
21
|
-
# RegTEquity,
|
22
|
-
# RegTMargin,
|
23
|
-
# SMA - Special Memorandum Account
|
24
|
-
# InitMarginReq,
|
25
|
-
# MaintMarginReq,
|
26
|
-
# AvailableFunds,
|
27
|
-
# ExcessLiquidity,
|
28
|
-
# Cushion - Excess liquidity as a percentage of net liquidation value
|
29
|
-
# FullInitMarginReq,
|
30
|
-
# FullMaintMarginReq,
|
31
|
-
# FullAvailableFunds,
|
32
|
-
# FullExcessLiquidity,
|
33
|
-
# LookAheadNextChange - Time when look-ahead values take effect
|
34
|
-
# LookAheadInitMarginReq,
|
35
|
-
# LookAheadMaintMarginReq,
|
36
|
-
# LookAheadAvailableFunds,
|
37
|
-
# LookAheadExcessLiquidity,
|
38
|
-
# HighestSeverity - A measure of how close the account is to liquidation
|
39
|
-
# DayTradesRemaining - The Number of Open/Close trades a user
|
40
|
-
# could put on before Pattern Day Trading is detected. A value of "-1"
|
41
|
-
# means that the user can put on unlimited day trades.
|
42
|
-
# Leverage - GrossPositionValue / NetLiquidation
|
43
|
-
# $LEDGER - Single flag to relay all cash balance tags*, only in base
|
44
|
-
# currency.
|
45
|
-
# $LEDGER:CURRENCY - Single flag to relay all cash balance tags*, only in
|
46
|
-
# the specified currency.
|
47
|
-
# $LEDGER:ALL - Single flag to relay all cash balance tags* in all
|
48
|
-
#
|
49
|
-
tags = %w( NetLiquidation InitMarginReq DayTradesRemaining )
|
50
|
-
# connect to IB TWS.
|
51
|
-
|
52
|
-
|
53
|
-
ib = IB::Connection.new( :client_id => 1112) do | gw | #, :port => 7496 # TWS)
|
54
|
-
## Subcribe to forseable events before the connection is completed
|
55
|
-
## Subscribe to TWS alerts/errors
|
56
|
-
gw.subscribe(:Alert, :AccountSummary){ |msg| puts msg.to_human }
|
57
|
-
gw.logger.level = Logger::FATAL # DEBUG -- INFO -- WARN -- ERROR -- FATAL
|
58
|
-
end
|
59
|
-
|
60
|
-
Thread.new do
|
61
|
-
sleep 1
|
62
|
-
puts "\n******** Press <Enter> to quit *********\n\n"
|
63
|
-
end
|
64
|
-
# request the AccountSummary
|
65
|
-
request_id = ib.send_message :RequestAccountSummary, tags: tags.join(',')
|
66
|
-
|
67
|
-
STDIN.gets
|
68
|
-
puts "\n *** canceling Request ..."
|
69
|
-
ib.send_message :CancelAccountSummary, id: request_id
|
70
|
-
sleep 1
|
71
|
-
puts "done."
|
72
|
-
|
73
|
-
|
74
|
-
=begin
|
75
|
-
Expected Output
|
76
|
-
|
77
|
-
delta:~/workspace/ib-ruby/example$ ./account_summary
|
78
|
-
<AccountSummary: request_id 8111, account DU167349, tag DayTradesRemaining, value -1.0, currency >
|
79
|
-
<AccountSummary: request_id 8111, account DU167349, tag InitMarginReq, value 93402.16, currency EUR >
|
80
|
-
<AccountSummary: request_id 8111, account DU167349, tag NetLiquidation, value 990842.34, currency EUR >
|
81
|
-
<AccountSummary: request_id 8111, account DF167347, tag InitMarginReq, value 0.0, currency EUR >
|
82
|
-
<AccountSummary: request_id 8111, account DF167347, tag NetLiquidation, value 0.0, currency EUR >
|
83
|
-
<AccountSummary: request_id 8111, account DU167348, tag DayTradesRemaining, value -1.0, currency >
|
84
|
-
<AccountSummary: request_id 8111, account DU167348, tag InitMarginReq, value 135317.73, currency EUR >
|
85
|
-
<AccountSummary: request_id 8111, account DU167348, tag NetLiquidation, value 949599.26, currency EUR >
|
86
|
-
|
87
|
-
******** Press <Enter> to quit *********
|
88
|
-
=end
|
data/example/cancel_orders
DELETED
@@ -1,74 +0,0 @@
|
|
1
|
-
#!/usr/bin/env ruby
|
2
|
-
#
|
3
|
-
# This script allows you to cancel either a set of open Orders by their ids,
|
4
|
-
# or ALL Orders opened via IB API at once. The latter is useful when your
|
5
|
-
# robot goes crazy and opens gazillions of wrong limit orders.
|
6
|
-
#
|
7
|
-
# Accepts the port to connect to as first command-parameter, T)ws or G)ateway, which is the default
|
8
|
-
#
|
9
|
-
# Numeric Parameter are interpreted as keys for specific orders to kill
|
10
|
-
|
11
|
-
require 'bundler/setup'
|
12
|
-
require 'ib-api'
|
13
|
-
specified_port = ARGV[0] || 'Gateway'
|
14
|
-
port = case specified_port
|
15
|
-
when /^[gG]/
|
16
|
-
ARGV.shift # consume the first argument
|
17
|
-
4002
|
18
|
-
when /^[Tt]/
|
19
|
-
ARGV.shift # consume the first argument
|
20
|
-
7497
|
21
|
-
end
|
22
|
-
|
23
|
-
# First, connect to IB TWS.
|
24
|
-
ib = IB::Connection.new client_id: 1111, port: port do | gw |
|
25
|
-
|
26
|
-
# Subscribe to TWS alerts/errors and order-related messages
|
27
|
-
gw.subscribe(:Alert, :ManagedAccounts, :OpenOrder, :OrderStatus, :OpenOrderEnd) { |msg| puts msg.to_human }
|
28
|
-
# Set log level
|
29
|
-
gw.logger.level = Logger::FATAL # DEBUG -- INFO -- WARN -- ERROR -- FATAL
|
30
|
-
end
|
31
|
-
|
32
|
-
if ARGV.empty?
|
33
|
-
ib.send_message :RequestGlobalCancel
|
34
|
-
else
|
35
|
-
puts "ARGV: #{ARGV}"
|
36
|
-
# Will only work for Orders placed under the same :client_id
|
37
|
-
ib.cancel_order *ARGV
|
38
|
-
puts '-'*55
|
39
|
-
puts "Remaining Orders"
|
40
|
-
puts '-'*55
|
41
|
-
end
|
42
|
-
|
43
|
-
puts '-'*55
|
44
|
-
puts "Remaining Orders"
|
45
|
-
ib.send_message :RequestAllOpenOrders
|
46
|
-
puts '-'*55
|
47
|
-
|
48
|
-
sleep 3
|
49
|
-
|
50
|
-
|
51
|
-
## Expected output
|
52
|
-
#12:20:25.154 Connected to server, version: 137,
|
53
|
-
# connection time: 2018-02-27 12:20:25 +0000 local, 2018-02-27T12:20:25+00:00 remote.
|
54
|
-
#12:20:25.156 Got message 5 (IB::Messages::Incoming::OpenOrder)
|
55
|
-
#<OpenOrder: <Stock: WFC USD> <Order: LMT GTC buy 100.0 1.13 Submitted #1/1562725191 from 1112/DU167348 fee 0.0>>
|
56
|
-
#12:20:25.158 Got message 3 (IB::Messages::Incoming::OrderStatus)
|
57
|
-
#<OrderStatus: <OrderState: Submitted #1/1562725191 from 1112 filled 0.0/100.0 at 0.0/0.0 why_held >>
|
58
|
-
#12:20:25.197 Got message 53 (IB::Messages::Incoming::OpenOrderEnd)
|
59
|
-
#<OpenOrderEnd: >
|
60
|
-
#12:20:25.197 Got message 15 (IB::Messages::Incoming::ManagedAccounts)
|
61
|
-
#12:20:25.197 No subscribers for message IB::Messages::Incoming::ManagedAccounts!
|
62
|
-
#12:20:25.197 Got message 9 (IB::Messages::Incoming::NextValidId)
|
63
|
-
#12:20:25.197 Got next valid order id: 2.
|
64
|
-
#12:20:25.254 Got message 5 (IB::Messages::Incoming::OpenOrder)
|
65
|
-
#<OpenOrder: <Stock: WFC USD> <Order: LMT GTC buy 100.0 1.13 PendingCancel #1/1562725191 from 1112/DU167348 fee 0.0>>
|
66
|
-
#12:20:25.256 Got message 3 (IB::Messages::Incoming::OrderStatus)
|
67
|
-
#<OrderStatus: <OrderState: PendingCancel #1/1562725191 from 1112 filled 0.0/100.0 at 0.0/0.0 why_held >>
|
68
|
-
#12:20:25.297 Got message 53 (IB::Messages::Incoming::OpenOrderEnd)
|
69
|
-
#<OpenOrderEnd: >
|
70
|
-
#12:20:25.342 Got message 3 (IB::Messages::Incoming::OrderStatus)
|
71
|
-
#<OrderStatus: <OrderState: Cancelled #1/1562725191 from 1112 filled 0.0/100.0 at 0.0/0.0 why_held >>
|
72
|
-
#12:20:25.343 Got message 4 (IB::Messages::Incoming::Alert)
|
73
|
-
#TWS Error 202: Order Canceled - reason:
|
74
|
-
##
|