Module: Tastytrade::Models::OrderStatus

Defined in:
lib/tastytrade/models/order_status.rb

Overview

Order status constants and helpers

Constant Summary collapse

RECEIVED =

Submission phase statuses

"Received"
ROUTED =
"Routed"
IN_FLIGHT =
"In Flight"
CONTINGENT =
"Contingent"
LIVE =

Working phase statuses

"Live"
CANCEL_REQUESTED =
"Cancel Requested"
REPLACE_REQUESTED =
"Replace Requested"
FILLED =

Terminal phase statuses

"Filled"
CANCELLED =
"Cancelled"
REJECTED =
"Rejected"
EXPIRED =
"Expired"
REMOVED =
"Removed"
SUBMISSION_STATUSES =

Status groupings

[
  RECEIVED,
  ROUTED,
  IN_FLIGHT,
  CONTINGENT
].freeze
WORKING_STATUSES =
[
  LIVE,
  CANCEL_REQUESTED,
  REPLACE_REQUESTED
].freeze
TERMINAL_STATUSES =
[
  FILLED,
  CANCELLED,
  REJECTED,
  EXPIRED,
  REMOVED
].freeze
ALL_STATUSES =
(
  SUBMISSION_STATUSES +
  WORKING_STATUSES +
  TERMINAL_STATUSES
).freeze

Class Method Summary collapse

Class Method Details

.cancellable?(status) ⇒ Boolean

Check if status allows cancellation



69
70
71
# File 'lib/tastytrade/models/order_status.rb', line 69

def self.cancellable?(status)
  status == LIVE
end

.editable?(status) ⇒ Boolean

Check if status allows replacement



74
75
76
# File 'lib/tastytrade/models/order_status.rb', line 74

def self.editable?(status)
  status == LIVE
end

.submission?(status) ⇒ Boolean

Check if status is in submission phase



54
55
56
# File 'lib/tastytrade/models/order_status.rb', line 54

def self.submission?(status)
  SUBMISSION_STATUSES.include?(status)
end

.terminal?(status) ⇒ Boolean

Check if status is terminal



64
65
66
# File 'lib/tastytrade/models/order_status.rb', line 64

def self.terminal?(status)
  TERMINAL_STATUSES.include?(status)
end

.valid?(status) ⇒ Boolean

Validate status value



79
80
81
# File 'lib/tastytrade/models/order_status.rb', line 79

def self.valid?(status)
  ALL_STATUSES.include?(status)
end

.working?(status) ⇒ Boolean

Check if status is in working phase



59
60
61
# File 'lib/tastytrade/models/order_status.rb', line 59

def self.working?(status)
  WORKING_STATUSES.include?(status)
end