removed unified exchange

This commit is contained in:
Boki 2025-06-18 11:32:40 -04:00
parent 265e10a658
commit f69c7b034b
3 changed files with 4 additions and 49 deletions

View file

@ -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

View file

@ -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<SyncResult> {
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<SyncResult> {
const db = this.getMongoDatabase();

View file

@ -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}`);