Class: SchwabRb::DataObjects::OrderLeg
- Inherits:
-
Object
- Object
- SchwabRb::DataObjects::OrderLeg
- Defined in:
- lib/schwab_rb/data_objects/order_leg.rb
Instance Attribute Summary collapse
-
#instruction ⇒ Object
readonly
Returns the value of attribute instruction.
-
#instrument ⇒ Object
readonly
Returns the value of attribute instrument.
-
#leg_id ⇒ Object
readonly
Returns the value of attribute leg_id.
-
#order_leg_type ⇒ Object
readonly
Returns the value of attribute order_leg_type.
-
#position_effect ⇒ Object
readonly
Returns the value of attribute position_effect.
-
#quantity ⇒ Object
readonly
Returns the value of attribute quantity.
Class Method Summary collapse
Instance Method Summary collapse
- #call? ⇒ Boolean
- #close? ⇒ Boolean
- #description ⇒ Object
-
#initialize(leg_id:, order_leg_type:, quantity:, instrument:, instruction:, position_effect:) ⇒ OrderLeg
constructor
A new instance of OrderLeg.
- #instrument_id ⇒ Object
- #open? ⇒ Boolean
- #put? ⇒ Boolean
- #put_call ⇒ Object
- #symbol ⇒ Object
- #to_h ⇒ Object
Constructor Details
#initialize(leg_id:, order_leg_type:, quantity:, instrument:, instruction:, position_effect:) ⇒ OrderLeg
Returns a new instance of OrderLeg.
23 24 25 26 27 28 29 30 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 23 def initialize(leg_id:, order_leg_type:, quantity:, instrument:, instruction:, position_effect:) @leg_id = leg_id @order_leg_type = order_leg_type @quantity = quantity @instrument = instrument @instruction = instruction @position_effect = position_effect end |
Instance Attribute Details
#instruction ⇒ Object (readonly)
Returns the value of attribute instruction.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 8 def instruction @instruction end |
#instrument ⇒ Object (readonly)
Returns the value of attribute instrument.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 8 def instrument @instrument end |
#leg_id ⇒ Object (readonly)
Returns the value of attribute leg_id.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 8 def leg_id @leg_id end |
#order_leg_type ⇒ Object (readonly)
Returns the value of attribute order_leg_type.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 8 def order_leg_type @order_leg_type end |
#position_effect ⇒ Object (readonly)
Returns the value of attribute position_effect.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 8 def position_effect @position_effect end |
#quantity ⇒ Object (readonly)
Returns the value of attribute quantity.
8 9 10 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 8 def quantity @quantity end |
Class Method Details
.build(data) ⇒ Object
11 12 13 14 15 16 17 18 19 20 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 11 def build(data) new( leg_id: data[:legId], order_leg_type: data[:orderLegType], quantity: data[:quantity], instrument: Instrument.build(data[:instrument]), instruction: data.fetch(:instruction, nil), position_effect: data[:positionEffect] ) end |
Instance Method Details
#call? ⇒ Boolean
36 37 38 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 36 def call? put_call == "CALL" end |
#close? ⇒ Boolean
40 41 42 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 40 def close? position_effect == "CLOSING" end |
#description ⇒ Object
60 61 62 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 60 def description instrument.description end |
#instrument_id ⇒ Object
32 33 34 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 32 def instrument_id instrument.instrument_id end |
#open? ⇒ Boolean
44 45 46 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 44 def open? position_effect == "OPENING" end |
#put? ⇒ Boolean
48 49 50 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 48 def put? put_call == "PUT" end |
#put_call ⇒ Object
52 53 54 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 52 def put_call instrument.put_call end |
#symbol ⇒ Object
56 57 58 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 56 def symbol instrument.symbol end |
#to_h ⇒ Object
64 65 66 67 68 69 70 71 72 73 |
# File 'lib/schwab_rb/data_objects/order_leg.rb', line 64 def to_h { legId: @leg_id, orderLegType: @order_leg_type, quantity: @quantity, instrument: @instrument.to_h, instruction: @instruction, positionEffect: @position_effect } end |