refactor(data): normalize provider symbols and remove dead scaffolding (CL34)

This commit is contained in:
Boki 2026-10-28 13:56:31 -04:00
parent 5c9e32d0ef
commit e2292e4883
11 changed files with 287 additions and 581 deletions

View file

@ -0,0 +1,50 @@
/** Fields retained by the QM, EOD and IB symbol collections, including older spellings. */
export interface ProviderSymbolDocument {
symbol?: string | null;
code?: string | null;
Code?: string | null;
exchangeCode?: string | null;
exchange?: string | null;
exchange_id?: string | null;
Exchange?: string | null;
companyName?: string | null;
name?: string | null;
company_name?: string | null;
Name?: string | null;
countryCode?: string | null;
country_code?: string | null;
Country?: string | null;
currency?: string | null;
Currency?: string | null;
qmSearchCode?: string | null;
eodSearchCode?: string | null;
}
/** Provider codes stay exact: exchange resolution and curated mappings belong to SQL. */
export interface ProviderSymbol {
symbol: string;
exchangeCode: string;
providerSymbol: string;
companyName: string | null;
country: string | null;
currency: string | null;
}
/** Preserve the existing field precedence without guessing suffixes or exchange aliases. */
export function normalizeProviderSymbol(document: ProviderSymbolDocument): ProviderSymbol | null {
const symbol = document.symbol || document.code || document.Code;
const exchangeCode =
document.exchangeCode || document.exchange || document.exchange_id || document.Exchange;
if (!symbol || !exchangeCode) {
return null;
}
return {
symbol,
exchangeCode,
providerSymbol: document.qmSearchCode || document.eodSearchCode || symbol,
companyName:
document.companyName || document.name || document.company_name || document.Name || null,
country: document.countryCode || document.country_code || document.Country || null,
currency: document.currency || document.Currency || null,
};
}