Class: SecID::SEDOL
- Includes:
- Checkable
- Defined in:
- lib/sec_id/sedol.rb
Overview
Stock Exchange Daily Official List (SEDOL) - a 7-character alphanumeric code that identifies securities traded on the London Stock Exchange and other UK exchanges.
Format: 6-character identifier + 1-digit check digit Note: SEDOL excludes vowels (A, E, I, O, U) to avoid forming words.
Constant Summary collapse
- FULL_NAME =
Human-readable name of the standard.
'Stock Exchange Daily Official List'- ID_LENGTH =
Valid length(s) of a normalized identifier.
7- EXAMPLE =
A representative valid identifier.
'B0YBKJ7'- VALID_CHARS_REGEX =
Pattern matching the identifier's permitted character set.
/\A[0-9BCDFGHJKLMNPQRSTVWXYZ]+\z/- ID_REGEX =
Regular expression for parsing SEDOL components. Excludes vowels (A, E, I, O, U) from valid characters.
/\A (?<identifier>[0-9BCDFGHJKLMNPQRSTVWXYZ]{6}) (?<check_digit>\d)? \z/x- CHARACTER_WEIGHTS =
Weights applied to each character position in the check digit calculation.
[1, 3, 1, 7, 3, 9].freeze
- GENERATE_CHARSET =
Characters valid in a SEDOL body (alphanumeric excluding vowels).
ALPHANUMERIC.grep(VALID_CHARS_REGEX).freeze
- ISIN_COUNTRY_CODES =
Valid country codes for SEDOL to ISIN conversion.
Set.new(%w[GB IE GG IM JE FK]).freeze
Constants included from Checkable
Checkable::CHAR_TO_DIGIT, Checkable::CHAR_TO_DIGITS
Constants included from Generatable
Generatable::ALPHA, Generatable::ALPHANUMERIC, Generatable::DIGITS
Constants included from Validatable
Constants included from Normalizable
Instance Attribute Summary
Attributes inherited from Base
Instance Method Summary collapse
-
#calculate_check_digit ⇒ Integer
The calculated check digit (0-9).
-
#initialize(sedol) ⇒ SEDOL
constructor
A new instance of SEDOL.
-
#to_isin(country_code = 'GB') ⇒ ISIN
A new ISIN instance with calculated check digit.
Methods included from Checkable
#restore, #restore!, #to_s, #valid?
Methods inherited from Base
#==, #as_json, example, full_name, has_check_digit?, #hash, id_length, length_specificity, length_values, short_name, #to_h
Methods included from Validatable
#errors, #valid?, #validate, #validate!
Methods included from Normalizable
#normalize!, #normalized, #to_pretty_s, #to_s, #to_str
Constructor Details
#initialize(sedol) ⇒ SEDOL
Returns a new instance of SEDOL.
43 44 45 46 47 |
# File 'lib/sec_id/sedol.rb', line 43 def initialize(sedol) sedol_parts = parse sedol @identifier = sedol_parts[:identifier] @check_digit = sedol_parts[:check_digit]&.to_i end |
Instance Method Details
#calculate_check_digit ⇒ Integer
Returns the calculated check digit (0-9).
65 66 67 68 |
# File 'lib/sec_id/sedol.rb', line 65 def calculate_check_digit validate_format_for_calculation! mod10(weighted_sum) end |
#to_isin(country_code = 'GB') ⇒ ISIN
Returns a new ISIN instance with calculated check digit.
55 56 57 58 59 60 61 |
# File 'lib/sec_id/sedol.rb', line 55 def to_isin(country_code = 'GB') unless ISIN_COUNTRY_CODES.include?(country_code) raise InvalidFormatError, "'#{country_code}' is not a valid SEDOL country code!" end ISIN.new("#{country_code}00#{restore}").restore! end |