class IB::OrderState
OrderState
represents dynamic (changeable) info about a single Order
, isolating these changes and making Order
essentially immutable
Public Instance Methods
==(other)
click to toggle source
Comparison
Calls superclass method
IB::BaseProperties#==
# File lib/models/ib/order_state.rb, line 96 def == other super(other) || other.is_a?(self.class) && status == other.status && local_id == other.local_id && perm_id == other.perm_id && client_id == other.client_id && filled == other.filled && remaining == other.remaining && last_fill_price == other.last_fill_price && init_margin == other.init_margin && maint_margin == other.maint_margin && equity_with_loan == other.equity_with_loan && why_held == other.why_held && warning_text == other.warning_text && commission == other.commission end
active?()
click to toggle source
Order
is in invalid state
# File lib/models/ib/order_state.rb, line 82 def active? new? || pending? end
complete_fill?()
click to toggle source
# File lib/models/ib/order_state.rb, line 91 def complete_fill? status == 'Filled' && remaining == 0 # filled >= total_quantity # Manually corrected end
inactive?()
click to toggle source
Order
is in invalid state
# File lib/models/ib/order_state.rb, line 87 def inactive? !active? # status == 'Inactive' end
new?()
click to toggle source
Testing Order
state:
# File lib/models/ib/order_state.rb, line 67 def new? status.empty? || status == 'New' end
pending?()
click to toggle source
Order
is in a valid, working state on TWS side
# File lib/models/ib/order_state.rb, line 77 def pending? submitted? || status == 'PendingSubmit' end
submitted?()
click to toggle source
Order
is in a valid, working state on TWS side
# File lib/models/ib/order_state.rb, line 72 def submitted? status == 'PreSubmitted' || status == 'Submitted' end
to_human()
click to toggle source
# File lib/models/ib/order_state.rb, line 115 def to_human "<OrderState: #{status} ##{local_id}/#{perm_id} from #{client_id}" + (filled ? " filled #{filled}/#{remaining}" : '') + (last_fill_price ? " at #{last_fill_price}/#{average_fill_price}" : '') + (init_margin ? " margin #{init_margin}/#{maint_margin}" : '') + (equity_with_loan ? " equity #{equity_with_loan}" : '') + (commission && commission > 0 ? " fee #{commission}" : "") + (why_held ? " why_held #{why_held}" : '') + ((warning_text && warning_text != '') ? " warning #{warning_text}" : '') + ">" end
Also aliased as: to_s