Browse Source

Improve tests

pull/3393/head
Thomas Kaul 1 year ago
parent
commit
75062158cf
  1. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts
  2. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts
  3. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy.spec.ts
  4. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts
  5. 1
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-fee.spec.ts
  6. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-googl-buy.spec.ts
  7. 1
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-item.spec.ts
  8. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell-partially.spec.ts
  9. 3
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts
  10. 5
      apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell-in-two-activities.spec.ts

@ -178,6 +178,9 @@ describe('PortfolioCalculator', () => {
'-0.05528341497550734703' '-0.05528341497550734703'
), ),
netPerformanceWithCurrencyEffect: new Big('-15.8'), netPerformanceWithCurrencyEffect: new Big('-15.8'),
netPerformanceWithCurrencyEffectMap: {
max: new Big('-15.8')
},
marketPrice: 148.9, marketPrice: 148.9,
marketPriceInBaseCurrency: 148.9, marketPriceInBaseCurrency: 148.9,
quantity: new Big('0'), quantity: new Big('0'),

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy-and-sell.spec.ts

@ -163,6 +163,9 @@ describe('PortfolioCalculator', () => {
'-0.0552834149755073478' '-0.0552834149755073478'
), ),
netPerformanceWithCurrencyEffect: new Big('-15.8'), netPerformanceWithCurrencyEffect: new Big('-15.8'),
netPerformanceWithCurrencyEffectMap: {
max: new Big('-15.8')
},
marketPrice: 148.9, marketPrice: 148.9,
marketPriceInBaseCurrency: 148.9, marketPriceInBaseCurrency: 148.9,
quantity: new Big('0'), quantity: new Big('0'),

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-baln-buy.spec.ts

@ -148,6 +148,9 @@ describe('PortfolioCalculator', () => {
'0.08437042459736456808' '0.08437042459736456808'
), ),
netPerformanceWithCurrencyEffect: new Big('23.05'), netPerformanceWithCurrencyEffect: new Big('23.05'),
netPerformanceWithCurrencyEffectMap: {
max: new Big('23.05')
},
marketPrice: 148.9, marketPrice: 148.9,
marketPriceInBaseCurrency: 148.9, marketPriceInBaseCurrency: 148.9,
quantity: new Big('2'), quantity: new Big('2'),

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-btcusd-buy-and-sell-partially.spec.ts

@ -182,6 +182,9 @@ describe('PortfolioCalculator', () => {
netPerformanceWithCurrencyEffect: new Big( netPerformanceWithCurrencyEffect: new Big(
'26516.208701400000064086' '26516.208701400000064086'
), ),
netPerformanceWithCurrencyEffectMap: {
max: new Big('26516.208701400000064086')
},
quantity: new Big('1'), quantity: new Big('1'),
symbol: 'BTCUSD', symbol: 'BTCUSD',
tags: [], tags: [],

1
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-fee.spec.ts

@ -131,6 +131,7 @@ describe('PortfolioCalculator', () => {
netPerformancePercentage: null, netPerformancePercentage: null,
netPerformancePercentageWithCurrencyEffect: null, netPerformancePercentageWithCurrencyEffect: null,
netPerformanceWithCurrencyEffect: null, netPerformanceWithCurrencyEffect: null,
netPerformanceWithCurrencyEffectMap: null,
quantity: new Big('0'), quantity: new Big('0'),
symbol: '2c463fb3-af07-486e-adb0-8301b3d72141', symbol: '2c463fb3-af07-486e-adb0-8301b3d72141',
tags: [], tags: [],

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-googl-buy.spec.ts

@ -161,6 +161,9 @@ describe('PortfolioCalculator', () => {
'0.24112962014285697628' '0.24112962014285697628'
), ),
netPerformanceWithCurrencyEffect: new Big('19.851974'), netPerformanceWithCurrencyEffect: new Big('19.851974'),
netPerformanceWithCurrencyEffectMap: {
max: new Big('19.851974')
},
marketPrice: 116.45, marketPrice: 116.45,
marketPriceInBaseCurrency: 103.10483, marketPriceInBaseCurrency: 103.10483,
quantity: new Big('1'), quantity: new Big('1'),

1
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-item.spec.ts

@ -131,6 +131,7 @@ describe('PortfolioCalculator', () => {
netPerformancePercentage: null, netPerformancePercentage: null,
netPerformancePercentageWithCurrencyEffect: null, netPerformancePercentageWithCurrencyEffect: null,
netPerformanceWithCurrencyEffect: null, netPerformanceWithCurrencyEffect: null,
netPerformanceWithCurrencyEffectMap: null,
quantity: new Big('0'), quantity: new Big('0'),
symbol: 'dac95060-d4f2-4653-a253-2c45e6fb5cde', symbol: 'dac95060-d4f2-4653-a253-2c45e6fb5cde',
tags: [], tags: [],

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell-partially.spec.ts

@ -163,6 +163,9 @@ describe('PortfolioCalculator', () => {
'0.12184460284330327256' '0.12184460284330327256'
), ),
netPerformanceWithCurrencyEffect: new Big('17.68'), netPerformanceWithCurrencyEffect: new Big('17.68'),
netPerformanceWithCurrencyEffectMap: {
max: new Big('17.68')
},
marketPrice: 87.8, marketPrice: 87.8,
marketPriceInBaseCurrency: 87.8, marketPriceInBaseCurrency: 87.8,
quantity: new Big('1'), quantity: new Big('1'),

3
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator-novn-buy-and-sell.spec.ts

@ -193,6 +193,9 @@ describe('PortfolioCalculator', () => {
'0.13100263852242744063' '0.13100263852242744063'
), ),
netPerformanceWithCurrencyEffect: new Big('19.86'), netPerformanceWithCurrencyEffect: new Big('19.86'),
netPerformanceWithCurrencyEffectMap: {
max: new Big('19.86')
},
marketPrice: 87.8, marketPrice: 87.8,
marketPriceInBaseCurrency: 87.8, marketPriceInBaseCurrency: 87.8,
quantity: new Big('0'), quantity: new Big('0'),

5
apps/api/src/app/portfolio/calculator/twr/portfolio-calculator.ts

@ -920,14 +920,15 @@ export class TWRPortfolioCalculator extends PortfolioCalculator {
average = average.div(dayCount); average = average.div(dayCount);
// TODO: Why without minus?
netPerformanceWithCurrencyEffectMap[dateRange] = average.gt(0) netPerformanceWithCurrencyEffectMap[dateRange] = average.gt(0)
? netPerformanceValuesWithCurrencyEffect[ ? netPerformanceValuesWithCurrencyEffect[
format(endDate, DATE_FORMAT) format(endDate, DATE_FORMAT)
].minus( ] /*.minus(
netPerformanceValuesWithCurrencyEffect[ netPerformanceValuesWithCurrencyEffect[
format(startDate, DATE_FORMAT) format(startDate, DATE_FORMAT)
] ]
) )*/
: new Big(0); : new Big(0);
netPerformancePercentageWithCurrencyEffectMap[dateRange] = average.gt(0) netPerformancePercentageWithCurrencyEffectMap[dateRange] = average.gt(0)

Loading…
Cancel
Save