Class: Tastytrade::Models::LiveOrder
- Defined in:
- lib/tastytrade/models/live_order.rb
Overview
Represents a live order (open or recently closed) from the API
Instance Attribute Summary collapse
-
#account_number ⇒ Object
readonly
Returns the value of attribute account_number.
-
#cancellable ⇒ Object
readonly
Returns the value of attribute cancellable.
-
#cancelled_at ⇒ Object
readonly
Returns the value of attribute cancelled_at.
-
#confirmation_status ⇒ Object
readonly
Returns the value of attribute confirmation_status.
-
#contingent_status ⇒ Object
readonly
Returns the value of attribute contingent_status.
-
#created_at ⇒ Object
readonly
Returns the value of attribute created_at.
-
#editable ⇒ Object
readonly
Returns the value of attribute editable.
-
#edited ⇒ Object
readonly
Returns the value of attribute edited.
-
#expired_at ⇒ Object
readonly
Returns the value of attribute expired_at.
-
#filled_at ⇒ Object
readonly
Returns the value of attribute filled_at.
-
#gtc_date ⇒ Object
readonly
Returns the value of attribute gtc_date.
-
#id ⇒ Object
readonly
Returns the value of attribute id.
-
#legs ⇒ Object
readonly
Returns the value of attribute legs.
-
#live_at ⇒ Object
readonly
Returns the value of attribute live_at.
-
#order_rule ⇒ Object
readonly
Returns the value of attribute order_rule.
-
#order_type ⇒ Object
readonly
Returns the value of attribute order_type.
-
#preflight_check_result ⇒ Object
readonly
Returns the value of attribute preflight_check_result.
-
#price ⇒ Object
readonly
Returns the value of attribute price.
-
#price_effect ⇒ Object
readonly
Returns the value of attribute price_effect.
-
#received_at ⇒ Object
readonly
Returns the value of attribute received_at.
-
#reject_reason ⇒ Object
readonly
Returns the value of attribute reject_reason.
-
#rejected_at ⇒ Object
readonly
Returns the value of attribute rejected_at.
-
#routed_at ⇒ Object
readonly
Returns the value of attribute routed_at.
-
#size ⇒ Object
readonly
Returns the value of attribute size.
-
#status ⇒ Object
readonly
Returns the value of attribute status.
-
#stop_trigger ⇒ Object
readonly
Returns the value of attribute stop_trigger.
-
#terminal_at ⇒ Object
readonly
Returns the value of attribute terminal_at.
-
#time_in_force ⇒ Object
readonly
Returns the value of attribute time_in_force.
-
#underlying_instrument_type ⇒ Object
readonly
Returns the value of attribute underlying_instrument_type.
-
#underlying_symbol ⇒ Object
readonly
Returns the value of attribute underlying_symbol.
-
#updated_at ⇒ Object
readonly
Returns the value of attribute updated_at.
-
#user_tag ⇒ Object
readonly
Returns the value of attribute user_tag.
Attributes inherited from Base
Instance Method Summary collapse
-
#cancellable? ⇒ Boolean
Check if order can be cancelled.
-
#cancelled? ⇒ Boolean
Check if order has been cancelled.
-
#editable? ⇒ Boolean
Check if order can be replaced/edited.
-
#filled? ⇒ Boolean
Check if order has been filled.
-
#filled_quantity ⇒ Object
Get filled quantity across all legs.
-
#remaining_quantity ⇒ Object
Get remaining quantity across all legs.
-
#terminal? ⇒ Boolean
Check if order is in a terminal state.
-
#to_h ⇒ Object
Convert to hash for JSON serialization.
-
#working? ⇒ Boolean
Check if order is working (live in market).
Methods inherited from Base
Constructor Details
This class inherits a constructor from Tastytrade::Models::Base
Instance Attribute Details
#account_number ⇒ Object (readonly)
Returns the value of attribute account_number.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def account_number @account_number end |
#cancellable ⇒ Object (readonly)
Returns the value of attribute cancellable.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def cancellable @cancellable end |
#cancelled_at ⇒ Object (readonly)
Returns the value of attribute cancelled_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def cancelled_at @cancelled_at end |
#confirmation_status ⇒ Object (readonly)
Returns the value of attribute confirmation_status.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def confirmation_status @confirmation_status end |
#contingent_status ⇒ Object (readonly)
Returns the value of attribute contingent_status.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def contingent_status @contingent_status end |
#created_at ⇒ Object (readonly)
Returns the value of attribute created_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def created_at @created_at end |
#editable ⇒ Object (readonly)
Returns the value of attribute editable.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def editable @editable end |
#edited ⇒ Object (readonly)
Returns the value of attribute edited.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def edited @edited end |
#expired_at ⇒ Object (readonly)
Returns the value of attribute expired_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def expired_at @expired_at end |
#filled_at ⇒ Object (readonly)
Returns the value of attribute filled_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def filled_at @filled_at end |
#gtc_date ⇒ Object (readonly)
Returns the value of attribute gtc_date.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def gtc_date @gtc_date end |
#id ⇒ Object (readonly)
Returns the value of attribute id.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def id @id end |
#legs ⇒ Object (readonly)
Returns the value of attribute legs.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def legs @legs end |
#live_at ⇒ Object (readonly)
Returns the value of attribute live_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def live_at @live_at end |
#order_rule ⇒ Object (readonly)
Returns the value of attribute order_rule.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def order_rule @order_rule end |
#order_type ⇒ Object (readonly)
Returns the value of attribute order_type.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def order_type @order_type end |
#preflight_check_result ⇒ Object (readonly)
Returns the value of attribute preflight_check_result.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def preflight_check_result @preflight_check_result end |
#price ⇒ Object (readonly)
Returns the value of attribute price.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def price @price end |
#price_effect ⇒ Object (readonly)
Returns the value of attribute price_effect.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def price_effect @price_effect end |
#received_at ⇒ Object (readonly)
Returns the value of attribute received_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def received_at @received_at end |
#reject_reason ⇒ Object (readonly)
Returns the value of attribute reject_reason.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def reject_reason @reject_reason end |
#rejected_at ⇒ Object (readonly)
Returns the value of attribute rejected_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def rejected_at @rejected_at end |
#routed_at ⇒ Object (readonly)
Returns the value of attribute routed_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def routed_at @routed_at end |
#size ⇒ Object (readonly)
Returns the value of attribute size.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def size @size end |
#status ⇒ Object (readonly)
Returns the value of attribute status.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def status @status end |
#stop_trigger ⇒ Object (readonly)
Returns the value of attribute stop_trigger.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def stop_trigger @stop_trigger end |
#terminal_at ⇒ Object (readonly)
Returns the value of attribute terminal_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def terminal_at @terminal_at end |
#time_in_force ⇒ Object (readonly)
Returns the value of attribute time_in_force.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def time_in_force @time_in_force end |
#underlying_instrument_type ⇒ Object (readonly)
Returns the value of attribute underlying_instrument_type.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def @underlying_instrument_type end |
#underlying_symbol ⇒ Object (readonly)
Returns the value of attribute underlying_symbol.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def @underlying_symbol end |
#updated_at ⇒ Object (readonly)
Returns the value of attribute updated_at.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def updated_at @updated_at end |
#user_tag ⇒ Object (readonly)
Returns the value of attribute user_tag.
10 11 12 |
# File 'lib/tastytrade/models/live_order.rb', line 10 def user_tag @user_tag end |
Instance Method Details
#cancellable? ⇒ Boolean
Check if order can be cancelled
20 21 22 |
# File 'lib/tastytrade/models/live_order.rb', line 20 def cancellable? @cancellable && status == "Live" end |
#cancelled? ⇒ Boolean
Check if order has been cancelled
45 46 47 |
# File 'lib/tastytrade/models/live_order.rb', line 45 def cancelled? status == "Cancelled" end |
#editable? ⇒ Boolean
Check if order can be replaced/edited
25 26 27 |
# File 'lib/tastytrade/models/live_order.rb', line 25 def editable? @editable && status == "Live" end |
#filled? ⇒ Boolean
Check if order has been filled
40 41 42 |
# File 'lib/tastytrade/models/live_order.rb', line 40 def filled? status == "Filled" end |
#filled_quantity ⇒ Object
Get filled quantity across all legs
56 57 58 59 |
# File 'lib/tastytrade/models/live_order.rb', line 56 def filled_quantity return 0 unless @legs @legs.sum { |leg| leg.filled_quantity || 0 } end |
#remaining_quantity ⇒ Object
Get remaining quantity across all legs
50 51 52 53 |
# File 'lib/tastytrade/models/live_order.rb', line 50 def remaining_quantity return 0 unless @legs @legs.sum { |leg| leg.remaining_quantity || 0 } end |
#terminal? ⇒ Boolean
Check if order is in a terminal state
30 31 32 |
# File 'lib/tastytrade/models/live_order.rb', line 30 def terminal? %w[Filled Cancelled Rejected Expired].include?(status) end |
#to_h ⇒ Object
Convert to hash for JSON serialization
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 |
# File 'lib/tastytrade/models/live_order.rb', line 62 def to_h { id: @id, account_number: @account_number, status: @status, cancellable: @cancellable, editable: @editable, edited: @edited, time_in_force: @time_in_force, order_type: @order_type, size: @size, price: @price&.to_s("F"), price_effect: @price_effect, underlying_symbol: @underlying_symbol, underlying_instrument_type: @underlying_instrument_type, stop_trigger: @stop_trigger&.to_s("F"), gtc_date: @gtc_date&.to_s, created_at: @created_at&.iso8601, updated_at: @updated_at&.iso8601, received_at: @received_at&.iso8601, routed_at: @routed_at&.iso8601, filled_at: @filled_at&.iso8601, cancelled_at: @cancelled_at&.iso8601, expired_at: @expired_at&.iso8601, rejected_at: @rejected_at&.iso8601, live_at: @live_at&.iso8601, terminal_at: @terminal_at&.iso8601, contingent_status: @contingent_status, confirmation_status: @confirmation_status, reject_reason: @reject_reason, user_tag: @user_tag, preflight_check_result: @preflight_check_result, order_rule: @order_rule, legs: @legs&.map(&:to_h), remaining_quantity: remaining_quantity, filled_quantity: filled_quantity }.compact end |
#working? ⇒ Boolean
Check if order is working (live in market)
35 36 37 |
# File 'lib/tastytrade/models/live_order.rb', line 35 def working? status == "Live" end |