Class: Tastytrade::Instruments::Equity
- Inherits:
-
Object
- Object
- Tastytrade::Instruments::Equity
- Defined in:
- lib/tastytrade/instruments/equity.rb
Overview
Represents an equity instrument
Instance Attribute Summary collapse
-
#active ⇒ Object
readonly
Returns the value of attribute active.
-
#cusip ⇒ Object
readonly
Returns the value of attribute cusip.
-
#description ⇒ Object
readonly
Returns the value of attribute description.
-
#exchange ⇒ Object
readonly
Returns the value of attribute exchange.
-
#symbol ⇒ Object
readonly
Returns the value of attribute symbol.
Class Method Summary collapse
-
.get(session, symbol) ⇒ Equity
Get equity information for a symbol.
Instance Method Summary collapse
-
#build_leg(action:, quantity:) ⇒ OrderLeg
Create an order leg for this equity.
-
#initialize(data = {}) ⇒ Equity
constructor
A new instance of Equity.
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
#active ⇒ Object (readonly)
Returns the value of attribute active.
7 8 9 |
# File 'lib/tastytrade/instruments/equity.rb', line 7 def active @active end |
#cusip ⇒ Object (readonly)
Returns the value of attribute cusip.
7 8 9 |
# File 'lib/tastytrade/instruments/equity.rb', line 7 def cusip @cusip end |
#description ⇒ Object (readonly)
Returns the value of attribute description.
7 8 9 |
# File 'lib/tastytrade/instruments/equity.rb', line 7 def description @description end |
#exchange ⇒ Object (readonly)
Returns the value of attribute exchange.
7 8 9 |
# File 'lib/tastytrade/instruments/equity.rb', line 7 def exchange @exchange end |
#symbol ⇒ Object (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
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
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 |