Class: ThePlaidApi::Holding
- Defined in:
- lib/the_plaid_api/models/holding.rb
Overview
A securities holding at an institution.
Instance Attribute Summary collapse
-
#account_id ⇒ String
The Plaid ‘account_id` associated with the holding.
-
#cost_basis ⇒ Float
The total cost basis of the holding (e.g., the total amount spent to acquire all assets currently in the holding).
-
#institution_price ⇒ Float
The last price given by the institution for this security.
-
#institution_price_as_of ⇒ Date
The date at which ‘institution_price` was current.
-
#institution_price_datetime ⇒ DateTime
Date and time at which ‘institution_price` was current, in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ).
-
#institution_value ⇒ Float
The value of the holding, as reported by the institution.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the holding.
-
#quantity ⇒ Float
The total quantity of the asset held, as reported by the financial institution.
-
#security_id ⇒ String
The Plaid ‘security_id` associated with the holding.
-
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the holding.
-
#vested_quantity ⇒ Float
The total quantity of vested assets held, as reported by the financial institution.
-
#vested_value ⇒ Float
The value of the vested holdings as reported by the institution.
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(account_id:, security_id:, institution_price:, institution_value:, cost_basis:, quantity:, iso_currency_code:, unofficial_currency_code:, institution_price_as_of: SKIP, institution_price_datetime: SKIP, vested_quantity: SKIP, vested_value: SKIP, additional_properties: nil) ⇒ Holding
constructor
A new instance of Holding.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_institution_price_datetime ⇒ Object
-
#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(account_id:, security_id:, institution_price:, institution_value:, cost_basis:, quantity:, iso_currency_code:, unofficial_currency_code:, institution_price_as_of: SKIP, institution_price_datetime: SKIP, vested_quantity: SKIP, vested_value: SKIP, additional_properties: nil) ⇒ Holding
Returns a new instance of Holding.
127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 |
# File 'lib/the_plaid_api/models/holding.rb', line 127 def initialize(account_id:, security_id:, institution_price:, institution_value:, cost_basis:, quantity:, iso_currency_code:, unofficial_currency_code:, institution_price_as_of: SKIP, institution_price_datetime: SKIP, vested_quantity: SKIP, vested_value: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @account_id = account_id @security_id = security_id @institution_price = institution_price @institution_price_as_of = institution_price_as_of unless institution_price_as_of == SKIP unless institution_price_datetime == SKIP @institution_price_datetime = institution_price_datetime end @institution_value = institution_value @cost_basis = cost_basis @quantity = quantity @iso_currency_code = iso_currency_code @unofficial_currency_code = unofficial_currency_code @vested_quantity = vested_quantity unless vested_quantity == SKIP @vested_value = vested_value unless vested_value == SKIP @additional_properties = additional_properties end |
Instance Attribute Details
#account_id ⇒ String
The Plaid ‘account_id` associated with the holding.
15 16 17 |
# File 'lib/the_plaid_api/models/holding.rb', line 15 def account_id @account_id end |
#cost_basis ⇒ Float
The total cost basis of the holding (e.g., the total amount spent to acquire all assets currently in the holding).
51 52 53 |
# File 'lib/the_plaid_api/models/holding.rb', line 51 def cost_basis @cost_basis end |
#institution_price ⇒ Float
The last price given by the institution for this security.
30 31 32 |
# File 'lib/the_plaid_api/models/holding.rb', line 30 def institution_price @institution_price end |
#institution_price_as_of ⇒ Date
The date at which ‘institution_price` was current.
34 35 36 |
# File 'lib/the_plaid_api/models/holding.rb', line 34 def institution_price_as_of @institution_price_as_of end |
#institution_price_datetime ⇒ DateTime
Date and time at which ‘institution_price` was current, in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ). This field is returned for select financial institutions and comes as provided by the institution. It may contain default time values (such as 00:00:00).
42 43 44 |
# File 'lib/the_plaid_api/models/holding.rb', line 42 def institution_price_datetime @institution_price_datetime end |
#institution_value ⇒ Float
The value of the holding, as reported by the institution.
46 47 48 |
# File 'lib/the_plaid_api/models/holding.rb', line 46 def institution_value @institution_value end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the holding. Always ‘null` if `unofficial_currency_code` is non-`null`.
63 64 65 |
# File 'lib/the_plaid_api/models/holding.rb', line 63 def iso_currency_code @iso_currency_code end |
#quantity ⇒ Float
The total quantity of the asset held, as reported by the financial institution. If the security is an option, ‘quantity` will reflect the total number of options (typically the number of contracts multiplied by 100), not the number of contracts.
58 59 60 |
# File 'lib/the_plaid_api/models/holding.rb', line 58 def quantity @quantity end |
#security_id ⇒ String
The Plaid ‘security_id` associated with the holding. Security data is not specific to a user’s account; any user who held the same security at the same financial institution at the same time would have identical security data. The ‘security_id` for the same security will typically be the same across different institutions, but this is not guaranteed. The `security_id` does not typically change, but may change if inherent details of the security change due to a corporate action, for example, in the event of a ticker symbol change or CUSIP change.
26 27 28 |
# File 'lib/the_plaid_api/models/holding.rb', line 26 def security_id @security_id end |
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the holding. Always ‘null` if `iso_currency_code` is non-`null`. Unofficial currency codes are used for currencies that do not have official ISO currency codes, such as cryptocurrencies and the currencies of certain countries. See the [currency code schema](plaid.com/docs/api/accounts#currency-code-schema) for a full listing of supported `iso_currency_code`s.
73 74 75 |
# File 'lib/the_plaid_api/models/holding.rb', line 73 def unofficial_currency_code @unofficial_currency_code end |
#vested_quantity ⇒ Float
The total quantity of vested assets held, as reported by the financial institution. Vested assets are only associated with [equities](plaid.com/docs/api/products/investments/#investments-ho ldings-get-response-securities-type).
80 81 82 |
# File 'lib/the_plaid_api/models/holding.rb', line 80 def vested_quantity @vested_quantity end |
#vested_value ⇒ Float
The value of the vested holdings as reported by the institution.
84 85 86 |
# File 'lib/the_plaid_api/models/holding.rb', line 84 def vested_value @vested_value end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 |
# File 'lib/the_plaid_api/models/holding.rb', line 155 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. account_id = hash.key?('account_id') ? hash['account_id'] : nil security_id = hash.key?('security_id') ? hash['security_id'] : nil institution_price = hash.key?('institution_price') ? hash['institution_price'] : nil institution_value = hash.key?('institution_value') ? hash['institution_value'] : nil cost_basis = hash.key?('cost_basis') ? hash['cost_basis'] : nil quantity = hash.key?('quantity') ? hash['quantity'] : nil iso_currency_code = hash.key?('iso_currency_code') ? hash['iso_currency_code'] : nil unofficial_currency_code = hash.key?('unofficial_currency_code') ? hash['unofficial_currency_code'] : nil institution_price_as_of = hash.key?('institution_price_as_of') ? hash['institution_price_as_of'] : SKIP institution_price_datetime = if hash.key?('institution_price_datetime') (DateTimeHelper.from_rfc3339(hash['institution_price_datetime']) if hash['institution_price_datetime']) else SKIP end vested_quantity = hash.key?('vested_quantity') ? hash['vested_quantity'] : SKIP vested_value = hash.key?('vested_value') ? hash['vested_value'] : SKIP # 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. Holding.new(account_id: account_id, security_id: security_id, institution_price: institution_price, institution_value: institution_value, cost_basis: cost_basis, quantity: quantity, iso_currency_code: iso_currency_code, unofficial_currency_code: unofficial_currency_code, institution_price_as_of: institution_price_as_of, institution_price_datetime: institution_price_datetime, vested_quantity: vested_quantity, vested_value: vested_value, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 |
# File 'lib/the_plaid_api/models/holding.rb', line 87 def self.names @_hash = {} if @_hash.nil? @_hash['account_id'] = 'account_id' @_hash['security_id'] = 'security_id' @_hash['institution_price'] = 'institution_price' @_hash['institution_price_as_of'] = 'institution_price_as_of' @_hash['institution_price_datetime'] = 'institution_price_datetime' @_hash['institution_value'] = 'institution_value' @_hash['cost_basis'] = 'cost_basis' @_hash['quantity'] = 'quantity' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash['vested_quantity'] = 'vested_quantity' @_hash['vested_value'] = 'vested_value' @_hash end |
.nullables ⇒ Object
An array for nullable fields
115 116 117 118 119 120 121 122 123 124 125 |
# File 'lib/the_plaid_api/models/holding.rb', line 115 def self.nullables %w[ institution_price_as_of institution_price_datetime cost_basis iso_currency_code unofficial_currency_code vested_quantity vested_value ] end |
.optionals ⇒ Object
An array for optional fields
105 106 107 108 109 110 111 112 |
# File 'lib/the_plaid_api/models/holding.rb', line 105 def self.optionals %w[ institution_price_as_of institution_price_datetime vested_quantity vested_value ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
222 223 224 225 226 227 228 229 230 231 232 |
# File 'lib/the_plaid_api/models/holding.rb', line 222 def inspect class_name = self.class.name.split('::').last "<#{class_name} account_id: #{@account_id.inspect}, security_id: #{@security_id.inspect},"\ " institution_price: #{@institution_price.inspect}, institution_price_as_of:"\ " #{@institution_price_as_of.inspect}, institution_price_datetime:"\ " #{@institution_price_datetime.inspect}, institution_value: #{@institution_value.inspect},"\ " cost_basis: #{@cost_basis.inspect}, quantity: #{@quantity.inspect}, iso_currency_code:"\ " #{@iso_currency_code.inspect}, unofficial_currency_code:"\ " #{@unofficial_currency_code.inspect}, vested_quantity: #{@vested_quantity.inspect},"\ " vested_value: #{@vested_value.inspect}, additional_properties: #{@additional_properties}>" end |
#to_custom_institution_price_datetime ⇒ Object
205 206 207 |
# File 'lib/the_plaid_api/models/holding.rb', line 205 def to_custom_institution_price_datetime DateTimeHelper.to_rfc3339(institution_price_datetime) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
210 211 212 213 214 215 216 217 218 219 |
# File 'lib/the_plaid_api/models/holding.rb', line 210 def to_s class_name = self.class.name.split('::').last "<#{class_name} account_id: #{@account_id}, security_id: #{@security_id},"\ " institution_price: #{@institution_price}, institution_price_as_of:"\ " #{@institution_price_as_of}, institution_price_datetime: #{@institution_price_datetime},"\ " institution_value: #{@institution_value}, cost_basis: #{@cost_basis}, quantity:"\ " #{@quantity}, iso_currency_code: #{@iso_currency_code}, unofficial_currency_code:"\ " #{@unofficial_currency_code}, vested_quantity: #{@vested_quantity}, vested_value:"\ " #{@vested_value}, additional_properties: #{@additional_properties}>" end |