|
|
@ -184,25 +184,19 @@ export class DataGatheringService { |
|
|
|
|
|
|
|
|
const symbolMapping = symbolProfile?.symbolMapping; |
|
|
const symbolMapping = symbolProfile?.symbolMapping; |
|
|
|
|
|
|
|
|
// Persist the data provider’s classification in the base asset profile;
|
|
|
let enhancedAssetProfile = symbolProfile |
|
|
// the asset profile override stays a separate layer applied at read time
|
|
|
? { |
|
|
const { |
|
|
...assetProfile, |
|
|
assetClass: assetClassFromDataProvider, |
|
|
assetClass: symbolProfile.assetClass ?? assetProfile.assetClass, |
|
|
assetSubClass: assetSubClassFromDataProvider |
|
|
assetSubClass: |
|
|
} = assetProfile; |
|
|
symbolProfile.assetSubClass ?? assetProfile.assetSubClass |
|
|
|
|
|
} |
|
|
// Apply the asset profile override so the data enhancers treat the asset
|
|
|
: assetProfile; |
|
|
// profile correctly (e.g. enrich an ETF that the data provider classifies
|
|
|
|
|
|
// as a stock)
|
|
|
|
|
|
if (symbolProfile) { |
|
|
|
|
|
assetProfile.assetClass = symbolProfile.assetClass; |
|
|
|
|
|
assetProfile.assetSubClass = symbolProfile.assetSubClass; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
for (const dataEnhancer of this.dataEnhancers) { |
|
|
for (const dataEnhancer of this.dataEnhancers) { |
|
|
try { |
|
|
try { |
|
|
assetProfiles[symbol] = await dataEnhancer.enhance({ |
|
|
enhancedAssetProfile = await dataEnhancer.enhance({ |
|
|
response: assetProfile, |
|
|
response: enhancedAssetProfile, |
|
|
symbol: symbolMapping?.[dataEnhancer.getName()] ?? symbol |
|
|
symbol: symbolMapping?.[dataEnhancer.getName()] ?? symbol |
|
|
}); |
|
|
}); |
|
|
} catch (error) { |
|
|
} catch (error) { |
|
|
@ -216,13 +210,11 @@ export class DataGatheringService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
// Restore the data provider’s classification before persisting
|
|
|
assetProfiles[symbol] = enhancedAssetProfile; |
|
|
assetProfile.assetClass = assetClassFromDataProvider; |
|
|
|
|
|
assetProfile.assetSubClass = assetSubClassFromDataProvider; |
|
|
const { assetClass, assetSubClass } = assetProfile; |
|
|
|
|
|
|
|
|
const { |
|
|
const { |
|
|
assetClass, |
|
|
|
|
|
assetSubClass, |
|
|
|
|
|
countries, |
|
|
countries, |
|
|
currency, |
|
|
currency, |
|
|
cusip, |
|
|
cusip, |
|
|
@ -235,7 +227,7 @@ export class DataGatheringService { |
|
|
name, |
|
|
name, |
|
|
sectors, |
|
|
sectors, |
|
|
url |
|
|
url |
|
|
} = assetProfile; |
|
|
} = enhancedAssetProfile; |
|
|
|
|
|
|
|
|
try { |
|
|
try { |
|
|
await this.prismaService.symbolProfile.upsert({ |
|
|
await this.prismaService.symbolProfile.upsert({ |
|
|
|