|
|
@ -50,6 +50,7 @@ import { |
|
|
PortfolioPerformanceResponse, |
|
|
PortfolioPerformanceResponse, |
|
|
PortfolioPosition, |
|
|
PortfolioPosition, |
|
|
PortfolioReportResponse, |
|
|
PortfolioReportResponse, |
|
|
|
|
|
PortfolioReportRule, |
|
|
PortfolioSummary, |
|
|
PortfolioSummary, |
|
|
UserSettings |
|
|
UserSettings |
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
} from '@ghostfolio/common/interfaces'; |
|
|
@ -1231,8 +1232,11 @@ export class PortfolioService { |
|
|
}) |
|
|
}) |
|
|
).toNumber(); |
|
|
).toNumber(); |
|
|
|
|
|
|
|
|
const rules: PortfolioReportResponse['xRay']['rules'] = { |
|
|
const categories: PortfolioReportResponse['xRay']['categories'] = [ |
|
|
accountClusterRisk: |
|
|
{ |
|
|
|
|
|
key: 'accountClusterRisk', |
|
|
|
|
|
name: 'accountClusterRisk', |
|
|
|
|
|
rules: |
|
|
summary.activityCount > 0 |
|
|
summary.activityCount > 0 |
|
|
? await this.rulesService.evaluate( |
|
|
? await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
@ -1251,8 +1255,12 @@ export class PortfolioService { |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
) |
|
|
) |
|
|
: undefined, |
|
|
: undefined |
|
|
assetClassClusterRisk: |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'assetClassClusterRisk', |
|
|
|
|
|
name: 'assetClassClusterRisk', |
|
|
|
|
|
rules: |
|
|
summary.activityCount > 0 |
|
|
summary.activityCount > 0 |
|
|
? await this.rulesService.evaluate( |
|
|
? await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
@ -1271,8 +1279,12 @@ export class PortfolioService { |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
) |
|
|
) |
|
|
: undefined, |
|
|
: undefined |
|
|
currencyClusterRisk: |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'currencyClusterRisk', |
|
|
|
|
|
name: 'currencyClusterRisk', |
|
|
|
|
|
rules: |
|
|
summary.activityCount > 0 |
|
|
summary.activityCount > 0 |
|
|
? await this.rulesService.evaluate( |
|
|
? await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
@ -1291,8 +1303,12 @@ export class PortfolioService { |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
) |
|
|
) |
|
|
: undefined, |
|
|
: undefined |
|
|
economicMarketClusterRisk: |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'economicMarketClusterRisk', |
|
|
|
|
|
name: 'economicMarketClusterRisk', |
|
|
|
|
|
rules: |
|
|
summary.activityCount > 0 |
|
|
summary.activityCount > 0 |
|
|
? await this.rulesService.evaluate( |
|
|
? await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
@ -1313,8 +1329,12 @@ export class PortfolioService { |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
) |
|
|
) |
|
|
: undefined, |
|
|
: undefined |
|
|
emergencyFund: await this.rulesService.evaluate( |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'emergencyFund', |
|
|
|
|
|
name: 'emergencyFund', |
|
|
|
|
|
rules: await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
new EmergencyFundSetup( |
|
|
new EmergencyFundSetup( |
|
|
this.exchangeRateDataService, |
|
|
this.exchangeRateDataService, |
|
|
@ -1328,8 +1348,12 @@ export class PortfolioService { |
|
|
) |
|
|
) |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
), |
|
|
) |
|
|
fees: await this.rulesService.evaluate( |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'fees', |
|
|
|
|
|
name: 'fees', |
|
|
|
|
|
rules: await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
new FeeRatioInitialInvestment( |
|
|
new FeeRatioInitialInvestment( |
|
|
this.exchangeRateDataService, |
|
|
this.exchangeRateDataService, |
|
|
@ -1340,8 +1364,12 @@ export class PortfolioService { |
|
|
) |
|
|
) |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
), |
|
|
) |
|
|
liquidity: await this.rulesService.evaluate( |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'liquidity', |
|
|
|
|
|
name: 'liquidity', |
|
|
|
|
|
rules: await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
new BuyingPower( |
|
|
new BuyingPower( |
|
|
this.exchangeRateDataService, |
|
|
this.exchangeRateDataService, |
|
|
@ -1351,8 +1379,12 @@ export class PortfolioService { |
|
|
) |
|
|
) |
|
|
], |
|
|
], |
|
|
userSettings |
|
|
userSettings |
|
|
), |
|
|
) |
|
|
regionalMarketClusterRisk: |
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
key: 'regionalMarketClusterRisk', |
|
|
|
|
|
name: 'regionalMarketClusterRisk', |
|
|
|
|
|
rules: |
|
|
summary.activityCount > 0 |
|
|
summary.activityCount > 0 |
|
|
? await this.rulesService.evaluate( |
|
|
? await this.rulesService.evaluate( |
|
|
[ |
|
|
[ |
|
|
@ -1395,12 +1427,15 @@ export class PortfolioService { |
|
|
userSettings |
|
|
userSettings |
|
|
) |
|
|
) |
|
|
: undefined |
|
|
: undefined |
|
|
}; |
|
|
} |
|
|
|
|
|
]; |
|
|
|
|
|
|
|
|
return { |
|
|
return { |
|
|
xRay: { |
|
|
xRay: { |
|
|
rules, |
|
|
categories, |
|
|
statistics: this.getReportStatistics(rules) |
|
|
statistics: this.getReportStatistics( |
|
|
|
|
|
categories.flatMap(({ rules }) => rules ?? []) |
|
|
|
|
|
) |
|
|
} |
|
|
} |
|
|
}; |
|
|
}; |
|
|
} |
|
|
} |
|
|
@ -1822,7 +1857,7 @@ export class PortfolioService { |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
private getReportStatistics( |
|
|
private getReportStatistics( |
|
|
evaluatedRules: PortfolioReportResponse['xRay']['rules'] |
|
|
evaluatedRules: PortfolioReportRule[] |
|
|
): PortfolioReportResponse['xRay']['statistics'] { |
|
|
): PortfolioReportResponse['xRay']['statistics'] { |
|
|
const rulesActiveCount = Object.values(evaluatedRules) |
|
|
const rulesActiveCount = Object.values(evaluatedRules) |
|
|
.flat() |
|
|
.flat() |
|
|
|