|
|
@ -1,6 +1,7 @@ |
|
|
import { |
|
|
import { |
|
|
activityDummyData, |
|
|
activityDummyData, |
|
|
assetProfileDummyData, |
|
|
assetProfileDummyData, |
|
|
|
|
|
getPerformanceByDateRange, |
|
|
userDummyData |
|
|
userDummyData |
|
|
} from '@ghostfolio/api/app/portfolio/calculator/portfolio-calculator-test-utils'; |
|
|
} from '@ghostfolio/api/app/portfolio/calculator/portfolio-calculator-test-utils'; |
|
|
import { PortfolioCalculatorFactory } from '@ghostfolio/api/app/portfolio/calculator/portfolio-calculator.factory'; |
|
|
import { PortfolioCalculatorFactory } from '@ghostfolio/api/app/portfolio/calculator/portfolio-calculator.factory'; |
|
|
@ -136,11 +137,17 @@ describe('PortfolioCalculator', () => { |
|
|
activities, |
|
|
activities, |
|
|
calculationType: PerformanceCalculationType.ROAI, |
|
|
calculationType: PerformanceCalculationType.ROAI, |
|
|
currency: 'CHF', |
|
|
currency: 'CHF', |
|
|
|
|
|
usePortfolioSnapshotCache: false, |
|
|
userId: userDummyData.id |
|
|
userId: userDummyData.id |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
const portfolioSnapshot = await portfolioCalculator.computeSnapshot(); |
|
|
const portfolioSnapshot = await portfolioCalculator.computeSnapshot(); |
|
|
|
|
|
|
|
|
|
|
|
const performanceByDateRange = await getPerformanceByDateRange({ |
|
|
|
|
|
portfolioCalculator, |
|
|
|
|
|
dateRanges: ['1d', 'max', 'ytd'] |
|
|
|
|
|
}); |
|
|
|
|
|
|
|
|
const investments = portfolioCalculator.getInvestments(); |
|
|
const investments = portfolioCalculator.getInvestments(); |
|
|
|
|
|
|
|
|
const investmentsByMonth = portfolioCalculator.getInvestmentsByGroup({ |
|
|
const investmentsByMonth = portfolioCalculator.getInvestmentsByGroup({ |
|
|
@ -269,6 +276,36 @@ describe('PortfolioCalculator', () => { |
|
|
{ date: '2017-01-01', investment: -318.54266729999995 }, |
|
|
{ date: '2017-01-01', investment: -318.54266729999995 }, |
|
|
{ date: '2018-01-01', investment: 0 } |
|
|
{ date: '2018-01-01', investment: 0 } |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
|
|
|
expect(performanceByDateRange).toMatchObject({ |
|
|
|
|
|
'1d': { |
|
|
|
|
|
date: '2018-01-01', |
|
|
|
|
|
netPerformance: -486.0860160000011, |
|
|
|
|
|
netPerformanceInPercentage: -1.5259683109961866, |
|
|
|
|
|
netPerformanceInPercentageWithCurrencyEffect: -1.7468407881319952, |
|
|
|
|
|
netPerformanceWithCurrencyEffect: -556.4433239999998, |
|
|
|
|
|
totalInvestmentValueWithCurrencyEffect: 318.54266729999995, |
|
|
|
|
|
valueWithCurrencyEffect: 13298.425356 |
|
|
|
|
|
}, |
|
|
|
|
|
max: { |
|
|
|
|
|
date: '2018-01-01', |
|
|
|
|
|
netPerformance: 26458.9121202, |
|
|
|
|
|
netPerformanceInPercentage: 41.63298219956282, |
|
|
|
|
|
netPerformanceInPercentageWithCurrencyEffect: 41.72313811883715, |
|
|
|
|
|
netPerformanceWithCurrencyEffect: 26516.2087014, |
|
|
|
|
|
totalInvestmentValueWithCurrencyEffect: 318.54266729999995, |
|
|
|
|
|
valueWithCurrencyEffect: 13298.425356 |
|
|
|
|
|
}, |
|
|
|
|
|
ytd: { |
|
|
|
|
|
date: '2018-01-01', |
|
|
|
|
|
netPerformance: -486.0860160000011, |
|
|
|
|
|
netPerformanceInPercentage: -1.5259683109961866, |
|
|
|
|
|
netPerformanceInPercentageWithCurrencyEffect: -1.7468407881319952, |
|
|
|
|
|
netPerformanceWithCurrencyEffect: -556.4433239999998, |
|
|
|
|
|
totalInvestmentValueWithCurrencyEffect: 318.54266729999995, |
|
|
|
|
|
valueWithCurrencyEffect: 13298.425356 |
|
|
|
|
|
} |
|
|
|
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
}); |
|
|
|