Bugfix/fix fees calculation in portfolio summary (#3567)
* Fix fees calculation * Update changelog
This commit is contained in:
parent
0640b24290
commit
9d6214e93a
@ -12,6 +12,10 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
|||||||
- Improved the chart of the holdings tab on the home page (experimental)
|
- Improved the chart of the holdings tab on the home page (experimental)
|
||||||
- Separated the icon purposes in the `site.webmanifest`
|
- Separated the icon purposes in the `site.webmanifest`
|
||||||
|
|
||||||
|
### Fixed
|
||||||
|
|
||||||
|
- Fixed an issue in the portfolio summary with the currency conversion of fees
|
||||||
|
|
||||||
## 2.95.0 - 2024-07-12
|
## 2.95.0 - 2024-07-12
|
||||||
|
|
||||||
### Added
|
### Added
|
||||||
|
@ -300,6 +300,12 @@ export abstract class PortfolioCalculator {
|
|||||||
const errors: ResponseError['errors'] = [];
|
const errors: ResponseError['errors'] = [];
|
||||||
|
|
||||||
for (const item of lastTransactionPoint.items) {
|
for (const item of lastTransactionPoint.items) {
|
||||||
|
const feeInBaseCurrency = item.fee.mul(
|
||||||
|
exchangeRatesByCurrency[`${item.currency}${this.currency}`]?.[
|
||||||
|
lastTransactionPoint.date
|
||||||
|
]
|
||||||
|
);
|
||||||
|
|
||||||
const marketPriceInBaseCurrency = (
|
const marketPriceInBaseCurrency = (
|
||||||
marketSymbolMap[endDateString]?.[item.symbol] ?? item.averagePrice
|
marketSymbolMap[endDateString]?.[item.symbol] ?? item.averagePrice
|
||||||
).mul(
|
).mul(
|
||||||
@ -340,10 +346,11 @@ export abstract class PortfolioCalculator {
|
|||||||
hasAnySymbolMetricsErrors = hasAnySymbolMetricsErrors || hasErrors;
|
hasAnySymbolMetricsErrors = hasAnySymbolMetricsErrors || hasErrors;
|
||||||
|
|
||||||
positions.push({
|
positions.push({
|
||||||
dividend: totalDividend,
|
feeInBaseCurrency,
|
||||||
dividendInBaseCurrency: totalDividendInBaseCurrency,
|
|
||||||
timeWeightedInvestment,
|
timeWeightedInvestment,
|
||||||
timeWeightedInvestmentWithCurrencyEffect,
|
timeWeightedInvestmentWithCurrencyEffect,
|
||||||
|
dividend: totalDividend,
|
||||||
|
dividendInBaseCurrency: totalDividendInBaseCurrency,
|
||||||
averagePrice: item.averagePrice,
|
averagePrice: item.averagePrice,
|
||||||
currency: item.currency,
|
currency: item.currency,
|
||||||
dataSource: item.dataSource,
|
dataSource: item.dataSource,
|
||||||
|
@ -168,6 +168,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('3.2'),
|
fee: new Big('3.2'),
|
||||||
|
feeInBaseCurrency: new Big('3.2'),
|
||||||
firstBuyDate: '2021-11-22',
|
firstBuyDate: '2021-11-22',
|
||||||
grossPerformance: new Big('-12.6'),
|
grossPerformance: new Big('-12.6'),
|
||||||
grossPerformancePercentage: new Big('-0.04408677396780965649'),
|
grossPerformancePercentage: new Big('-0.04408677396780965649'),
|
||||||
|
@ -153,6 +153,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('3.2'),
|
fee: new Big('3.2'),
|
||||||
|
feeInBaseCurrency: new Big('3.2'),
|
||||||
firstBuyDate: '2021-11-22',
|
firstBuyDate: '2021-11-22',
|
||||||
grossPerformance: new Big('-12.6'),
|
grossPerformance: new Big('-12.6'),
|
||||||
grossPerformancePercentage: new Big('-0.0440867739678096571'),
|
grossPerformancePercentage: new Big('-0.0440867739678096571'),
|
||||||
|
@ -138,6 +138,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('1.55'),
|
fee: new Big('1.55'),
|
||||||
|
feeInBaseCurrency: new Big('1.55'),
|
||||||
firstBuyDate: '2021-11-30',
|
firstBuyDate: '2021-11-30',
|
||||||
grossPerformance: new Big('24.6'),
|
grossPerformance: new Big('24.6'),
|
||||||
grossPerformancePercentage: new Big('0.09004392386530014641'),
|
grossPerformancePercentage: new Big('0.09004392386530014641'),
|
||||||
|
@ -166,6 +166,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('0'),
|
fee: new Big('0'),
|
||||||
|
feeInBaseCurrency: new Big('0'),
|
||||||
firstBuyDate: '2015-01-01',
|
firstBuyDate: '2015-01-01',
|
||||||
grossPerformance: new Big('27172.74'),
|
grossPerformance: new Big('27172.74'),
|
||||||
grossPerformancePercentage: new Big('42.41978276196153750666'),
|
grossPerformancePercentage: new Big('42.41978276196153750666'),
|
||||||
|
@ -123,6 +123,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('49'),
|
fee: new Big('49'),
|
||||||
|
feeInBaseCurrency: new Big('49'),
|
||||||
firstBuyDate: '2021-09-01',
|
firstBuyDate: '2021-09-01',
|
||||||
grossPerformance: null,
|
grossPerformance: null,
|
||||||
grossPerformancePercentage: null,
|
grossPerformancePercentage: null,
|
||||||
|
@ -151,6 +151,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('1'),
|
fee: new Big('1'),
|
||||||
|
feeInBaseCurrency: new Big('0.9238'),
|
||||||
firstBuyDate: '2023-01-03',
|
firstBuyDate: '2023-01-03',
|
||||||
grossPerformance: new Big('27.33'),
|
grossPerformance: new Big('27.33'),
|
||||||
grossPerformancePercentage: new Big('0.3066651705565529623'),
|
grossPerformancePercentage: new Big('0.3066651705565529623'),
|
||||||
@ -177,7 +178,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
valueInBaseCurrency: new Big('103.10483')
|
valueInBaseCurrency: new Big('103.10483')
|
||||||
}
|
}
|
||||||
],
|
],
|
||||||
totalFeesWithCurrencyEffect: new Big('1'),
|
totalFeesWithCurrencyEffect: new Big('0.9238'),
|
||||||
totalInterestWithCurrencyEffect: new Big('0'),
|
totalInterestWithCurrencyEffect: new Big('0'),
|
||||||
totalInvestment: new Big('89.12'),
|
totalInvestment: new Big('89.12'),
|
||||||
totalInvestmentWithCurrencyEffect: new Big('82.329056'),
|
totalInvestmentWithCurrencyEffect: new Big('82.329056'),
|
||||||
|
@ -123,6 +123,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('0'),
|
fee: new Big('0'),
|
||||||
|
feeInBaseCurrency: new Big('0'),
|
||||||
firstBuyDate: '2022-01-01',
|
firstBuyDate: '2022-01-01',
|
||||||
grossPerformance: null,
|
grossPerformance: null,
|
||||||
grossPerformancePercentage: null,
|
grossPerformancePercentage: null,
|
||||||
|
@ -153,6 +153,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('4.25'),
|
fee: new Big('4.25'),
|
||||||
|
feeInBaseCurrency: new Big('4.25'),
|
||||||
firstBuyDate: '2022-03-07',
|
firstBuyDate: '2022-03-07',
|
||||||
grossPerformance: new Big('21.93'),
|
grossPerformance: new Big('21.93'),
|
||||||
grossPerformancePercentage: new Big('0.15113417083448194384'),
|
grossPerformancePercentage: new Big('0.15113417083448194384'),
|
||||||
|
@ -183,6 +183,7 @@ describe('PortfolioCalculator', () => {
|
|||||||
dividend: new Big('0'),
|
dividend: new Big('0'),
|
||||||
dividendInBaseCurrency: new Big('0'),
|
dividendInBaseCurrency: new Big('0'),
|
||||||
fee: new Big('0'),
|
fee: new Big('0'),
|
||||||
|
feeInBaseCurrency: new Big('0'),
|
||||||
firstBuyDate: '2022-03-07',
|
firstBuyDate: '2022-03-07',
|
||||||
grossPerformance: new Big('19.86'),
|
grossPerformance: new Big('19.86'),
|
||||||
grossPerformancePercentage: new Big('0.13100263852242744063'),
|
grossPerformancePercentage: new Big('0.13100263852242744063'),
|
||||||
|
@ -34,9 +34,9 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
|
|||||||
let totalTimeWeightedInvestmentWithCurrencyEffect = new Big(0);
|
let totalTimeWeightedInvestmentWithCurrencyEffect = new Big(0);
|
||||||
|
|
||||||
for (const currentPosition of positions) {
|
for (const currentPosition of positions) {
|
||||||
if (currentPosition.fee) {
|
if (currentPosition.feeInBaseCurrency) {
|
||||||
totalFeesWithCurrencyEffect = totalFeesWithCurrencyEffect.plus(
|
totalFeesWithCurrencyEffect = totalFeesWithCurrencyEffect.plus(
|
||||||
currentPosition.fee
|
currentPosition.feeInBaseCurrency
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -24,6 +24,10 @@ export class TimelinePosition {
|
|||||||
@Type(() => Big)
|
@Type(() => Big)
|
||||||
fee: Big;
|
fee: Big;
|
||||||
|
|
||||||
|
@Transform(transformToBig, { toClassOnly: true })
|
||||||
|
@Type(() => Big)
|
||||||
|
feeInBaseCurrency: Big;
|
||||||
|
|
||||||
firstBuyDate: string;
|
firstBuyDate: string;
|
||||||
|
|
||||||
@Transform(transformToBig, { toClassOnly: true })
|
@Transform(transformToBig, { toClassOnly: true })
|
||||||
|
Loading…
x
Reference in New Issue
Block a user