Expand description
Conversions between securities identifiers.
An ISIN is the international wrapper around a national securities number (the NSIN). For three jurisdictions that wrapper is exact and reversible:
US / CA ISIN country prefix · 9-char NSIN · check NSIN IS the CUSIP
GB / IE ISIN country prefix · 00 + SEDOL · check NSIN IS 00 + SEDOL
CH / LI ISIN country prefix · 0…0 + VALOR · check NSIN IS padded VALOR- A US or CA ISIN embeds a
Cusipverbatim as its nine-character NSIN. Extracting the CUSIP is taking those nine characters; building the ISIN is prefixingUSorCAand computing a fresh ISIN check digit. - A GB or IE ISIN embeds a seven-character
Sedolright-aligned in the nine-character NSIN, left-padded with the two literal characters00. Extracting the SEDOL strips that00. - A CH or LI ISIN embeds a
Valor— a one-to-nine-digit number — left-padded with zeros to nine digits. Extracting the VALOR strips the leading zeros.
The two check-digit schemes are independent: the CUSIP, SEDOL, and ISIN
algorithms are unrelated, so every conversion recomputes — never reuses —
the target’s check digit and re-parses the result through the target type’s
own validator. A conversion with no defined meaning (a non-US/CA ISIN to a
CUSIP, say) returns ConversionError::UnsupportedCountry; a conversion
whose result is not a valid identifier returns
ConversionError::NotConvertible or ConversionError::Validation. A
conversion never returns a wrong answer.
Every *_to_isin function and build_isin left-pads a short national
number into the nine-character NSIN field, so a Sedol (00 + 7) and a
Valor (zero-padded to 9) land where the standard places them.
§References
- ISO 6166 (ISIN), ANSI X9.6 (CUSIP), London Stock Exchange (SEDOL), SIX Financial Information (VALOR) — the schemes whose embedding rules these conversions implement.
Functions§
- build_
isin - Assembles an ISIN from a two-character country prefix and a national number, computing the ISIN check digit.
- cusip_
to_ isin - Wraps a
Cusipinto an ISIN for the given country. - isin_
to_ cusip - Extracts the
Cusipembedded in a United States or Canada ISIN. - isin_
to_ sedol - Extracts the
Sedolembedded in a United Kingdom or Ireland ISIN. - isin_
to_ valor - Extracts the
Valorembedded in a Switzerland or Liechtenstein ISIN. - sedol_
to_ isin - Wraps a
Sedolinto an ISIN for the given country. - valor_
to_ isin - Wraps a
Valorinto an ISIN for the given country.