|
|
@ -19,35 +19,35 @@ export class AccountClusterRiskInitialInvestment extends Rule<Settings> {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
public evaluate(ruleSettings?: Settings) {
|
|
|
|
public evaluate(ruleSettings?: Settings) {
|
|
|
|
const platforms: {
|
|
|
|
const accounts: {
|
|
|
|
[symbol: string]: Pick<PortfolioPosition, 'name'> & {
|
|
|
|
[symbol: string]: Pick<PortfolioPosition, 'name'> & {
|
|
|
|
investment: number;
|
|
|
|
investment: number;
|
|
|
|
};
|
|
|
|
};
|
|
|
|
} = {};
|
|
|
|
} = {};
|
|
|
|
|
|
|
|
|
|
|
|
for (const account of Object.keys(this.accounts)) {
|
|
|
|
for (const [accountId, account] of Object.entries(this.accounts)) {
|
|
|
|
platforms[account] = {
|
|
|
|
accounts[accountId] = {
|
|
|
|
name: account,
|
|
|
|
name: account.name,
|
|
|
|
investment: this.accounts[account].original
|
|
|
|
investment: account.original
|
|
|
|
};
|
|
|
|
};
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
let maxItem;
|
|
|
|
let maxItem;
|
|
|
|
let totalInvestment = 0;
|
|
|
|
let totalInvestment = 0;
|
|
|
|
|
|
|
|
|
|
|
|
Object.values(platforms).forEach((platform) => {
|
|
|
|
for (const account of Object.values(accounts)) {
|
|
|
|
if (!maxItem) {
|
|
|
|
if (!maxItem) {
|
|
|
|
maxItem = platform;
|
|
|
|
maxItem = account;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
// Calculate total investment
|
|
|
|
// Calculate total investment
|
|
|
|
totalInvestment += platform.investment;
|
|
|
|
totalInvestment += account.investment;
|
|
|
|
|
|
|
|
|
|
|
|
// Find maximum
|
|
|
|
// Find maximum
|
|
|
|
if (platform.investment > maxItem?.investment) {
|
|
|
|
if (account.investment > maxItem?.investment) {
|
|
|
|
maxItem = platform;
|
|
|
|
maxItem = account;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
const maxInvestmentRatio = maxItem.investment / totalInvestment;
|
|
|
|
const maxInvestmentRatio = maxItem.investment / totalInvestment;
|
|
|
|
|
|
|
|
|
|
|
|