|
@ -236,7 +236,15 @@ export class ImportService { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
if (!isDryRun && assetProfilesWithMarketDataDto?.length) { |
|
|
if (!isDryRun && assetProfilesWithMarketDataDto) { |
|
|
|
|
|
// Filter out not custom asset profiles
|
|
|
|
|
|
assetProfilesWithMarketDataDto = assetProfilesWithMarketDataDto.filter( |
|
|
|
|
|
(assetProfile) => { |
|
|
|
|
|
return assetProfile.dataSource === DataSource.MANUAL; |
|
|
|
|
|
} |
|
|
|
|
|
); |
|
|
|
|
|
|
|
|
|
|
|
if (assetProfilesWithMarketDataDto.length) { |
|
|
const existingAssetProfiles = |
|
|
const existingAssetProfiles = |
|
|
await this.symbolProfileService.getSymbolProfiles( |
|
|
await this.symbolProfileService.getSymbolProfiles( |
|
|
assetProfilesWithMarketDataDto.map(({ dataSource, symbol }) => { |
|
|
assetProfilesWithMarketDataDto.map(({ dataSource, symbol }) => { |
|
@ -251,13 +259,17 @@ export class ImportService { |
|
|
return ( |
|
|
return ( |
|
|
existingAssetProfile.dataSource === |
|
|
existingAssetProfile.dataSource === |
|
|
assetProfileWithMarketData.dataSource && |
|
|
assetProfileWithMarketData.dataSource && |
|
|
existingAssetProfile.symbol === assetProfileWithMarketData.symbol |
|
|
existingAssetProfile.symbol === |
|
|
|
|
|
assetProfileWithMarketData.symbol |
|
|
); |
|
|
); |
|
|
} |
|
|
} |
|
|
); |
|
|
); |
|
|
|
|
|
|
|
|
// If there is no asset profile or if the asset profile belongs to a different user then create a new asset profile
|
|
|
// If there is no asset profile or if the asset profile belongs to a different user then create a new asset profile
|
|
|
if (!existingAssetProfile || existingAssetProfile.userId !== user.id) { |
|
|
if ( |
|
|
|
|
|
!existingAssetProfile || |
|
|
|
|
|
existingAssetProfile.userId !== user.id |
|
|
|
|
|
) { |
|
|
const assetProfile: CreateAssetProfileDto = omit( |
|
|
const assetProfile: CreateAssetProfileDto = omit( |
|
|
assetProfileWithMarketData, |
|
|
assetProfileWithMarketData, |
|
|
'marketData' |
|
|
'marketData' |
|
@ -293,6 +305,7 @@ export class ImportService { |
|
|
await this.marketDataService.updateMany({ data: marketDataObjects }); |
|
|
await this.marketDataService.updateMany({ data: marketDataObjects }); |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
for (const activity of activitiesDto) { |
|
|
for (const activity of activitiesDto) { |
|
|
if (!activity.dataSource) { |
|
|
if (!activity.dataSource) { |
|
|