Class: Tastytrade::OrderLeg

Inherits:
Object
  • Object
show all
Defined in:
lib/tastytrade/order.rb

Overview

Represents a single leg of an order

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(action:, symbol:, quantity:, instrument_type: "Equity") ⇒ OrderLeg

Returns a new instance of OrderLeg.



37
38
39
40
41
42
43
44
# File 'lib/tastytrade/order.rb', line 37

def initialize(action:, symbol:, quantity:, instrument_type: "Equity")
  validate_action!(action)

  @action = action
  @symbol = symbol
  @quantity = quantity.to_i
  @instrument_type = instrument_type
end

Instance Attribute Details

#actionObject (readonly)

Returns the value of attribute action.



35
36
37
# File 'lib/tastytrade/order.rb', line 35

def action
  @action
end

#instrument_typeObject (readonly)

Returns the value of attribute instrument_type.



35
36
37
# File 'lib/tastytrade/order.rb', line 35

def instrument_type
  @instrument_type
end

#quantityObject (readonly)

Returns the value of attribute quantity.



35
36
37
# File 'lib/tastytrade/order.rb', line 35

def quantity
  @quantity
end

#symbolObject (readonly)

Returns the value of attribute symbol.



35
36
37
# File 'lib/tastytrade/order.rb', line 35

def symbol
  @symbol
end

Instance Method Details

#to_api_paramsObject



46
47
48
49
50
51
52
53
# File 'lib/tastytrade/order.rb', line 46

def to_api_params
  {
    "action" => @action,
    "symbol" => @symbol,
    "quantity" => @quantity,
    "instrument-type" => @instrument_type
  }
end