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
-
#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
7-character SEDOL, an identifier assigned to securities in the UK.
-
#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
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 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 |
# File 'lib/plaid/models/security.rb', line 167 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?(:'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?(:'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
#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.
53 54 55 |
# File 'lib/plaid/models/security.rb', line 53 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`.
56 57 58 |
# File 'lib/plaid/models/security.rb', line 56 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.
78 79 80 |
# File 'lib/plaid/models/security.rb', line 78 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).
74 75 76 |
# File 'lib/plaid/models/security.rb', line 74 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`.
62 63 64 |
# File 'lib/plaid/models/security.rb', line 62 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.
68 69 70 |
# File 'lib/plaid/models/security.rb', line 68 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.
76 77 78 |
# File 'lib/plaid/models/security.rb', line 76 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).
71 72 73 |
# File 'lib/plaid/models/security.rb', line 71 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
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 |
#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.
65 66 67 |
# File 'lib/plaid/models/security.rb', line 65 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`.
59 60 61 |
# File 'lib/plaid/models/security.rb', line 59 def update_datetime @update_datetime end |
Class Method Details
.acceptable_attributes ⇒ Object
Returns all the JSON keys this model knows about
108 109 110 |
# File 'lib/plaid/models/security.rb', line 108 def self.acceptable_attributes attribute_map.values end |
.attribute_map ⇒ Object
Attribute mapping from ruby-style variable name to JSON key.
81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/plaid/models/security.rb', line 81 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', :'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', :'option_contract' => :'option_contract', :'fixed_income' => :'fixed_income' } end |
.build_from_hash(attributes) ⇒ Object
Builds the object from hash
326 327 328 |
# File 'lib/plaid/models/security.rb', line 326 def self.build_from_hash(attributes) new.build_from_hash(attributes) end |
.openapi_nullable ⇒ Object
List of attributes with nullable: true
140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 |
# File 'lib/plaid/models/security.rb', line 140 def self.openapi_nullable Set.new([ :'isin', :'cusip', :'sedol', :'institution_security_id', :'institution_id', :'proxy_security_id', :'name', :'ticker_symbol', :'is_cash_equivalent', :'type', :'close_price', :'close_price_as_of', :'update_datetime', :'iso_currency_code', :'unofficial_currency_code', :'market_identifier_code', :'sector', :'industry', :'option_contract', :'fixed_income' ]) end |
.openapi_types ⇒ Object
Attribute type mapping.
113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 |
# File 'lib/plaid/models/security.rb', line 113 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', :'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', :'option_contract' => :'OptionContract', :'fixed_income' => :'FixedIncome' } end |
Instance Method Details
#==(o) ⇒ Object
Checks equality by comparing each attribute.
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 |
# File 'lib/plaid/models/security.rb', line 285 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 && 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 && option_contract == o.option_contract && fixed_income == o.fixed_income end |
#_deserialize(type, value) ⇒ Object
Deserializes the data based on type
357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 |
# File 'lib/plaid/models/security.rb', line 357 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
428 429 430 431 432 433 434 435 436 437 438 439 440 |
# File 'lib/plaid/models/security.rb', line 428 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
333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 |
# File 'lib/plaid/models/security.rb', line 333 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
313 314 315 |
# File 'lib/plaid/models/security.rb', line 313 def eql?(o) self == o end |
#hash ⇒ Integer
Calculates hash code according to all attributes.
319 320 321 |
# File 'lib/plaid/models/security.rb', line 319 def hash [security_id, isin, cusip, sedol, institution_security_id, institution_id, proxy_security_id, name, ticker_symbol, is_cash_equivalent, type, close_price, close_price_as_of, update_datetime, iso_currency_code, unofficial_currency_code, market_identifier_code, sector, industry, option_contract, fixed_income].hash end |
#list_invalid_properties ⇒ Object
Show invalid properties with the reasons. Usually used together with valid?
267 268 269 270 271 272 273 274 |
# File 'lib/plaid/models/security.rb', line 267 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)
404 405 406 |
# File 'lib/plaid/models/security.rb', line 404 def to_body to_hash end |
#to_hash ⇒ Hash
Returns the object in the form of hash
410 411 412 413 414 415 416 417 418 419 420 421 422 |
# File 'lib/plaid/models/security.rb', line 410 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
398 399 400 |
# File 'lib/plaid/models/security.rb', line 398 def to_s to_hash.to_s end |
#valid? ⇒ Boolean
Check to see if the all the properties in the model are valid
278 279 280 281 |
# File 'lib/plaid/models/security.rb', line 278 def valid? return false if @security_id.nil? true end |