T-66: tests
This commit is contained in:
parent
e468148c70
commit
141a3a6d2b
1 changed files with 107 additions and 0 deletions
|
|
@ -1133,6 +1133,113 @@ describe('security master Pass 6 OTC delisting chain linker', () => {
|
|||
assertReconciliationAndContracts(result, listings.length);
|
||||
});
|
||||
|
||||
test('T-66 suppression keys on undated OTC rows only: stale undated stubs suppress, undated non-OTC rows and active-only groups do not', () => {
|
||||
const datedPair = (isin: string, root: string): StageBListingCandidate[] => [
|
||||
makeListing({ primaryIsin: isin, mic: 'XNAS', tickerRoot: root, listedTo: '2023-03-10' }),
|
||||
makeListing({
|
||||
primaryIsin: isin,
|
||||
mic: 'OTCM',
|
||||
tickerRoot: `${root}Q`,
|
||||
listedFrom: '2023-03-15',
|
||||
listedTo: '2024-01-01',
|
||||
}),
|
||||
];
|
||||
const listings: StageBListingCandidate[] = [
|
||||
// Undated OTC stub that ended years before the primary: still suppresses (conservative Rule 5).
|
||||
...datedPair('US4600000001', 'STLE'),
|
||||
makeListing({
|
||||
primaryIsin: 'US4600000001',
|
||||
mic: 'OTCM',
|
||||
tickerRoot: 'STLEU',
|
||||
listedFrom: null,
|
||||
listedTo: '2010-01-04',
|
||||
}),
|
||||
// Undated non-OTC row in the group is not an OTC continuation candidate: link still forms.
|
||||
...datedPair('US4600000002', 'NOTC'),
|
||||
makeListing({
|
||||
primaryIsin: 'US4600000002',
|
||||
mic: 'XNYS',
|
||||
tickerRoot: 'NOTCN',
|
||||
listedFrom: null,
|
||||
listedTo: null,
|
||||
}),
|
||||
// Undated OTC row with an active (never-ended) primary: nothing to link, no conflict.
|
||||
makeListing({ primaryIsin: 'US4600000003', mic: 'XNAS', tickerRoot: 'ACTV', listedTo: null }),
|
||||
makeListing({
|
||||
primaryIsin: 'US4600000003',
|
||||
mic: 'OTCM',
|
||||
tickerRoot: 'ACTVU',
|
||||
listedFrom: null,
|
||||
listedTo: null,
|
||||
}),
|
||||
];
|
||||
|
||||
const result = linkDelistingChains(
|
||||
{ listings, otcMics: DEFAULT_OTC_MICS },
|
||||
{ asOfDate: '2025-11-27' }
|
||||
);
|
||||
|
||||
expect(result.continuities).toHaveLength(1);
|
||||
expect(result.continuities[0]).toMatchObject({
|
||||
fromListingKey: { primaryIsin: 'US4600000002', tickerRoot: 'NOTC' },
|
||||
toListingKey: { primaryIsin: 'US4600000002', tickerRoot: 'NOTCQ' },
|
||||
effectiveDate: '2023-03-15',
|
||||
});
|
||||
expect(result.conflicts).toHaveLength(1);
|
||||
expect(result.conflicts[0]).toMatchObject({
|
||||
conflictKind: 'missing_otc_listed_from',
|
||||
detail: { primaryIsin: 'US4600000001', listedFrom: null, listedTo: '2010-01-04' },
|
||||
});
|
||||
expect(result.conflicts[0]?.detail.toListingKeys.map(k => k.tickerRoot)).toEqual(['STLEU']);
|
||||
expect(result.conflicts[0]?.detail.fromListingKeys.map(k => k.tickerRoot)).toEqual(['STLE']);
|
||||
|
||||
const byTicker = new Map(result.listingOutcomes.map(o => [o.listingKey.tickerRoot, o]));
|
||||
expect(byTicker.get('STLE')).toMatchObject({
|
||||
delistReason: 'unknown_involuntary',
|
||||
terminalReturn: SHUMWAY_PRIMARY_TERMINAL_RETURN,
|
||||
});
|
||||
expect(byTicker.get('NOTC')).toMatchObject({ delistReason: 'moved_to_otc', terminalReturn: null });
|
||||
expect(byTicker.get('ACTV')).toMatchObject({ delistReason: 'active', terminalReturn: null });
|
||||
expect(byTicker.get('ACTVU')).toMatchObject({ delistReason: 'active', terminalReturn: null });
|
||||
expect(result.stats.continuitiesCreated).toBe(1);
|
||||
expect(result.stats.byOutcome.moved_to_otc).toBe(1);
|
||||
assertReconciliationAndContracts(result, listings.length);
|
||||
|
||||
// Custom otcMics: suppression follows the caller's OTC venue set, not a hard-coded MIC.
|
||||
const customListings: StageBListingCandidate[] = [
|
||||
makeListing({ primaryIsin: 'US4600000004', mic: 'XNAS', tickerRoot: 'CUST', listedTo: '2023-03-10' }),
|
||||
makeListing({
|
||||
primaryIsin: 'US4600000004',
|
||||
mic: 'PINX',
|
||||
tickerRoot: 'CUSTQ',
|
||||
listedFrom: '2023-03-15',
|
||||
listedTo: '2024-01-01',
|
||||
}),
|
||||
makeListing({
|
||||
primaryIsin: 'US4600000004',
|
||||
mic: 'PINX',
|
||||
tickerRoot: 'CUSTU',
|
||||
listedFrom: null,
|
||||
listedTo: null,
|
||||
}),
|
||||
];
|
||||
const suppressed = linkDelistingChains(
|
||||
{ listings: customListings, otcMics: new Set(['PINX']) },
|
||||
{ asOfDate: '2025-11-27' }
|
||||
);
|
||||
expect(suppressed.continuities).toEqual([]);
|
||||
expect(suppressed.conflicts.map(c => c.conflictKind)).toEqual(['missing_otc_listed_from']);
|
||||
assertReconciliationAndContracts(suppressed, customListings.length);
|
||||
|
||||
// Removing only the undated OTC row restores the link, proving the undated row is the sole cause.
|
||||
const unsuppressed = linkDelistingChains(
|
||||
{ listings: customListings.slice(0, 2), otcMics: new Set(['PINX']) },
|
||||
{ asOfDate: '2025-11-27' }
|
||||
);
|
||||
expect(unsuppressed.continuities).toHaveLength(1);
|
||||
expect(unsuppressed.conflicts).toEqual([]);
|
||||
});
|
||||
|
||||
test('throws TypeError or RangeError on invalid options or container arguments', () => {
|
||||
const emptyInput = { listings: [], otcMics: DEFAULT_OTC_MICS };
|
||||
const validOpts = { asOfDate: '2025-11-27' };
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue