Sha256: d80d92435d233eda02f9f59df2cc6555167e77b3c6563d2f79438334c5c3637e
Contents?: true
Size: 895 Bytes
Versions: 2
Compression:
Stored size: 895 Bytes
Contents
#!/usr/bin/env ruby # # This script allows you to cancel either a set of open Orders by their ids, # or ALL Orders opened via IB API at once. The latter is useful when your # robot goes crazy and opens gazillions of wrong limit orders. require 'rubygems' require 'pathname' LIB_DIR = (Pathname.new(__FILE__).dirname + '../lib/').realpath.to_s $LOAD_PATH.unshift LIB_DIR unless $LOAD_PATH.include?(LIB_DIR) require 'bundler/setup' require 'ib-ruby' # First, connect to IB TWS. ib = IB::Connection.new :client_id => 1112 #, :port => 7496 # TWS # Subscribe to TWS alerts/errors and order-related messages ib.subscribe(:Alert, :OpenOrder, :OrderStatus, :OpenOrderEnd) { |msg| puts msg.to_human } if ARGV.empty? ib.send_message :RequestGlobalCancel else # Will only work for Orders placed under the same :client_id ib.cancel_order *ARGV end ib.send_message :RequestAllOpenOrders sleep 3
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
ib-ruby-0.7.3 | bin/cancel_orders |
ib-ruby-0.7.2 | bin/cancel_orders |