|
@ -113,19 +113,21 @@ describe('PortfolioCalculator', () => { |
|
|
...activityDummyData, |
|
|
...activityDummyData, |
|
|
...activity, |
|
|
...activity, |
|
|
date: parseDate(activity.date), |
|
|
date: parseDate(activity.date), |
|
|
|
|
|
feeInAssetProfileCurrency: 4.46, |
|
|
SymbolProfile: { |
|
|
SymbolProfile: { |
|
|
...symbolProfileDummyData, |
|
|
...symbolProfileDummyData, |
|
|
currency: 'USD', |
|
|
currency: 'USD', |
|
|
dataSource: activity.dataSource, |
|
|
dataSource: activity.dataSource, |
|
|
name: 'Bitcoin', |
|
|
name: 'Bitcoin', |
|
|
symbol: activity.symbol |
|
|
symbol: activity.symbol |
|
|
} |
|
|
}, |
|
|
|
|
|
unitPriceInAssetProfileCurrency: 44558.42 |
|
|
})); |
|
|
})); |
|
|
|
|
|
|
|
|
const portfolioCalculator = portfolioCalculatorFactory.createCalculator({ |
|
|
const portfolioCalculator = portfolioCalculatorFactory.createCalculator({ |
|
|
activities, |
|
|
activities, |
|
|
calculationType: PerformanceCalculationType.ROAI, |
|
|
calculationType: PerformanceCalculationType.ROAI, |
|
|
currency: 'EUR', |
|
|
currency: 'USD', |
|
|
userId: userDummyData.id |
|
|
userId: userDummyData.id |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
@ -155,17 +157,17 @@ describe('PortfolioCalculator', () => { |
|
|
|
|
|
|
|
|
expect(portfolioSnapshot.historicalData[1]).toEqual({ |
|
|
expect(portfolioSnapshot.historicalData[1]).toEqual({ |
|
|
date: '2021-12-12', |
|
|
date: '2021-12-12', |
|
|
investmentValueWithCurrencyEffect: 39380.731596, |
|
|
investmentValueWithCurrencyEffect: 44558.42, |
|
|
netPerformance: -3.892688, |
|
|
netPerformance: -4.46, |
|
|
netPerformanceInPercentage: 0, |
|
|
netPerformanceInPercentage: 0, |
|
|
netPerformanceInPercentageWithCurrencyEffect: 0, |
|
|
netPerformanceInPercentageWithCurrencyEffect: 0, |
|
|
netPerformanceWithCurrencyEffect: -3.941748, |
|
|
netPerformanceWithCurrencyEffect: -4.46, |
|
|
netWorth: 39380.731596, |
|
|
netWorth: 44558.42, |
|
|
totalAccountBalance: 0, |
|
|
totalAccountBalance: 0, |
|
|
totalInvestment: 38890.588976, |
|
|
totalInvestment: 44558.42, |
|
|
totalInvestmentValueWithCurrencyEffect: 39380.731596, |
|
|
totalInvestmentValueWithCurrencyEffect: 44558.42, |
|
|
value: 38890.588976, |
|
|
value: 44558.42, |
|
|
valueWithCurrencyEffect: 39380.731596 |
|
|
valueWithCurrencyEffect: 44558.42 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expect( |
|
|
expect( |
|
@ -175,20 +177,20 @@ describe('PortfolioCalculator', () => { |
|
|
).toEqual({ |
|
|
).toEqual({ |
|
|
date: '2022-01-14', |
|
|
date: '2022-01-14', |
|
|
investmentValueWithCurrencyEffect: 0, |
|
|
investmentValueWithCurrencyEffect: 0, |
|
|
netPerformance: -1277.063504, |
|
|
netPerformance: -1463.18, |
|
|
netPerformanceInPercentage: -0.032837340282712, |
|
|
netPerformanceInPercentage: -0.032837340282712, |
|
|
netPerformanceInPercentageWithCurrencyEffect: -0.044876138974002826, |
|
|
netPerformanceInPercentageWithCurrencyEffect: -0.032837340282712, |
|
|
netPerformanceWithCurrencyEffect: -1767.255184, |
|
|
netPerformanceWithCurrencyEffect: -1463.18, |
|
|
netWorth: 37617.41816, |
|
|
netWorth: 43099.7, |
|
|
totalAccountBalance: 0, |
|
|
totalAccountBalance: 0, |
|
|
totalInvestment: 38890.588976, |
|
|
totalInvestment: 44558.42, |
|
|
totalInvestmentValueWithCurrencyEffect: 39380.731596, |
|
|
totalInvestmentValueWithCurrencyEffect: 44558.42, |
|
|
value: 37617.41816, |
|
|
value: 43099.7, |
|
|
valueWithCurrencyEffect: 37617.41816 |
|
|
valueWithCurrencyEffect: 43099.7 |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
expect(portfolioSnapshot).toMatchObject({ |
|
|
expect(portfolioSnapshot).toMatchObject({ |
|
|
currentValueInBaseCurrency: new Big('37617.41816'), |
|
|
currentValueInBaseCurrency: new Big('43099.7'), |
|
|
errors: [], |
|
|
errors: [], |
|
|
hasErrors: false, |
|
|
hasErrors: false, |
|
|
positions: [ |
|
|
positions: [ |
|
@ -199,39 +201,39 @@ describe('PortfolioCalculator', () => { |
|
|
dividend: new Big('0'), |
|
|
dividend: new Big('0'), |
|
|
dividendInBaseCurrency: new Big('0'), |
|
|
dividendInBaseCurrency: new Big('0'), |
|
|
fee: new Big('4.46'), |
|
|
fee: new Big('4.46'), |
|
|
feeInBaseCurrency: new Big('3.941748'), |
|
|
feeInBaseCurrency: new Big('4.46'), |
|
|
firstBuyDate: '2021-12-12', |
|
|
firstBuyDate: '2021-12-12', |
|
|
grossPerformance: new Big('-1273.170816'), |
|
|
grossPerformance: new Big('-1458.72'), |
|
|
grossPerformancePercentage: new Big('-0.03273724696701543726'), |
|
|
grossPerformancePercentage: new Big('-0.03273724696701543726'), |
|
|
grossPerformancePercentageWithCurrencyEffect: new Big( |
|
|
grossPerformancePercentageWithCurrencyEffect: new Big( |
|
|
'-0.04477604565830626119' |
|
|
'-0.03273724696701543726' |
|
|
), |
|
|
), |
|
|
grossPerformanceWithCurrencyEffect: new Big('-1763.313436'), |
|
|
grossPerformanceWithCurrencyEffect: new Big('-1458.72'), |
|
|
investment: new Big('38890.588976'), |
|
|
investment: new Big('44558.42'), |
|
|
investmentWithCurrencyEffect: new Big('39380.731596'), |
|
|
investmentWithCurrencyEffect: new Big('44558.42'), |
|
|
netPerformance: new Big('-1277.063504'), |
|
|
netPerformance: new Big('-1463.18'), |
|
|
netPerformancePercentage: new Big('-0.03283734028271199921'), |
|
|
netPerformancePercentage: new Big('-0.03283734028271199921'), |
|
|
netPerformancePercentageWithCurrencyEffectMap: { |
|
|
netPerformancePercentageWithCurrencyEffectMap: { |
|
|
max: new Big('-0.04487613897400282314') |
|
|
max: new Big('-0.03283734028271199921') |
|
|
}, |
|
|
}, |
|
|
netPerformanceWithCurrencyEffectMap: { |
|
|
netPerformanceWithCurrencyEffectMap: { |
|
|
max: new Big('-1767.255184') |
|
|
max: new Big('-1463.18') |
|
|
}, |
|
|
}, |
|
|
marketPrice: 43099.7, |
|
|
marketPrice: 43099.7, |
|
|
marketPriceInBaseCurrency: 37617.41816, |
|
|
marketPriceInBaseCurrency: 43099.7, |
|
|
quantity: new Big('1'), |
|
|
quantity: new Big('1'), |
|
|
symbol: 'BTCUSD', |
|
|
symbol: 'BTCUSD', |
|
|
tags: [], |
|
|
tags: [], |
|
|
timeWeightedInvestment: new Big('38890.588976'), |
|
|
timeWeightedInvestment: new Big('44558.42'), |
|
|
timeWeightedInvestmentWithCurrencyEffect: new Big('39380.731596'), |
|
|
timeWeightedInvestmentWithCurrencyEffect: new Big('44558.42'), |
|
|
transactionCount: 1, |
|
|
transactionCount: 1, |
|
|
valueInBaseCurrency: new Big('37617.41816') |
|
|
valueInBaseCurrency: new Big('43099.7') |
|
|
} |
|
|
} |
|
|
], |
|
|
], |
|
|
totalFeesWithCurrencyEffect: new Big('3.941748'), |
|
|
totalFeesWithCurrencyEffect: new Big('4.46'), |
|
|
totalInterestWithCurrencyEffect: new Big('0'), |
|
|
totalInterestWithCurrencyEffect: new Big('0'), |
|
|
totalInvestment: new Big('38890.588976'), |
|
|
totalInvestment: new Big('44558.42'), |
|
|
totalInvestmentWithCurrencyEffect: new Big('39380.731596'), |
|
|
totalInvestmentWithCurrencyEffect: new Big('44558.42'), |
|
|
totalLiabilitiesWithCurrencyEffect: new Big('0'), |
|
|
totalLiabilitiesWithCurrencyEffect: new Big('0'), |
|
|
totalValuablesWithCurrencyEffect: new Big('0') |
|
|
totalValuablesWithCurrencyEffect: new Big('0') |
|
|
}); |
|
|
}); |
|
@ -241,7 +243,7 @@ describe('PortfolioCalculator', () => { |
|
|
]); |
|
|
]); |
|
|
|
|
|
|
|
|
expect(investmentsByMonth).toEqual([ |
|
|
expect(investmentsByMonth).toEqual([ |
|
|
{ date: '2021-12-01', investment: 39380.731596 }, |
|
|
{ date: '2021-12-01', investment: 44558.42 }, |
|
|
{ date: '2022-01-01', investment: 0 } |
|
|
{ date: '2022-01-01', investment: 0 } |
|
|
]); |
|
|
]); |
|
|
}); |
|
|
}); |
|
|