Sha256: dba451bbc7ee55ba4741c35f8fa4b8e18617451c845e4cce2a039d381a0367a2

Contents?: true

Size: 890 Bytes

Versions: 10

Compression:

Stored size: 890 Bytes

Contents

#!/usr/bin/env ruby
#
# This script places WFC buy order for 100 lots

require 'rubygems'
require 'bundler/setup'
$LOAD_PATH.unshift File.expand_path(File.dirname(__FILE__) + '/../lib')
require 'ib-ruby'

# First, connect to IB TWS. Arbitrary :client_id is used to identify your script
ib = IB::Connection.new :client_id => 1112 #, :port => 7496 # TWS

# Subscribe to TWS alerts/errors and order-related messages
ib.subscribe(:Alert, :OpenOrder, :OrderStatus) { |msg| puts msg.to_human }

wfc = IB::Symbols::Stocks[:wfc]
buy_order = IB::Order.new :total_quantity => 100,
                          :limit_price => 1 + rand().round(2),
                          :action => 'BUY',
                          :order_type => 'LMT'
ib.wait_for :NextValidId
ib.place_order buy_order, wfc

ib.send_message :RequestAllOpenOrders

puts "\n******** Press <Enter> to cancel... *********\n\n"
STDIN.gets

Version data entries

10 entries across 10 versions & 1 rubygems

Version Path
ib-ruby-0.8.4 bin/place_order
ib-ruby-0.8.3 bin/place_order
ib-ruby-0.8.1 bin/place_order
ib-ruby-0.8.0 bin/place_order
ib-ruby-0.7.12 bin/place_order
ib-ruby-0.7.11 bin/place_order
ib-ruby-0.7.10 bin/place_order
ib-ruby-0.7.9 bin/place_order
ib-ruby-0.7.8 bin/place_order
ib-ruby-0.7.6 bin/place_order