Class: Tastytrade::Instruments::Equity

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

Overview

Represents an equity instrument

Instance Attribute Summary collapse

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(data = {}) ⇒ Equity

Returns a new instance of Equity.



9
10
11
12
13
14
15
# File 'lib/tastytrade/instruments/equity.rb', line 9

def initialize(data = {})
  @symbol = data["symbol"]
  @description = data["description"]
  @exchange = data["exchange"]
  @cusip = data["cusip"]
  @active = data["active"]
end

Instance Attribute Details

#activeObject (readonly)

Returns the value of attribute active.



7
8
9
# File 'lib/tastytrade/instruments/equity.rb', line 7

def active
  @active
end

#cusipObject (readonly)

Returns the value of attribute cusip.



7
8
9
# File 'lib/tastytrade/instruments/equity.rb', line 7

def cusip
  @cusip
end

#descriptionObject (readonly)

Returns the value of attribute description.



7
8
9
# File 'lib/tastytrade/instruments/equity.rb', line 7

def description
  @description
end

#exchangeObject (readonly)

Returns the value of attribute exchange.



7
8
9
# File 'lib/tastytrade/instruments/equity.rb', line 7

def exchange
  @exchange
end

#symbolObject (readonly)

Returns the value of attribute symbol.



7
8
9
# File 'lib/tastytrade/instruments/equity.rb', line 7

def symbol
  @symbol
end

Class Method Details

.get(session, symbol) ⇒ Equity

Get equity information for a symbol

Parameters:

Returns:

  • (Equity)

    Equity instrument



22
23
24
25
# File 'lib/tastytrade/instruments/equity.rb', line 22

def self.get(session, symbol)
  response = session.get("/instruments/equities/#{symbol}")
  new(response["data"])
end

Instance Method Details

#build_leg(action:, quantity:) ⇒ OrderLeg

Create an order leg for this equity

Parameters:

  • action (String)

    Order action (from OrderAction module)

  • quantity (Integer)

    Number of shares

Returns:

  • (OrderLeg)

    Order leg for this equity



32
33
34
35
36
37
38
39
# File 'lib/tastytrade/instruments/equity.rb', line 32

def build_leg(action:, quantity:)
  OrderLeg.new(
    action: action,
    symbol: @symbol,
    quantity: quantity,
    instrument_type: "Equity"
  )
end