Class: ThePlaidApi::Security
- Defined in:
- lib/the_plaid_api/models/security.rb
Overview
Contains details about a security
Instance Attribute Summary collapse
-
#cfi_code ⇒ String
The ISO-10962 Classification of Financial Instruments Code used to classify the security based on its structure and function.
-
#close_price ⇒ Float
Price of the security at the close of the previous trading session.
-
#close_price_as_of ⇒ Date
Date for which ‘close_price` is accurate.
-
#cusip ⇒ String
9-character CUSIP, an identifier assigned to North American securities.
-
#fixed_income ⇒ FixedIncome
Details about the fixed income security.
-
#industry ⇒ String
The industry classification of the security, such as Biotechnology, Airlines, etc.
-
#institution_id ⇒ String
If ‘institution_security_id` is present, this field indicates the Plaid `institution_id` of the institution to whom the identifier belongs.
-
#institution_security_id ⇒ String
An identifier given to the security by the institution.
-
#is_cash_equivalent ⇒ TrueClass | FalseClass
Indicates that a security is a highly liquid asset and can be treated like cash.
-
#isin ⇒ String
12-character ISIN, a globally unique securities identifier.
-
#iso_currency_code ⇒ String
The ISO-4217 currency code of the price given.
-
#market_identifier_code ⇒ String
The ISO-10383 Market Identifier Code of the exchange or market in which the security is being traded.
-
#name ⇒ String
A descriptive name for the security, suitable for display.
-
#option_contract ⇒ OptionContract
Details about the option security.
-
#proxy_security_id ⇒ String
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 ⇒ String
The sector classification of the security, such as Finance, Health Technology, etc.
-
#security_id ⇒ String
A unique, Plaid-specific identifier for the security, used to associate securities with holdings.
-
#sedol ⇒ String
(Deprecated) 7-character SEDOL, an identifier assigned to securities in the UK.
-
#subtype ⇒ String
The security subtype of the holding.
-
#ticker_symbol ⇒ String
The security’s trading symbol for publicly traded securities, and otherwise a short identifier if available.
-
#type ⇒ String
The security type of the holding.
-
#unofficial_currency_code ⇒ String
The unofficial currency code associated with the security.
-
#update_datetime ⇒ DateTime
Date and time at which ‘close_price` is accurate, in ISO 8601 format (YYYY-MM-DDTHH:mm:ssZ).
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(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:, iso_currency_code:, unofficial_currency_code:, market_identifier_code:, sector:, industry:, cfi_code:, option_contract:, fixed_income:, subtype: SKIP, update_datetime: SKIP, additional_properties: nil) ⇒ Security
constructor
A new instance of Security.
-
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
- #to_custom_update_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(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:, iso_currency_code:, unofficial_currency_code:, market_identifier_code:, sector:, industry:, cfi_code:, option_contract:, fixed_income:, subtype: SKIP, update_datetime: SKIP, additional_properties: nil) ⇒ Security
Returns a new instance of Security.
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 284 285 286 287 288 |
# File 'lib/the_plaid_api/models/security.rb', line 253 def initialize(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:, iso_currency_code:, unofficial_currency_code:, market_identifier_code:, sector:, industry:, cfi_code:, option_contract:, fixed_income:, subtype: SKIP, update_datetime: SKIP, additional_properties: nil) # Add additional model properties to the instance additional_properties = {} if additional_properties.nil? @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 unless subtype == SKIP @close_price = close_price @close_price_as_of = close_price_as_of @update_datetime = update_datetime unless update_datetime == SKIP @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 @additional_properties = additional_properties end |
Instance Attribute Details
#cfi_code ⇒ String
The ISO-10962 Classification of Financial Instruments Code used to classify the security based on its structure and function.
170 171 172 |
# File 'lib/the_plaid_api/models/security.rb', line 170 def cfi_code @cfi_code end |
#close_price ⇒ Float
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.
117 118 119 |
# File 'lib/the_plaid_api/models/security.rb', line 117 def close_price @close_price end |
#close_price_as_of ⇒ Date
Date for which ‘close_price` is accurate. Always `null` if `close_price` is `null`.
122 123 124 |
# File 'lib/the_plaid_api/models/security.rb', line 122 def close_price_as_of @close_price_as_of end |
#cusip ⇒ String
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/1FAIpQLSd9asHEYEfmf8fxJTHZTAfAzW4 dugsnSu-HS2J51f1mxwd6Sw/viewform).
39 40 41 |
# File 'lib/the_plaid_api/models/security.rb', line 39 def cusip @cusip end |
#fixed_income ⇒ FixedIncome
Details about the fixed income security.
186 187 188 |
# File 'lib/the_plaid_api/models/security.rb', line 186 def fixed_income @fixed_income end |
#industry ⇒ String
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/1L7aXUdqLhxgM8qe7hK67q qKXiUdQqILpwZ0LpxvCVnc).
165 166 167 |
# File 'lib/the_plaid_api/models/security.rb', line 165 def industry @industry end |
#institution_id ⇒ String
If ‘institution_security_id` is present, this field indicates the Plaid `institution_id` of the institution to whom the identifier belongs.
53 54 55 |
# File 'lib/the_plaid_api/models/security.rb', line 53 def institution_id @institution_id end |
#institution_security_id ⇒ String
An identifier given to the security by the institution
48 49 50 |
# File 'lib/the_plaid_api/models/security.rb', line 48 def institution_security_id @institution_security_id end |
#is_cash_equivalent ⇒ TrueClass | FalseClass
Indicates that a security is a highly liquid asset and can be treated like cash.
74 75 76 |
# File 'lib/the_plaid_api/models/security.rb', line 74 def is_cash_equivalent @is_cash_equivalent end |
#isin ⇒ String
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/1FAIpQLSd9asHEYEfmf8fxJTHZTAfAzW4 dugsnSu-HS2J51f1mxwd6Sw/viewform).
29 30 31 |
# File 'lib/the_plaid_api/models/security.rb', line 29 def isin @isin end |
#iso_currency_code ⇒ String
The ISO-4217 currency code of the price given. Always ‘null` if `unofficial_currency_code` is non-`null`.
132 133 134 |
# File 'lib/the_plaid_api/models/security.rb', line 132 def iso_currency_code @iso_currency_code end |
#market_identifier_code ⇒ String
The ISO-10383 Market Identifier Code of the exchange or market in which the security is being traded.
147 148 149 |
# File 'lib/the_plaid_api/models/security.rb', line 147 def market_identifier_code @market_identifier_code end |
#name ⇒ String
A descriptive name for the security, suitable for display.
64 65 66 |
# File 'lib/the_plaid_api/models/security.rb', line 64 def name @name end |
#option_contract ⇒ OptionContract
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).
182 183 184 |
# File 'lib/the_plaid_api/models/security.rb', line 182 def option_contract @option_contract end |
#proxy_security_id ⇒ String
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.
60 61 62 |
# File 'lib/the_plaid_api/models/security.rb', line 60 def proxy_security_id @proxy_security_id end |
#sector ⇒ String
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/1L7aXUdqLhxgM8qe7hK67q qKXiUdQqILpwZ0LpxvCVnc).
156 157 158 |
# File 'lib/the_plaid_api/models/security.rb', line 156 def sector @sector end |
#security_id ⇒ String
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.
19 20 21 |
# File 'lib/the_plaid_api/models/security.rb', line 19 def security_id @security_id end |
#sedol ⇒ String
(Deprecated) 7-character SEDOL, an identifier assigned to securities in the UK.
44 45 46 |
# File 'lib/the_plaid_api/models/security.rb', line 44 def sedol @sedol end |
#subtype ⇒ String
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`.
106 107 108 |
# File 'lib/the_plaid_api/models/security.rb', line 106 def subtype @subtype end |
#ticker_symbol ⇒ String
The security’s trading symbol for publicly traded securities, and otherwise a short identifier if available.
69 70 71 |
# File 'lib/the_plaid_api/models/security.rb', line 69 def ticker_symbol @ticker_symbol end |
#type ⇒ String
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
91 92 93 |
# File 'lib/the_plaid_api/models/security.rb', line 91 def type @type end |
#unofficial_currency_code ⇒ String
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.
142 143 144 |
# File 'lib/the_plaid_api/models/security.rb', line 142 def unofficial_currency_code @unofficial_currency_code end |
#update_datetime ⇒ DateTime
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`.
127 128 129 |
# File 'lib/the_plaid_api/models/security.rb', line 127 def update_datetime @update_datetime end |
Class Method Details
.from_hash(hash) ⇒ Object
Creates an instance of the object from a hash.
291 292 293 294 295 296 297 298 299 300 301 302 303 304 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 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 |
# File 'lib/the_plaid_api/models/security.rb', line 291 def self.from_hash(hash) return nil unless hash # Extract variables from the hash. security_id = hash.key?('security_id') ? hash['security_id'] : nil isin = hash.key?('isin') ? hash['isin'] : nil cusip = hash.key?('cusip') ? hash['cusip'] : nil sedol = hash.key?('sedol') ? hash['sedol'] : nil institution_security_id = hash.key?('institution_security_id') ? hash['institution_security_id'] : nil institution_id = hash.key?('institution_id') ? hash['institution_id'] : nil proxy_security_id = hash.key?('proxy_security_id') ? hash['proxy_security_id'] : nil name = hash.key?('name') ? hash['name'] : nil ticker_symbol = hash.key?('ticker_symbol') ? hash['ticker_symbol'] : nil is_cash_equivalent = hash.key?('is_cash_equivalent') ? hash['is_cash_equivalent'] : nil type = hash.key?('type') ? hash['type'] : nil close_price = hash.key?('close_price') ? hash['close_price'] : nil close_price_as_of = hash.key?('close_price_as_of') ? hash['close_price_as_of'] : 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 market_identifier_code = hash.key?('market_identifier_code') ? hash['market_identifier_code'] : nil sector = hash.key?('sector') ? hash['sector'] : nil industry = hash.key?('industry') ? hash['industry'] : nil cfi_code = hash.key?('cfi_code') ? hash['cfi_code'] : nil option_contract = OptionContract.from_hash(hash['option_contract']) if hash['option_contract'] fixed_income = FixedIncome.from_hash(hash['fixed_income']) if hash['fixed_income'] subtype = hash.key?('subtype') ? hash['subtype'] : SKIP update_datetime = if hash.key?('update_datetime') (DateTimeHelper.from_rfc3339(hash['update_datetime']) if hash['update_datetime']) else SKIP end # 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. Security.new(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, 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, subtype: subtype, update_datetime: update_datetime, additional_properties: additional_properties) end |
.names ⇒ Object
A mapping from model property names to API property names.
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 |
# File 'lib/the_plaid_api/models/security.rb', line 189 def self.names @_hash = {} if @_hash.nil? @_hash['security_id'] = 'security_id' @_hash['isin'] = 'isin' @_hash['cusip'] = 'cusip' @_hash['sedol'] = 'sedol' @_hash['institution_security_id'] = 'institution_security_id' @_hash['institution_id'] = 'institution_id' @_hash['proxy_security_id'] = 'proxy_security_id' @_hash['name'] = 'name' @_hash['ticker_symbol'] = 'ticker_symbol' @_hash['is_cash_equivalent'] = 'is_cash_equivalent' @_hash['type'] = 'type' @_hash['subtype'] = 'subtype' @_hash['close_price'] = 'close_price' @_hash['close_price_as_of'] = 'close_price_as_of' @_hash['update_datetime'] = 'update_datetime' @_hash['iso_currency_code'] = 'iso_currency_code' @_hash['unofficial_currency_code'] = 'unofficial_currency_code' @_hash['market_identifier_code'] = 'market_identifier_code' @_hash['sector'] = 'sector' @_hash['industry'] = 'industry' @_hash['cfi_code'] = 'cfi_code' @_hash['option_contract'] = 'option_contract' @_hash['fixed_income'] = 'fixed_income' @_hash end |
.nullables ⇒ Object
An array for nullable fields
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 |
# File 'lib/the_plaid_api/models/security.rb', line 226 def self.nullables %w[ 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 |
.optionals ⇒ Object
An array for optional fields
218 219 220 221 222 223 |
# File 'lib/the_plaid_api/models/security.rb', line 218 def self.optionals %w[ subtype update_datetime ] end |
Instance Method Details
#inspect ⇒ Object
Provides a debugging-friendly string with detailed object information.
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 |
# File 'lib/the_plaid_api/models/security.rb', line 386 def inspect class_name = self.class.name.split('::').last "<#{class_name} security_id: #{@security_id.inspect}, isin: #{@isin.inspect}, cusip:"\ " #{@cusip.inspect}, sedol: #{@sedol.inspect}, institution_security_id:"\ " #{@institution_security_id.inspect}, institution_id: #{@institution_id.inspect},"\ " proxy_security_id: #{@proxy_security_id.inspect}, name: #{@name.inspect}, ticker_symbol:"\ " #{@ticker_symbol.inspect}, is_cash_equivalent: #{@is_cash_equivalent.inspect}, type:"\ " #{@type.inspect}, subtype: #{@subtype.inspect}, close_price: #{@close_price.inspect},"\ " close_price_as_of: #{@close_price_as_of.inspect}, update_datetime:"\ " #{@update_datetime.inspect}, iso_currency_code: #{@iso_currency_code.inspect},"\ " unofficial_currency_code: #{@unofficial_currency_code.inspect}, market_identifier_code:"\ " #{@market_identifier_code.inspect}, sector: #{@sector.inspect}, industry:"\ " #{@industry.inspect}, cfi_code: #{@cfi_code.inspect}, option_contract:"\ " #{@option_contract.inspect}, fixed_income: #{@fixed_income.inspect},"\ " additional_properties: #{@additional_properties}>" end |
#to_custom_update_datetime ⇒ Object
366 367 368 |
# File 'lib/the_plaid_api/models/security.rb', line 366 def to_custom_update_datetime DateTimeHelper.to_rfc3339(update_datetime) end |
#to_s ⇒ Object
Provides a human-readable string representation of the object.
371 372 373 374 375 376 377 378 379 380 381 382 383 |
# File 'lib/the_plaid_api/models/security.rb', line 371 def to_s class_name = self.class.name.split('::').last "<#{class_name} 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}, additional_properties: #{@additional_properties}>" end |