Class: SchwabRb::DataObjects::OrderPreview::OrderStrategy

Inherits:
Object
  • Object
show all
Defined in:
lib/schwab_rb/data_objects/order_preview.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(attrs) ⇒ OrderStrategy

Returns a new instance of OrderStrategy.



68
69
70
71
72
73
74
75
76
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 68

def initialize(attrs)
  @status = attrs[:status]
  @price = attrs[:price]
  @quantity = attrs[:quantity]
  @order_type = attrs[:orderType]
  @type = attrs[:type]
  @strategy_id = attrs[:strategyId]
  @order_legs = attrs[:orderLegs]&.map { |leg| OrderLeg.build(leg) } || []
end

Instance Attribute Details

#order_legsObject (readonly)

Returns the value of attribute order_legs.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def order_legs
  @order_legs
end

#order_typeObject (readonly)

Returns the value of attribute order_type.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def order_type
  @order_type
end

#priceObject (readonly)

Returns the value of attribute price.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def price
  @price
end

#quantityObject (readonly)

Returns the value of attribute quantity.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def quantity
  @quantity
end

#statusObject (readonly)

Returns the value of attribute status.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def status
  @status
end

#strategy_idObject (readonly)

Returns the value of attribute strategy_id.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def strategy_id
  @strategy_id
end

#typeObject (readonly)

Returns the value of attribute type.



66
67
68
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 66

def type
  @type
end

Instance Method Details

#to_hObject



78
79
80
81
82
83
84
85
86
87
88
# File 'lib/schwab_rb/data_objects/order_preview.rb', line 78

def to_h
  {
    status: @status,
    price: @price,
    quantity: @quantity,
    orderType: @order_type,
    type: @type,
    strategyId: @strategy_id,
    orderLegs: @order_legs.map(&:to_h)
  }
end