|
|
|
@ -125,58 +125,15 @@ describe('PortfolioCalculator', () => { |
|
|
|
const portfolioCalculator = portfolioCalculatorFactory.createCalculator({ |
|
|
|
activities, |
|
|
|
calculationType: PerformanceCalculationType.ROAI, |
|
|
|
currency: 'CHF', |
|
|
|
currency: 'EUR', |
|
|
|
userId: userDummyData.id |
|
|
|
}); |
|
|
|
|
|
|
|
const portfolioSnapshot = await portfolioCalculator.computeSnapshot(); |
|
|
|
|
|
|
|
expect(portfolioSnapshot).toMatchObject({ |
|
|
|
currentValueInBaseCurrency: new Big('43099.7'), |
|
|
|
errors: [], |
|
|
|
hasErrors: false, |
|
|
|
positions: [ |
|
|
|
{ |
|
|
|
averagePrice: new Big('44558.42'), |
|
|
|
currency: 'USD', |
|
|
|
dataSource: 'YAHOO', |
|
|
|
dividend: new Big('0'), |
|
|
|
dividendInBaseCurrency: new Big('0'), |
|
|
|
expect(portfolioSnapshot.positions[0]).toMatchObject({ |
|
|
|
fee: new Big('4.46'), |
|
|
|
feeInBaseCurrency: new Big('3.94'), |
|
|
|
firstBuyDate: '2021-12-12', |
|
|
|
grossPerformance: new Big('-1458.72'), |
|
|
|
grossPerformancePercentage: new Big('-0.03273724696701543726'), |
|
|
|
grossPerformancePercentageWithCurrencyEffect: new Big( |
|
|
|
'-0.03273724696701543726' |
|
|
|
), |
|
|
|
grossPerformanceWithCurrencyEffect: new Big('-1458.72'), |
|
|
|
investment: new Big('44558.42'), |
|
|
|
investmentWithCurrencyEffect: new Big('44558.42'), |
|
|
|
netPerformance: new Big('-1463.18'), |
|
|
|
netPerformancePercentage: new Big('-0.03283734028271199921'), |
|
|
|
netPerformancePercentageWithCurrencyEffectMap: { |
|
|
|
max: new Big('-0.03283734028271199921') |
|
|
|
}, |
|
|
|
netPerformanceWithCurrencyEffectMap: { |
|
|
|
max: new Big('-1463.18') |
|
|
|
}, |
|
|
|
marketPrice: 43099.7, |
|
|
|
marketPriceInBaseCurrency: 43099.7, |
|
|
|
quantity: new Big('1'), |
|
|
|
symbol: 'BTCUSD', |
|
|
|
tags: [], |
|
|
|
timeWeightedInvestment: new Big('44558.42'), |
|
|
|
timeWeightedInvestmentWithCurrencyEffect: new Big('44558.42'), |
|
|
|
transactionCount: 1, |
|
|
|
valueInBaseCurrency: new Big('43099.7') |
|
|
|
} |
|
|
|
], |
|
|
|
totalFeesWithCurrencyEffect: new Big('4.46'), |
|
|
|
totalInterestWithCurrencyEffect: new Big('0'), |
|
|
|
totalInvestment: new Big('44558.42'), |
|
|
|
totalInvestmentWithCurrencyEffect: new Big('44558.42'), |
|
|
|
totalLiabilitiesWithCurrencyEffect: new Big('0') |
|
|
|
feeInBaseCurrency: new Big('3.94') |
|
|
|
}); |
|
|
|
}); |
|
|
|
}); |
|
|
|
|