Class: Plaid::Security
- Inherits:
-
Object
- Object
- Plaid::Security
- Defined in:
- lib/plaid/models/security.rb
Overview
Contains details about a security
Instance Attribute Summary collapse
-
#cfi_code ⇒ Object
The ISO-10962 Classification of Financial Instruments Code used to classify the security based on its structure and function.
-
#close_price ⇒ Object
Price of the security at the close of the previous trading session.
-
#close_price_as_of ⇒ Object
Date for which ‘close_price` is accurate.
-
#cusip ⇒ Object
9-character CUSIP, an identifier assigned to North American securities.
-
#fixed_income ⇒ Object
Returns the value of attribute fixed_income.
-
#industry ⇒ Object
The industry classification of the security, such as Biotechnology, Airlines, etc.
-
#institution_id ⇒ Object
If ‘institution_security_id` is present, this field indicates the Plaid `institution_id` of the institution to whom the identifier belongs.
-
#institution_security_id ⇒ Object
An identifier given to the security by the institution.
-
#is_cash_equivalent ⇒ Object
Indicates that a security is a highly liquid asset and can be treated like cash.
-
#isin ⇒ Object
12-character ISIN, a globally unique securities identifier.
-
#iso_currency_code ⇒ Object
The ISO-4217 currency code of the price given.
-
#market_identifier_code ⇒ Object
The ISO-10383 Market Identifier Code of the exchange or market in which the security is being traded.
-
#name ⇒ Object
A descriptive name for the security, suitable for display.
-
#option_contract ⇒ Object
Returns the value of attribute option_contract.
-
#proxy_security_id ⇒ Object
In certain cases, Plaid will provide the ID of another security whose performance resembles this security, typically when the original security has low volume, or when a private security can be modeled with a publicly traded security.
-
#sector ⇒ Object
The sector classification of the security, such as Finance, Health Technology, etc.
-
#security_id ⇒ Object
A unique, Plaid-specific identifier for the security, used to associate securities with holdings.
-
#sedol ⇒ Object
(Deprecated) 7-character SEDOL, an identifier assigned to securities in the UK.
-
#subtype ⇒ Object
The security subtype of the holding.
-
#ticker_symbol ⇒ Object
The security’s trading symbol for publicly traded securities, and otherwise a short identifier if available.
-
#type ⇒ Object
The security type of the holding.
-
#unofficial_currency_code ⇒ Object
The unofficial currency code associated with the security.
-
#update_datetime ⇒ Object
Date and time at which ‘close_price` is accurate, in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ).
Class Method Summary collapse
-
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about.
-
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
-
.build_from_hash(attributes) ⇒ Object
Builds the object from hash.
-
.openapi_nullable ⇒ Object
List of attributes with nullable: true.
-
.openapi_types ⇒ Object
Attribute type mapping.
Instance Method Summary collapse
-
#==(o) ⇒ Object
Checks equality by comparing each attribute.
-
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type.
-
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash.
-
#build_from_hash(attributes) ⇒ Object
Builds the object from hash.
- #eql?(o) ⇒ Boolean
-
#hash ⇒ Integer
Calculates hash code according to all attributes.
-
#initialize(attributes = {}) ⇒ Security
constructor
Initializes the object.
-
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons.
-
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility).
-
#to_hash ⇒ Hash
Returns the object in the form of hash.
-
#to_s ⇒ String
Returns the string representation of the object.
-
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid.
Constructor Details
#initialize(attributes = {}) ⇒ Security
Initializes the object
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 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 |
# File 'lib/plaid/models/security.rb', line 179 def initialize(attributes = {}) if (!attributes.is_a?(Hash)) fail ArgumentError, "The input argument (attributes) must be a hash in `Plaid::Security` initialize method" end # check to see if the attribute exists and convert string to symbol for hash key attributes = attributes.each_with_object({}) { |(k, v), h| if (!self.class.attribute_map.key?(k.to_sym)) fail ArgumentError, "`#{k}` is not a valid attribute in `Plaid::Security`. Please check the name to make sure it's valid. List of attributes: " + self.class.attribute_map.keys.inspect end h[k.to_sym] = v } if attributes.key?(:'security_id') self.security_id = attributes[:'security_id'] end if attributes.key?(:'isin') self.isin = attributes[:'isin'] end if attributes.key?(:'cusip') self.cusip = attributes[:'cusip'] end if attributes.key?(:'sedol') self.sedol = attributes[:'sedol'] end if attributes.key?(:'institution_security_id') self.institution_security_id = attributes[:'institution_security_id'] end if attributes.key?(:'institution_id') self.institution_id = attributes[:'institution_id'] end if attributes.key?(:'proxy_security_id') self.proxy_security_id = attributes[:'proxy_security_id'] end if attributes.key?(:'name') self.name = attributes[:'name'] end if attributes.key?(:'ticker_symbol') self.ticker_symbol = attributes[:'ticker_symbol'] end if attributes.key?(:'is_cash_equivalent') self.is_cash_equivalent = attributes[:'is_cash_equivalent'] end if attributes.key?(:'type') self.type = attributes[:'type'] end if attributes.key?(:'subtype') self.subtype = attributes[:'subtype'] end if attributes.key?(:'close_price') self.close_price = attributes[:'close_price'] end if attributes.key?(:'close_price_as_of') self.close_price_as_of = attributes[:'close_price_as_of'] end if attributes.key?(:'update_datetime') self.update_datetime = attributes[:'update_datetime'] end if attributes.key?(:'iso_currency_code') self.iso_currency_code = attributes[:'iso_currency_code'] end if attributes.key?(:'unofficial_currency_code') self.unofficial_currency_code = attributes[:'unofficial_currency_code'] end if attributes.key?(:'market_identifier_code') self.market_identifier_code = attributes[:'market_identifier_code'] end if attributes.key?(:'sector') self.sector = attributes[:'sector'] end if attributes.key?(:'industry') self.industry = attributes[:'industry'] end if attributes.key?(:'cfi_code') self.cfi_code = attributes[:'cfi_code'] end if attributes.key?(:'option_contract') self.option_contract = attributes[:'option_contract'] end if attributes.key?(:'fixed_income') self.fixed_income = attributes[:'fixed_income'] end end |
Instance Attribute Details
#cfi_code ⇒ Object
The ISO-10962 Classification of Financial Instruments Code used to classify the security based on its structure and function.
80 81 82 |
# File 'lib/plaid/models/security.rb', line 80 def cfi_code @cfi_code end |
#close_price ⇒ Object
Price of the security at the close of the previous trading session. Null for non-public securities. If the security is a foreign currency this field will be updated daily and will be priced in USD. If the security is a cryptocurrency, this field will be updated multiple times a day. As crypto prices can fluctuate quickly and data may become stale sooner than other asset classes, refer to ‘update_datetime` with the time when the price was last updated.
56 57 58 |
# File 'lib/plaid/models/security.rb', line 56 def close_price @close_price end |
#close_price_as_of ⇒ Object
Date for which ‘close_price` is accurate. Always `null` if `close_price` is `null`.
59 60 61 |
# File 'lib/plaid/models/security.rb', line 59 def close_price_as_of @close_price_as_of end |
#cusip ⇒ Object
9-character CUSIP, an identifier assigned to North American securities. A verified CUSIP Global Services license is required to receive this data. This field will be null by default for new customers, and null for existing customers starting March 12, 2024. If you would like access to this field, please start the verification process [here](docs.google.com/forms/d/e/1FAIpQLSd9asHEYEfmf8fxJTHZTAfAzW4dugsnSu-HS2J51f1mxwd6Sw/viewform).
26 27 28 |
# File 'lib/plaid/models/security.rb', line 26 def cusip @cusip end |
#fixed_income ⇒ Object
Returns the value of attribute fixed_income.
84 85 86 |
# File 'lib/plaid/models/security.rb', line 84 def fixed_income @fixed_income end |
#industry ⇒ Object
The industry classification of the security, such as Biotechnology, Airlines, etc. For a complete list of possible values, please refer to the ["Sectors and Industries" spreadsheet](docs.google.com/spreadsheets/d/1L7aXUdqLhxgM8qe7hK67qqKXiUdQqILpwZ0LpxvCVnc).
77 78 79 |
# File 'lib/plaid/models/security.rb', line 77 def industry @industry end |
#institution_id ⇒ Object
If ‘institution_security_id` is present, this field indicates the Plaid `institution_id` of the institution to whom the identifier belongs.
35 36 37 |
# File 'lib/plaid/models/security.rb', line 35 def institution_id @institution_id end |
#institution_security_id ⇒ Object
An identifier given to the security by the institution
32 33 34 |
# File 'lib/plaid/models/security.rb', line 32 def institution_security_id @institution_security_id end |
#is_cash_equivalent ⇒ Object
Indicates that a security is a highly liquid asset and can be treated like cash.
47 48 49 |
# File 'lib/plaid/models/security.rb', line 47 def is_cash_equivalent @is_cash_equivalent end |
#isin ⇒ Object
12-character ISIN, a globally unique securities identifier. A verified CUSIP Global Services license is required to receive this data. This field will be null by default for new customers, and null for existing customers starting March 12, 2024. If you would like access to this field, please start the verification process [here](docs.google.com/forms/d/e/1FAIpQLSd9asHEYEfmf8fxJTHZTAfAzW4dugsnSu-HS2J51f1mxwd6Sw/viewform).
23 24 25 |
# File 'lib/plaid/models/security.rb', line 23 def isin @isin end |
#iso_currency_code ⇒ Object
The ISO-4217 currency code of the price given. Always ‘null` if `unofficial_currency_code` is non-`null`.
65 66 67 |
# File 'lib/plaid/models/security.rb', line 65 def iso_currency_code @iso_currency_code end |
#market_identifier_code ⇒ Object
The ISO-10383 Market Identifier Code of the exchange or market in which the security is being traded.
71 72 73 |
# File 'lib/plaid/models/security.rb', line 71 def market_identifier_code @market_identifier_code end |
#name ⇒ Object
A descriptive name for the security, suitable for display.
41 42 43 |
# File 'lib/plaid/models/security.rb', line 41 def name @name end |
#option_contract ⇒ Object
Returns the value of attribute option_contract.
82 83 84 |
# File 'lib/plaid/models/security.rb', line 82 def option_contract @option_contract end |
#proxy_security_id ⇒ Object
In certain cases, Plaid will provide the ID of another security whose performance resembles this security, typically when the original security has low volume, or when a private security can be modeled with a publicly traded security.
38 39 40 |
# File 'lib/plaid/models/security.rb', line 38 def proxy_security_id @proxy_security_id end |
#sector ⇒ Object
The sector classification of the security, such as Finance, Health Technology, etc. For a complete list of possible values, please refer to the ["Sectors and Industries" spreadsheet](docs.google.com/spreadsheets/d/1L7aXUdqLhxgM8qe7hK67qqKXiUdQqILpwZ0LpxvCVnc).
74 75 76 |
# File 'lib/plaid/models/security.rb', line 74 def sector @sector end |
#security_id ⇒ Object
A unique, Plaid-specific identifier for the security, used to associate securities with holdings. Like all Plaid identifiers, the ‘security_id` is case sensitive. The `security_id` 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.
20 21 22 |
# File 'lib/plaid/models/security.rb', line 20 def security_id @security_id end |
#sedol ⇒ Object
(Deprecated) 7-character SEDOL, an identifier assigned to securities in the UK.
29 30 31 |
# File 'lib/plaid/models/security.rb', line 29 def sedol @sedol end |
#subtype ⇒ Object
The security subtype of the holding. In rare instances, a null value is returned when institutional data is insufficient to determine the security subtype. Possible values: ‘asset backed security`, `bill`, `bond`, `bond with warrants`, `cash`, `cash management bill`, `common stock`, `convertible bond`, `convertible equity`, `cryptocurrency`, `depositary receipt`, `depositary receipt on debt`, `etf`, `float rating note`, `fund of funds`, `hedge fund`, `limited partnership unit`, `medium term note`, `money market debt`, `mortgage backed security`, `municipal bond`, `mutual fund`, `note`, `option`, `other`, `preferred convertible`, `preferred equity`, `private equity fund`, `real estate investment trust`, `structured equity product`, `treasury inflation protected securities`, `unit`, `warrant`.
53 54 55 |
# File 'lib/plaid/models/security.rb', line 53 def subtype @subtype end |
#ticker_symbol ⇒ Object
The security’s trading symbol for publicly traded securities, and otherwise a short identifier if available.
44 45 46 |
# File 'lib/plaid/models/security.rb', line 44 def ticker_symbol @ticker_symbol end |
#type ⇒ Object
The security type of the holding. In rare instances, a null value is returned when institutional data is insufficient to determine the security type. Valid security types are: ‘cash`: Cash, currency, and money market funds `cryptocurrency`: Digital or virtual currencies `derivative`: Options, warrants, and other derivative instruments `equity`: Domestic and foreign equities `etf`: Multi-asset exchange-traded investment funds `fixed income`: Bonds and certificates of deposit (CDs) `loan`: Loans and loan receivables `mutual fund`: Open- and closed-end vehicles pooling funds of multiple investors `other`: Unknown or other investment types
50 51 52 |
# File 'lib/plaid/models/security.rb', line 50 def type @type end |
#unofficial_currency_code ⇒ Object
The unofficial currency code associated with the security. 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.
68 69 70 |
# File 'lib/plaid/models/security.rb', line 68 def unofficial_currency_code @unofficial_currency_code end |
#update_datetime ⇒ Object
Date and time at which ‘close_price` is accurate, in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ). Always `null` if `close_price` is `null`.
62 63 64 |
# File 'lib/plaid/models/security.rb', line 62 def update_datetime @update_datetime end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
116 117 118 |
# File 'lib/plaid/models/security.rb', line 116 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 |
# File 'lib/plaid/models/security.rb', line 87 def self.attribute_map { :'security_id' => :'security_id', :'isin' => :'isin', :'cusip' => :'cusip', :'sedol' => :'sedol', :'institution_security_id' => :'institution_security_id', :'institution_id' => :'institution_id', :'proxy_security_id' => :'proxy_security_id', :'name' => :'name', :'ticker_symbol' => :'ticker_symbol', :'is_cash_equivalent' => :'is_cash_equivalent', :'type' => :'type', :'subtype' => :'subtype', :'close_price' => :'close_price', :'close_price_as_of' => :'close_price_as_of', :'update_datetime' => :'update_datetime', :'iso_currency_code' => :'iso_currency_code', :'unofficial_currency_code' => :'unofficial_currency_code', :'market_identifier_code' => :'market_identifier_code', :'sector' => :'sector', :'industry' => :'industry', :'cfi_code' => :'cfi_code', :'option_contract' => :'option_contract', :'fixed_income' => :'fixed_income' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
348 349 350 |
# File 'lib/plaid/models/security.rb', line 348 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 |
# File 'lib/plaid/models/security.rb', line 150 def self.openapi_nullable Set.new([ :'isin', :'cusip', :'sedol', :'institution_security_id', :'institution_id', :'proxy_security_id', :'name', :'ticker_symbol', :'is_cash_equivalent', :'type', :'subtype', :'close_price', :'close_price_as_of', :'update_datetime', :'iso_currency_code', :'unofficial_currency_code', :'market_identifier_code', :'sector', :'industry', :'cfi_code', :'option_contract', :'fixed_income' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 |
# File 'lib/plaid/models/security.rb', line 121 def self.openapi_types { :'security_id' => :'String', :'isin' => :'String', :'cusip' => :'String', :'sedol' => :'String', :'institution_security_id' => :'String', :'institution_id' => :'String', :'proxy_security_id' => :'String', :'name' => :'String', :'ticker_symbol' => :'String', :'is_cash_equivalent' => :'Boolean', :'type' => :'String', :'subtype' => :'String', :'close_price' => :'Float', :'close_price_as_of' => :'Date', :'update_datetime' => :'Time', :'iso_currency_code' => :'String', :'unofficial_currency_code' => :'String', :'market_identifier_code' => :'String', :'sector' => :'String', :'industry' => :'String', :'cfi_code' => :'String', :'option_contract' => :'OptionContract', :'fixed_income' => :'FixedIncome' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 |
# File 'lib/plaid/models/security.rb', line 305 def ==(o) return true if self.equal?(o) self.class == o.class && security_id == o.security_id && isin == o.isin && cusip == o.cusip && sedol == o.sedol && institution_security_id == o.institution_security_id && institution_id == o.institution_id && proxy_security_id == o.proxy_security_id && name == o.name && ticker_symbol == o.ticker_symbol && is_cash_equivalent == o.is_cash_equivalent && type == o.type && subtype == o.subtype && close_price == o.close_price && close_price_as_of == o.close_price_as_of && update_datetime == o.update_datetime && iso_currency_code == o.iso_currency_code && unofficial_currency_code == o.unofficial_currency_code && market_identifier_code == o.market_identifier_code && sector == o.sector && industry == o.industry && cfi_code == o.cfi_code && option_contract == o.option_contract && fixed_income == o.fixed_income end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 |
# File 'lib/plaid/models/security.rb', line 379 def _deserialize(type, value) case type.to_sym when :Time Time.parse(value) when :Date Date.parse(value) when :String value.to_s when :Integer value.to_i when :Float value.to_f when :Boolean if value.to_s =~ /\A(true|t|yes|y|1)\z/i true else false end when :Object # generic object (usually a Hash), return directly value when /\AArray<(?<inner_type>.+)>\z/ inner_type = Regexp.last_match[:inner_type] value.map { |v| _deserialize(inner_type, v) } when /\AHash<(?<k_type>.+?), (?<v_type>.+)>\z/ k_type = Regexp.last_match[:k_type] v_type = Regexp.last_match[:v_type] {}.tap do |hash| value.each do |k, v| hash[_deserialize(k_type, k)] = _deserialize(v_type, v) end end else # model # models (e.g. Pet) or oneOf klass = Plaid.const_get(type) klass.respond_to?(:openapi_one_of) ? klass.build(value) : klass.build_from_hash(value) end end |
#_to_hash(value) ⇒ Hash
Outputs non-array value in the form of hash For object, use to_hash. Otherwise, just return the value
450 451 452 453 454 455 456 457 458 459 460 461 462 |
# File 'lib/plaid/models/security.rb', line 450 def _to_hash(value) if value.is_a?(Array) value.compact.map { |v| _to_hash(v) } elsif value.is_a?(Hash) {}.tap do |hash| value.each { |k, v| hash[k] = _to_hash(v) } end elsif value.respond_to? :to_hash value.to_hash else value end end |
#build_from_hash(attributes) ⇒ Object
Builds the object from hash
355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 |
# File 'lib/plaid/models/security.rb', line 355 def build_from_hash(attributes) return nil unless attributes.is_a?(Hash) attributes = attributes.transform_keys(&:to_sym) self.class.openapi_types.each_pair do |key, type| if attributes[self.class.attribute_map[key]].nil? && self.class.openapi_nullable.include?(key) self.send("#{key}=", nil) elsif type =~ /\AArray<(.*)>/i # check to ensure the input is an array given that the attribute # is documented as an array but the input is not if attributes[self.class.attribute_map[key]].is_a?(Array) self.send("#{key}=", attributes[self.class.attribute_map[key]].map { |v| _deserialize($1, v) }) end elsif !attributes[self.class.attribute_map[key]].nil? self.send("#{key}=", _deserialize(type, attributes[self.class.attribute_map[key]])) end end self end |
#eql?(o) ⇒ Boolean
335 336 337 |
# File 'lib/plaid/models/security.rb', line 335 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
341 342 343 |
# File 'lib/plaid/models/security.rb', line 341 def hash [security_id, isin, cusip, sedol, institution_security_id, institution_id, proxy_security_id, name, ticker_symbol, is_cash_equivalent, type, subtype, close_price, close_price_as_of, update_datetime, iso_currency_code, unofficial_currency_code, market_identifier_code, sector, industry, cfi_code, option_contract, fixed_income].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
287 288 289 290 291 292 293 294 |
# File 'lib/plaid/models/security.rb', line 287 def list_invalid_properties invalid_properties = Array.new if @security_id.nil? invalid_properties.push('invalid value for "security_id", security_id cannot be nil.') end invalid_properties end |
#to_body ⇒ Hash
to_body is an alias to to_hash (backward compatibility)
426 427 428 |
# File 'lib/plaid/models/security.rb', line 426 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
432 433 434 435 436 437 438 439 440 441 442 443 444 |
# File 'lib/plaid/models/security.rb', line 432 def to_hash hash = {} self.class.attribute_map.each_pair do |attr, param| value = self.send(attr) if value.nil? is_nullable = self.class.openapi_nullable.include?(attr) next if !is_nullable || (is_nullable && !instance_variable_defined?(:"@#{attr}")) end hash[param] = _to_hash(value) end hash end |
#to_s ⇒ String
Returns the string representation of the object
420 421 422 |
# File 'lib/plaid/models/security.rb', line 420 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
298 299 300 301 |
# File 'lib/plaid/models/security.rb', line 298 def valid? return false if @security_id.nil? true end |