|
|
@ -910,12 +910,14 @@ export class PortfolioService {
|
|
|
|
const positions = currentPositions.positions.filter(
|
|
|
|
const positions = currentPositions.positions.filter(
|
|
|
|
(item) => !item.quantity.eq(0)
|
|
|
|
(item) => !item.quantity.eq(0)
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const dataGatheringItem = positions.map((position) => {
|
|
|
|
const dataGatheringItem = positions.map((position) => {
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
dataSource: position.dataSource,
|
|
|
|
dataSource: position.dataSource,
|
|
|
|
symbol: position.symbol
|
|
|
|
symbol: position.symbol
|
|
|
|
};
|
|
|
|
};
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
const symbols = positions.map((position) => position.symbol);
|
|
|
|
const symbols = positions.map((position) => position.symbol);
|
|
|
|
|
|
|
|
|
|
|
|
const [dataProviderResponses, symbolProfiles] = await Promise.all([
|
|
|
|
const [dataProviderResponses, symbolProfiles] = await Promise.all([
|
|
|
@ -1103,16 +1105,23 @@ export class PortfolioService {
|
|
|
|
portfolioStart
|
|
|
|
portfolioStart
|
|
|
|
);
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const positions = currentPositions.positions.filter(
|
|
|
|
|
|
|
|
(item) => !item.quantity.eq(0)
|
|
|
|
|
|
|
|
);
|
|
|
|
|
|
|
|
|
|
|
|
const portfolioItemsNow: { [symbol: string]: TimelinePosition } = {};
|
|
|
|
const portfolioItemsNow: { [symbol: string]: TimelinePosition } = {};
|
|
|
|
for (const position of currentPositions.positions) {
|
|
|
|
|
|
|
|
|
|
|
|
for (const position of positions) {
|
|
|
|
portfolioItemsNow[position.symbol] = position;
|
|
|
|
portfolioItemsNow[position.symbol] = position;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const accounts = await this.getValueOfAccounts({
|
|
|
|
const accounts = await this.getValueOfAccounts({
|
|
|
|
orders,
|
|
|
|
orders,
|
|
|
|
portfolioItemsNow,
|
|
|
|
portfolioItemsNow,
|
|
|
|
userId,
|
|
|
|
userCurrency,
|
|
|
|
userCurrency
|
|
|
|
userId
|
|
|
|
});
|
|
|
|
});
|
|
|
|
|
|
|
|
|
|
|
|
return {
|
|
|
|
return {
|
|
|
|
rules: {
|
|
|
|
rules: {
|
|
|
|
accountClusterRisk: await this.rulesService.evaluate(
|
|
|
|
accountClusterRisk: await this.rulesService.evaluate(
|
|
|
@ -1136,19 +1145,19 @@ export class PortfolioService {
|
|
|
|
[
|
|
|
|
[
|
|
|
|
new CurrencyClusterRiskBaseCurrencyInitialInvestment(
|
|
|
|
new CurrencyClusterRiskBaseCurrencyInitialInvestment(
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
currentPositions
|
|
|
|
positions
|
|
|
|
),
|
|
|
|
),
|
|
|
|
new CurrencyClusterRiskBaseCurrencyCurrentInvestment(
|
|
|
|
new CurrencyClusterRiskBaseCurrencyCurrentInvestment(
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
currentPositions
|
|
|
|
positions
|
|
|
|
),
|
|
|
|
),
|
|
|
|
new CurrencyClusterRiskInitialInvestment(
|
|
|
|
new CurrencyClusterRiskInitialInvestment(
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
currentPositions
|
|
|
|
positions
|
|
|
|
),
|
|
|
|
),
|
|
|
|
new CurrencyClusterRiskCurrentInvestment(
|
|
|
|
new CurrencyClusterRiskCurrentInvestment(
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
this.exchangeRateDataService,
|
|
|
|
currentPositions
|
|
|
|
positions
|
|
|
|
)
|
|
|
|
)
|
|
|
|
],
|
|
|
|
],
|
|
|
|
<UserSettings>this.request.user.Settings.settings
|
|
|
|
<UserSettings>this.request.user.Settings.settings
|
|
|
@ -1682,7 +1691,7 @@ export class PortfolioService {
|
|
|
|
for (const order of ordersByAccount) {
|
|
|
|
for (const order of ordersByAccount) {
|
|
|
|
let currentValueOfSymbolInBaseCurrency =
|
|
|
|
let currentValueOfSymbolInBaseCurrency =
|
|
|
|
order.quantity *
|
|
|
|
order.quantity *
|
|
|
|
portfolioItemsNow[order.SymbolProfile.symbol].marketPrice;
|
|
|
|
portfolioItemsNow[order.SymbolProfile.symbol]?.marketPrice ?? 0;
|
|
|
|
let originalValueOfSymbolInBaseCurrency =
|
|
|
|
let originalValueOfSymbolInBaseCurrency =
|
|
|
|
this.exchangeRateDataService.toCurrency(
|
|
|
|
this.exchangeRateDataService.toCurrency(
|
|
|
|
order.quantity * order.unitPrice,
|
|
|
|
order.quantity * order.unitPrice,
|
|
|
|