Class: ThePlaidApi::OptionContract
- Defined in:
- lib/the_plaid_api/models/option_contract.rb
Overview
Details about the option security. For the Sandbox environment, this data is currently only available if the Item is using a [custom Sandbox user](plaid.com/docs/sandbox/user-custom/) and the ‘ticker` field of the custom security follows the [OCC Option Symbol](en.wikipedia.org/wiki/Option_symbol#The_OCC_Option_Symbol) standard with no spaces. For an example of simulating this in Sandbox, see the [custom Sandbox GitHub](github.com/plaid/sandbox-custom-users).
Instance Attribute Summary collapse
-
#contract_type ⇒ String
The type of this option contract.
-
#expiration_date ⇒ Date
The expiration date for this option contract, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.
-
#strike_price ⇒ Float
The strike price for this option contract, per share of security.
-
#underlying_security_ticker ⇒ String
The ticker of the underlying security for this option contract.
Class Method Summary collapse
-
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
-
.names ⇒ Object
A mapping from model property names to API property names.
-
.nullables ⇒ Object
An array for nullable fields.
-
.optionals ⇒ Object
An array for optional fields.
Instance Method Summary collapse
-
#initialize(contract_type:, expiration_date:, strike_price:, underlying_security_ticker:, additional_properties: nil) ⇒ OptionContract
constructor
A new instance of OptionContract.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
-
#to_s ⇒ Object
Provides a human-readable string representation of the object.
Methods inherited from BaseModel
#check_for_conflict, #process_additional_properties, #process_array, #process_basic_value, #process_hash, #to_hash, #to_json
Constructor Details
#initialize(contract_type:, expiration_date:, strike_price:, underlying_security_ticker:, additional_properties: nil) ⇒ OptionContract
Returns a new instance of OptionContract.
57 58 59 60 61 62 63 64 65 66 67 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 57 def initialize(contract_type:, expiration_date:, strike_price:, underlying_security_ticker:, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @contract_type = contract_type @expiration_date = expiration_date @strike_price = strike_price @underlying_security_ticker = @additional_properties = additional_properties end |
Instance Attribute Details
#contract_type ⇒ String
The type of this option contract. It is one of: ‘put`: for Put option contracts `call`: for Call option contracts
22 23 24 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 22 def contract_type @contract_type end |
#expiration_date ⇒ Date
The expiration date for this option contract, in [ISO 8601](wikipedia.org/wiki/ISO_8601) format.
27 28 29 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 27 def expiration_date @expiration_date end |
#strike_price ⇒ Float
The strike price for this option contract, per share of security.
31 32 33 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 31 def strike_price @strike_price end |
#underlying_security_ticker ⇒ String
The ticker of the underlying security for this option contract.
35 36 37 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 35 def @underlying_security_ticker end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 70 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. contract_type = hash.key?('contract_type') ? hash['contract_type'] : nil expiration_date = hash.key?('expiration_date') ? hash['expiration_date'] : nil strike_price = hash.key?('strike_price') ? hash['strike_price'] : nil = hash.key?('underlying_security_ticker') ? hash['underlying_security_ticker'] : nil # Create a new hash for additional properties, removing known properties. new_hash = hash.reject { |k, _| names.value?(k) } additional_properties = APIHelper.get_additional_properties( new_hash, proc { |value| value } ) # Create object from extracted values. OptionContract.new(contract_type: contract_type, expiration_date: expiration_date, strike_price: strike_price, underlying_security_ticker: , additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
38 39 40 41 42 43 44 45 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 38 def self.names @_hash = {} if @_hash.nil? @_hash['contract_type'] = 'contract_type' @_hash['expiration_date'] = 'expiration_date' @_hash['strike_price'] = 'strike_price' @_hash['underlying_security_ticker'] = 'underlying_security_ticker' @_hash end |
.nullables ⇒ Object
An array for nullable fields
53 54 55 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 53 def self.nullables [] end |
.optionals ⇒ Object
An array for optional fields
48 49 50 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 48 def self.optionals [] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
105 106 107 108 109 110 111 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 105 def inspect class_name = self.class.name.split('::').last "<#{class_name} contract_type: #{@contract_type.inspect}, expiration_date:"\ " #{@expiration_date.inspect}, strike_price: #{@strike_price.inspect},"\ " underlying_security_ticker: #{@underlying_security_ticker.inspect}, additional_properties:"\ " #{@additional_properties}>" end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
97 98 99 100 101 102 |
# File 'lib/the_plaid_api/models/option_contract.rb', line 97 def to_s class_name = self.class.name.split('::').last "<#{class_name} contract_type: #{@contract_type}, expiration_date: #{@expiration_date},"\ " strike_price: #{@strike_price}, underlying_security_ticker:"\ " #{@underlying_security_ticker}, additional_properties: #{@additional_properties}>" end |