Class: Tastytrade::Models::LiveOrderLeg
- Defined in:
- lib/tastytrade/models/live_order.rb
Overview
Represents a leg in a live order
Instance Attribute Summary collapse
-
#action ⇒ Object
readonly
Returns the value of attribute action.
-
#execution_price ⇒ Object
readonly
Returns the value of attribute execution_price.
-
#fill_price ⇒ Object
readonly
Returns the value of attribute fill_price.
-
#fill_quantity ⇒ Object
readonly
Returns the value of attribute fill_quantity.
-
#fills ⇒ Object
readonly
Returns the value of attribute fills.
-
#instrument_type ⇒ Object
readonly
Returns the value of attribute instrument_type.
-
#position_effect ⇒ Object
readonly
Returns the value of attribute position_effect.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
-
#ratio_quantity ⇒ Object
readonly
Returns the value of attribute ratio_quantity.
-
#remaining_quantity ⇒ Object
readonly
Returns the value of attribute remaining_quantity.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Attributes inherited from Base
Instance Method Summary collapse
-
#filled? ⇒ Boolean
Check if leg is completely filled.
-
#filled_quantity ⇒ Object
Calculate filled quantity.
-
#partially_filled? ⇒ Boolean
Check if leg is partially filled.
-
#to_h ⇒ Object
Convert to hash for JSON serialization.
Methods inherited from Base
Constructor Details
This class inherits a constructor from Tastytrade::Models::Base
Instance Attribute Details
#action ⇒ Object (readonly)
Returns the value of attribute action.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def action @action end |
#execution_price ⇒ Object (readonly)
Returns the value of attribute execution_price.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def execution_price @execution_price end |
#fill_price ⇒ Object (readonly)
Returns the value of attribute fill_price.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def fill_price @fill_price end |
#fill_quantity ⇒ Object (readonly)
Returns the value of attribute fill_quantity.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def fill_quantity @fill_quantity end |
#fills ⇒ Object (readonly)
Returns the value of attribute fills.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def fills @fills end |
#instrument_type ⇒ Object (readonly)
Returns the value of attribute instrument_type.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def instrument_type @instrument_type end |
#position_effect ⇒ Object (readonly)
Returns the value of attribute position_effect.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def position_effect @position_effect end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def quantity @quantity end |
#ratio_quantity ⇒ Object (readonly)
Returns the value of attribute ratio_quantity.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def ratio_quantity @ratio_quantity end |
#remaining_quantity ⇒ Object (readonly)
Returns the value of attribute remaining_quantity.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def remaining_quantity @remaining_quantity end |
#symbol ⇒ Object (readonly)
Returns the value of attribute symbol.
172 173 174 |
# File 'lib/tastytrade/models/live_order.rb', line 172 def symbol @symbol end |
Instance Method Details
#filled? ⇒ Boolean
Check if leg is completely filled
183 184 185 |
# File 'lib/tastytrade/models/live_order.rb', line 183 def filled? @remaining_quantity.to_i == 0 end |
#filled_quantity ⇒ Object
Calculate filled quantity
177 178 179 180 |
# File 'lib/tastytrade/models/live_order.rb', line 177 def filled_quantity return 0 if @quantity.nil? || @remaining_quantity.nil? @quantity - @remaining_quantity end |
#partially_filled? ⇒ Boolean
Check if leg is partially filled
188 189 190 |
# File 'lib/tastytrade/models/live_order.rb', line 188 def partially_filled? !filled? && filled_quantity > 0 end |
#to_h ⇒ Object
Convert to hash for JSON serialization
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 |
# File 'lib/tastytrade/models/live_order.rb', line 193 def to_h { symbol: @symbol, instrument_type: @instrument_type, action: @action, quantity: @quantity, remaining_quantity: @remaining_quantity, filled_quantity: filled_quantity, fill_quantity: @fill_quantity, fill_price: @fill_price&.to_s("F"), execution_price: @execution_price&.to_s("F"), position_effect: @position_effect, ratio_quantity: @ratio_quantity, fills: @fills&.map(&:to_h) }.compact end |