Skip to content

Commit

Permalink
Codestyling
Browse files Browse the repository at this point in the history
  • Loading branch information
arvicco committed Mar 12, 2012
1 parent 903b5fb commit 1861d43
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 28 deletions.
43 changes: 21 additions & 22 deletions lib/ib-ruby/models/execution.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,27 +5,26 @@ module Models
# This is IB Order execution report.
# Instantiate with a Hash of attributes, to be auto-set via initialize in Model.
class Execution < Model
attr_accessor :order_id, # int: order id. TWS orders have a fixed order id of 0.
:client_id, # int: id of the client that placed the order.
# TWS orders have a fixed client id of 0.
:exec_id, # String: Unique order execution id.
:time, # String: The order execution time.
:account_name, #String: The customer account number.
:exchange, # String: Exchange that executed the order.
:side, # String: Was the transaction a buy or a sale: BOT|SLD
:shares, # int: The number of shares filled.
:price, # double: The order execution price.
:perm_id, # int: TWS id used to identify orders, remains
attr_accessor :order_id, # int: order id. TWS orders have a fixed order id of 0.
:client_id, # int: id of the client that placed the order.
# TWS orders have a fixed client id of 0.
:perm_id, # int: TWS id used to identify orders, remains
:exec_id, # String: Unique order execution id.
# the same over TWS sessions.
:liquidation, # int: Identifies the position as one to be liquidated
# last should the need arise.
:time, # String: The order execution time.
:exchange, # String: Exchange that executed the order.
:side, # String: Was the transaction a buy or a sale: BOT|SLD
:account_name, # String: The customer account number.
:price, # double: The order execution price.
:average_price, # double: Average price. Used in regular trades, combo
# trades and legs of the combo.
:shares, # int: The number of shares filled.
:cumulative_quantity, # int: Cumulative quantity. Used in regular
# trades, combo trades and legs of the combo
:average_price # double: Average price. Used in regular trades, combo
# trades and legs of the combo.
# Legacy
alias account_number account_name
alias account_number= account_name=
# trades, combo trades and legs of the combo
:liquidation # int: This position is liquidated last should the need arise.

alias account_number account_name # Legacy
alias account_number= account_name= # Legacy

def side= value
@side = case value
Expand All @@ -50,9 +49,9 @@ def initialize opts = {}
end

def to_s
"<Execution #{@time}: #{@side} #{@shares} @ #{@price} on #{@exchange}, " +
"cumulative: #{@cumulative_quantity} @ #{@average_price}, " +
"ids: #{@order_id} order, #{@perm_id} perm, #{@exec_id} exec>"
"<Execution #{time}: #{side} #{shares} @ #{price} on #{exchange}, " +
"cumulative: #{cumulative_quantity} @ #{average_price}, " +
"ids: #{order_id} order, #{perm_id} perm, #{exec_id} exec>"
end
end # Execution
end # module Models
Expand Down
12 changes: 6 additions & 6 deletions spec/integration/market_data_spec.rb
Original file line number Diff line number Diff line change
Expand Up @@ -23,15 +23,15 @@

it_behaves_like 'Received Market Data'

it "logs no warning about unhandled :Alert message" do
it 'logs no warning about unhandled :Alert message' do
should_not_log /No subscribers for message .*:Alert/
end

it "logs no warning about unhandled :Tick... messages" do
it 'logs no warning about unhandled :Tick... messages' do
should_not_log /No subscribers for message .*:TickPrice/
end

it "logs no warning about unhandled :Tick... messages", :if => :forex_trading_hours do
it 'logs no warning about unhandled :Tick... messages', :if => :forex_trading_hours do
should_not_log /No subscribers for message .*:TickSize/
end

Expand All @@ -52,15 +52,15 @@
close_connection
end

it "logs warning about unhandled :Alert message" do
it 'logs warning about unhandled :Alert message' do
should_log /No subscribers for message .*:Alert/
end

it "logs warning about unhandled :Tick... messages" do
it 'logs warning about unhandled :Tick... messages' do
should_log /No subscribers for message .*:TickPrice/
end

it "logs warning about unhandled :Tick... messages", :if => :forex_trading_hours do
it 'logs warning about unhandled :Tick... messages', :if => :forex_trading_hours do
should_log /No subscribers for message .*:TickSize/
end

Expand Down

0 comments on commit 1861d43

Please sign in to comment.