T-38: M1.1b — Pass 2 normalization: ISIN/CUSIP validators, ticker root/suffix parser, IB fields in provider-symbol.ts
This commit is contained in:
parent
5483f7f127
commit
eb8e2aa57a
4 changed files with 27 additions and 18 deletions
|
|
@ -192,6 +192,11 @@ export function resolveIsin(input: ResolveIsinInput | null | undefined): Resolve
|
|||
return { isin, source: 'isin' };
|
||||
}
|
||||
|
||||
const isinPrefix = isin !== null && isin.length >= 2 ? isin.slice(0, 2) : null;
|
||||
if (country !== null && isNorthAmericaCountry(isinPrefix) && country !== isinPrefix) {
|
||||
return { isin: null, reason: 'invalid_isin_and_no_valid_cusip' };
|
||||
}
|
||||
|
||||
if (cusip !== null) {
|
||||
if (isValidCusip(cusip)) {
|
||||
if (country !== null) {
|
||||
|
|
@ -203,7 +208,6 @@ export function resolveIsin(input: ResolveIsinInput | null | undefined): Resolve
|
|||
return { isin: derived, source: 'cusip_derived' };
|
||||
}
|
||||
} else {
|
||||
const isinPrefix = isin !== null && isin.length >= 2 ? isin.slice(0, 2) : null;
|
||||
if (!isNorthAmericaCountry(isinPrefix)) {
|
||||
return { isin: null, reason: 'unsupported_country_for_cusip' };
|
||||
}
|
||||
|
|
@ -217,13 +221,10 @@ export function resolveIsin(input: ResolveIsinInput | null | undefined): Resolve
|
|||
}
|
||||
}
|
||||
|
||||
if (isin !== null && isin.length === 12) {
|
||||
const isinPrefix = isin.slice(0, 2);
|
||||
if (isNorthAmericaCountry(isinPrefix) && (country === null || country === isinPrefix)) {
|
||||
const derived = cusipToIsin(isin.slice(2, 11), isinPrefix);
|
||||
if (derived !== null) {
|
||||
return { isin: derived, source: 'cusip_derived' };
|
||||
}
|
||||
if (isin !== null && isin.length === 12 && isNorthAmericaCountry(isinPrefix)) {
|
||||
const derived = cusipToIsin(isin.slice(2, 11), isinPrefix);
|
||||
if (derived !== null) {
|
||||
return { isin: derived, source: 'cusip_derived' };
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue