T-86: M1.1k — Read-only Mongo source-symbol readers: eodSymbols / ibSymbols / qmSymbols / ceoSymbols / eodSymbolChange → Stage A + Stage B input records (no new dependencies)

This commit is contained in:
Studio 2026-11-28 04:36:37 -05:00
parent cadc3d1b6d
commit 2888dfb136
3 changed files with 226 additions and 51 deletions

View file

@ -301,10 +301,11 @@ export const REVIEWED_US_CA_EXCHANGE_SOURCE_MAP_ROWS: readonly ExchangeSourceMap
{ source: 'eod' as const, sourceCode: 'PINK', role: 'primary_venue' as const, mic: 'OTCM', countryIso: 'US' },
{ source: 'eod' as const, sourceCode: 'TO', role: 'primary_venue' as const, mic: 'XTSE', countryIso: 'CA' },
{ source: 'eod' as const, sourceCode: 'V', role: 'primary_venue' as const, mic: 'XTSX', countryIso: 'CA' },
// IB US + CA primary venues (ATS/routing venues live in EXPLICIT_EXCHANGE_SOURCE_RULES)
// IB US + CA venues (additional ATS/routing venues live in EXPLICIT_EXCHANGE_SOURCE_RULES)
{ source: 'ib' as const, sourceCode: 'AMEX', role: 'primary_venue' as const, mic: 'XASE', countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'ARCA', role: 'primary_venue' as const, mic: 'ARCX', countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'BATS', role: 'primary_venue' as const, mic: 'BATS', countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'EDGX', role: 'ats_routing' as const, mic: null, countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'ISLAND', role: 'primary_venue' as const, mic: 'XNAS', countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'NASDAQ', role: 'primary_venue' as const, mic: 'XNAS', countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'NEO', role: 'primary_venue' as const, mic: 'NEOE', countryIso: 'CA' },
@ -314,7 +315,7 @@ export const REVIEWED_US_CA_EXCHANGE_SOURCE_MAP_ROWS: readonly ExchangeSourceMap
{ source: 'ib' as const, sourceCode: 'TSE', role: 'primary_venue' as const, mic: 'XTSE', countryIso: 'CA' },
{ source: 'ib' as const, sourceCode: 'VALUE', role: 'primary_venue' as const, mic: 'OTCM', countryIso: 'US' },
{ source: 'ib' as const, sourceCode: 'VENTURE', role: 'primary_venue' as const, mic: 'XTSX', countryIso: 'CA' },
// QuoteMedia US + CA primary venues (qmExchanges has 0% OperatingMIC)
// QuoteMedia US + CA venues (qmExchanges has 0% OperatingMIC)
{ source: 'qm' as const, sourceCode: 'AMEX', role: 'primary_venue' as const, mic: 'XASE', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'AQL', role: 'primary_venue' as const, mic: 'NEOE', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'ARC', role: 'primary_venue' as const, mic: 'ARCX', countryIso: 'US' },
@ -324,11 +325,16 @@ export const REVIEWED_US_CA_EXCHANGE_SOURCE_MAP_ROWS: readonly ExchangeSourceMap
{ source: 'qm' as const, sourceCode: 'BTS', role: 'primary_venue' as const, mic: 'BATS', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'BZX', role: 'primary_venue' as const, mic: 'BATS', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'CC', role: 'primary_venue' as const, mic: 'XCNQ', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CCQ TSX', role: 'composite' as const, mic: null, countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CCQ TSXV', role: 'composite' as const, mic: null, countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CDX', role: 'primary_venue' as const, mic: 'XTSX', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CNQ', role: 'primary_venue' as const, mic: 'XCNQ', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CNX', role: 'primary_venue' as const, mic: 'XCNQ', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CSE', role: 'primary_venue' as const, mic: 'XCNQ', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'CVE', role: 'primary_venue' as const, mic: 'XTSX', countryIso: 'CA' },
{ source: 'qm' as const, sourceCode: 'EDGA', role: 'ats_routing' as const, mic: null, countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'EDGX', role: 'ats_routing' as const, mic: null, countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'EGX', role: 'ats_routing' as const, mic: null, countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'IEX', role: 'primary_venue' as const, mic: 'IEXG', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'NASDAQ', role: 'primary_venue' as const, mic: 'XNAS', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'NCM', role: 'primary_venue' as const, mic: 'XNAS', countryIso: 'US' },
@ -341,6 +347,7 @@ export const REVIEWED_US_CA_EXCHANGE_SOURCE_MAP_ROWS: readonly ExchangeSourceMap
{ source: 'qm' as const, sourceCode: 'NYE', role: 'primary_venue' as const, mic: 'XNYS', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'NYS', role: 'primary_venue' as const, mic: 'XNYS', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'NYSE', role: 'primary_venue' as const, mic: 'XNYS', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'NYSE AMERICAN', role: 'primary_venue' as const, mic: 'XASE', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'NYSEMKT', role: 'primary_venue' as const, mic: 'XASE', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'OBB', role: 'primary_venue' as const, mic: 'OTCM', countryIso: 'US' },
{ source: 'qm' as const, sourceCode: 'OTC', role: 'primary_venue' as const, mic: 'OTCM', countryIso: 'US' },

View file

@ -263,7 +263,6 @@ export interface SecurityMasterSourcesResult {
}
const ISO2_PATTERN = /^[A-Z]{2}$/;
const DEFAULT_CEO_CA_CODES: readonly string[] = Object.freeze(['AQL', 'CDX', 'CNQ', 'TSX']);
const COUNTRY_ISO2_ALIASES: Readonly<Record<string, readonly string[]>> = Object.freeze({
US: Object.freeze(['US', 'USA', 'U.S.', 'U.S.A.', 'United States', 'United States of America']),
@ -842,16 +841,20 @@ function buildEodCountryFilter(
return {};
}
const countryValues = expandCountryFilterValues(countries);
const exchangeCodes =
typeof exchangeLookup.getCodesForCountries === 'function'
? exchangeLookup.getCodesForCountries('eod', countries)
: [];
const clauses: Record<string, unknown>[] = [];
if (countryValues.length > 0) {
clauses.push({ Country: { $in: countryValues } });
clauses.push({ countryCode: { $in: countryValues } });
if (countryValues.length === 0) {
return { ...EMPTY_MATCH_FILTER };
}
// When the lookup cannot enumerate in-scope venue codes, keep the query conservative
// so countryless documents that derive country from Exchange are not dropped before the adapter.
if (typeof exchangeLookup.getCodesForCountries !== 'function') {
return {};
}
const exchangeCodes = exchangeLookup.getCodesForCountries('eod', countries);
const clauses: Record<string, unknown>[] = [
{ Country: { $in: countryValues } },
{ countryCode: { $in: countryValues } },
];
if (exchangeCodes.length > 0) {
clauses.push({ Exchange: { $in: exchangeCodes } });
clauses.push({ exchange: { $in: exchangeCodes } });
@ -882,16 +885,18 @@ function buildQmCountryFilter(
return {};
}
const countryValues = expandCountryFilterValues(countries);
const exchangeCodes =
typeof exchangeLookup.getCodesForCountries === 'function'
? exchangeLookup.getCodesForCountries('qm', countries)
: [];
const clauses: Record<string, unknown>[] = [];
if (countryValues.length > 0) {
clauses.push({ countryCode: { $in: countryValues } });
clauses.push({ country: { $in: countryValues } });
if (countryValues.length === 0) {
return { ...EMPTY_MATCH_FILTER };
}
if (typeof exchangeLookup.getCodesForCountries !== 'function') {
return {};
}
const exchangeCodes = exchangeLookup.getCodesForCountries('qm', countries);
const clauses: Record<string, unknown>[] = [
{ countryCode: { $in: countryValues } },
{ country: { $in: countryValues } },
];
if (exchangeCodes.length > 0) {
clauses.push({ exchange: { $in: exchangeCodes } });
clauses.push({ exchangeCode: { $in: exchangeCodes } });
@ -907,18 +912,18 @@ function buildCeoCountryFilter(
return {};
}
const countryValues = expandCountryFilterValues(countries);
const exchangeCodes =
typeof exchangeLookup.getCodesForCountries === 'function'
? exchangeLookup.getCodesForCountries('ceo', countries)
: countries.includes('CA')
? [...DEFAULT_CEO_CA_CODES]
: [];
const clauses: Record<string, unknown>[] = [];
if (countryValues.length > 0) {
clauses.push({ countryCode: { $in: countryValues } });
clauses.push({ country: { $in: countryValues } });
if (countryValues.length === 0) {
return { ...EMPTY_MATCH_FILTER };
}
if (typeof exchangeLookup.getCodesForCountries !== 'function') {
return {};
}
const exchangeCodes = exchangeLookup.getCodesForCountries('ceo', countries);
const clauses: Record<string, unknown>[] = [
{ countryCode: { $in: countryValues } },
{ country: { $in: countryValues } },
];
if (exchangeCodes.length > 0) {
clauses.push({ exchange: { $in: exchangeCodes } });
clauses.push({ exchangeCode: { $in: exchangeCodes } });
@ -934,16 +939,18 @@ function buildEodSymbolChangeFilter(
return {};
}
const countryValues = expandCountryFilterValues(countries);
const exchangeCodes =
typeof exchangeLookup.getCodesForCountries === 'function'
? exchangeLookup.getCodesForCountries('eod', countries)
: [];
const clauses: Record<string, unknown>[] = [];
if (countryValues.length > 0) {
clauses.push({ country: { $in: countryValues } });
clauses.push({ Country: { $in: countryValues } });
if (countryValues.length === 0) {
return { ...EMPTY_MATCH_FILTER };
}
if (typeof exchangeLookup.getCodesForCountries !== 'function') {
return {};
}
const exchangeCodes = exchangeLookup.getCodesForCountries('eod', countries);
const clauses: Record<string, unknown>[] = [
{ country: { $in: countryValues } },
{ Country: { $in: countryValues } },
];
if (exchangeCodes.length > 0) {
clauses.push({ exchange: { $in: exchangeCodes } });
}