From f69c7b034bdeb5a03aed503eee3bae4edb901e82 Mon Sep 17 00:00:00 2001 From: Boki Date: Wed, 18 Jun 2025 11:32:40 -0400 Subject: [PATCH] removed unified exchange --- apps/data-sync-service/README.md | 3 +- .../src/services/enhanced-sync-manager.ts | 37 ++----------------- apps/web-api/src/services/exchange.service.ts | 13 ------- 3 files changed, 4 insertions(+), 49 deletions(-) diff --git a/apps/data-sync-service/README.md b/apps/data-sync-service/README.md index 1c12102..4b32672 100644 --- a/apps/data-sync-service/README.md +++ b/apps/data-sync-service/README.md @@ -52,8 +52,7 @@ The Data Sync Service handles synchronization of raw MongoDB data to PostgreSQL ### 1. Multi-Provider Exchange Sync Instead of only syncing QM exchanges, the enhanced sync manager: -- Syncs from unified `exchanges` collection first (primary source) -- Enriches with EOD exchanges (comprehensive global data with currencies) +- Syncs from EOD exchanges (comprehensive global data with currencies) - Adds IB exchanges for additional coverage (214 exchanges vs 25 in QM) ### 2. Intelligent Exchange Mapping diff --git a/apps/data-sync-service/src/services/enhanced-sync-manager.ts b/apps/data-sync-service/src/services/enhanced-sync-manager.ts index b7f523c..82fdff6 100644 --- a/apps/data-sync-service/src/services/enhanced-sync-manager.ts +++ b/apps/data-sync-service/src/services/enhanced-sync-manager.ts @@ -162,19 +162,15 @@ export class EnhancedSyncManager { // Start transaction for atomic operations await this.postgresClient.query('BEGIN'); - // 1. Sync from unified exchanges collection (primary source) - const unifiedResult = await this.syncUnifiedExchanges(); - this.mergeResults(result, unifiedResult); - - // 2. Sync from EOD exchanges (comprehensive global data) + // 1. Sync from EOD exchanges (comprehensive global data) const eodResult = await this.syncEODExchanges(); this.mergeResults(result, eodResult); - // 3. Sync from IB exchanges (detailed asset information) + // 2. Sync from IB exchanges (detailed asset information) const ibResult = await this.syncIBExchanges(); this.mergeResults(result, ibResult); - // 4. Update sync status + // 3. Update sync status await this.updateSyncStatus('all', 'exchanges', result.processed); await this.postgresClient.query('COMMIT'); @@ -418,33 +414,6 @@ export class EnhancedSyncManager { logger.info(`Loaded ${this.exchangeCache.size} exchanges into cache`); } - private async syncUnifiedExchanges(): Promise { - const db = this.getMongoDatabase(); - const exchanges = await db.collection('exchanges').find({}).toArray(); - const result: SyncResult = { processed: 0, created: 0, updated: 0, skipped: 0, errors: 0 }; - - for (const exchange of exchanges) { - try { - // Create provider exchange mapping for unified collection - await this.createProviderExchangeMapping( - 'unified', // provider - exchange.sourceCode || exchange.code, - exchange.sourceName || exchange.name, - exchange.sourceRegion, - null, // currency not in unified - 0.9 // high confidence for unified mappings - ); - - result.processed++; - result.created++; // Count as created mapping - } catch (error) { - logger.error('Failed to process unified exchange', { error, exchange }); - result.errors++; - } - } - - return result; - } private async syncEODExchanges(): Promise { const db = this.getMongoDatabase(); diff --git a/apps/web-api/src/services/exchange.service.ts b/apps/web-api/src/services/exchange.service.ts index 020dec8..e58ccf2 100644 --- a/apps/web-api/src/services/exchange.service.ts +++ b/apps/web-api/src/services/exchange.service.ts @@ -355,19 +355,6 @@ export class ExchangeService { break; } - case 'unified': { - const unifiedExchanges = await db.collection('exchanges').find({}).toArray(); - providerExchanges = unifiedExchanges - .filter(exchange => !mappedCodes.has(exchange.sourceCode || exchange.code)) - .map(exchange => ({ - provider_exchange_code: exchange.sourceCode || exchange.code, - provider_exchange_name: exchange.sourceName || exchange.name, - country_code: null, - currency: null, - symbol_count: null, - })); - break; - } default: throw new Error(`Unknown provider: ${provider}`);