Browse Source
Bugfix/fix unresolved account names in reports (#636)
* Fix unresolved account names
* Update changelog
pull/637/head
Thomas Kaul
3 years ago
committed by
GitHub
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
3 changed files with
23 additions and
17 deletions
-
CHANGELOG.md
-
apps/api/src/models/rules/account-cluster-risk/current-investment.ts
-
apps/api/src/models/rules/account-cluster-risk/initial-investment.ts
|
|
@ -5,6 +5,12 @@ All notable changes to this project will be documented in this file. |
|
|
|
The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/), |
|
|
|
and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0.html). |
|
|
|
|
|
|
|
## Unreleased |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
|
|
- Fixed the unresolved account names in the _X-ray_ section |
|
|
|
|
|
|
|
## 1.104.0 - 16.01.2022 |
|
|
|
|
|
|
|
### Fixed |
|
|
|
|
|
@ -25,17 +25,17 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> { |
|
|
|
}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
for (const account of Object.keys(this.accounts)) { |
|
|
|
accounts[account] = { |
|
|
|
name: account, |
|
|
|
investment: this.accounts[account].current |
|
|
|
for (const [accountId, account] of Object.entries(this.accounts)) { |
|
|
|
accounts[accountId] = { |
|
|
|
name: account.name, |
|
|
|
investment: account.current |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
let maxItem; |
|
|
|
let totalInvestment = 0; |
|
|
|
|
|
|
|
Object.values(accounts).forEach((account) => { |
|
|
|
for (const account of Object.values(accounts)) { |
|
|
|
if (!maxItem) { |
|
|
|
maxItem = account; |
|
|
|
} |
|
|
@ -47,7 +47,7 @@ export class AccountClusterRiskCurrentInvestment extends Rule<Settings> { |
|
|
|
if (account.investment > maxItem?.investment) { |
|
|
|
maxItem = account; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
const maxInvestmentRatio = maxItem.investment / totalInvestment; |
|
|
|
|
|
|
|
|
|
@ -19,35 +19,35 @@ export class AccountClusterRiskInitialInvestment extends Rule<Settings> { |
|
|
|
} |
|
|
|
|
|
|
|
public evaluate(ruleSettings?: Settings) { |
|
|
|
const platforms: { |
|
|
|
const accounts: { |
|
|
|
[symbol: string]: Pick<PortfolioPosition, 'name'> & { |
|
|
|
investment: number; |
|
|
|
}; |
|
|
|
} = {}; |
|
|
|
|
|
|
|
for (const account of Object.keys(this.accounts)) { |
|
|
|
platforms[account] = { |
|
|
|
name: account, |
|
|
|
investment: this.accounts[account].original |
|
|
|
for (const [accountId, account] of Object.entries(this.accounts)) { |
|
|
|
accounts[accountId] = { |
|
|
|
name: account.name, |
|
|
|
investment: account.original |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
let maxItem; |
|
|
|
let totalInvestment = 0; |
|
|
|
|
|
|
|
Object.values(platforms).forEach((platform) => { |
|
|
|
for (const account of Object.values(accounts)) { |
|
|
|
if (!maxItem) { |
|
|
|
maxItem = platform; |
|
|
|
maxItem = account; |
|
|
|
} |
|
|
|
|
|
|
|
// Calculate total investment
|
|
|
|
totalInvestment += platform.investment; |
|
|
|
totalInvestment += account.investment; |
|
|
|
|
|
|
|
// Find maximum
|
|
|
|
if (platform.investment > maxItem?.investment) { |
|
|
|
maxItem = platform; |
|
|
|
if (account.investment > maxItem?.investment) { |
|
|
|
maxItem = account; |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
const maxInvestmentRatio = maxItem.investment / totalInvestment; |
|
|
|
|
|
|
|