add investment to timeline calculation
This commit is contained in:
parent
4f7628921d
commit
dd86adcea1
@ -561,19 +561,19 @@ describe('PortfolioCalculator', () => {
|
|||||||
{
|
{
|
||||||
date: '2019-01-01',
|
date: '2019-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('0'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-01-01',
|
date: '2020-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-01-01',
|
date: '2021-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
@ -601,217 +601,217 @@ describe('PortfolioCalculator', () => {
|
|||||||
{
|
{
|
||||||
date: '2019-01-01',
|
date: '2019-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('0'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-02-01',
|
date: '2019-02-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-03-01',
|
date: '2019-03-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-04-01',
|
date: '2019-04-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-05-01',
|
date: '2019-05-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-06-01',
|
date: '2019-06-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-07-01',
|
date: '2019-07-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-08-01',
|
date: '2019-08-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('1443.8'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-09-01',
|
date: '2019-09-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-10-01',
|
date: '2019-10-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-11-01',
|
date: '2019-11-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2019-12-01',
|
date: '2019-12-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-01-01',
|
date: '2020-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-02-01',
|
date: '2020-02-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-03-01',
|
date: '2020-03-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-04-01',
|
date: '2020-04-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-05-01',
|
date: '2020-05-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-06-01',
|
date: '2020-06-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-07-01',
|
date: '2020-07-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-08-01',
|
date: '2020-08-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-09-01',
|
date: '2020-09-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-10-01',
|
date: '2020-10-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-11-01',
|
date: '2020-11-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-12-01',
|
date: '2020-12-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-01-01',
|
date: '2021-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-02-01',
|
date: '2021-02-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-03-01',
|
date: '2021-03-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-04-01',
|
date: '2021-04-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-05-01',
|
date: '2021-05-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-06-01',
|
date: '2021-06-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-07-01',
|
date: '2021-07-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-08-01',
|
date: '2021-08-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-09-01',
|
date: '2021-09-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-10-01',
|
date: '2021-10-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-11-01',
|
date: '2021-11-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-01',
|
date: '2021-12-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
@ -843,85 +843,85 @@ describe('PortfolioCalculator', () => {
|
|||||||
{
|
{
|
||||||
date: '2019-01-01',
|
date: '2019-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('0'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-01-01',
|
date: '2020-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-01-01',
|
date: '2021-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-02-01',
|
date: '2021-02-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-03-01',
|
date: '2021-03-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-04-01',
|
date: '2021-04-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-05-01',
|
date: '2021-05-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-06-01',
|
date: '2021-06-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-07-01',
|
date: '2021-07-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-08-01',
|
date: '2021-08-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-09-01',
|
date: '2021-09-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-10-01',
|
date: '2021-10-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-11-01',
|
date: '2021-11-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-01',
|
date: '2021-12-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
@ -957,265 +957,265 @@ describe('PortfolioCalculator', () => {
|
|||||||
{
|
{
|
||||||
date: '2019-01-01',
|
date: '2019-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('0'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2020-01-01',
|
date: '2020-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2923.7'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-01-01',
|
date: '2021-01-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('652.55'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-02-01',
|
date: '2021-02-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-03-01',
|
date: '2021-03-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-04-01',
|
date: '2021-04-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-05-01',
|
date: '2021-05-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-06-01',
|
date: '2021-06-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-07-01',
|
date: '2021-07-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('2684.05'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-08-01',
|
date: '2021-08-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-09-01',
|
date: '2021-09-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-10-01',
|
date: '2021-10-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-11-01',
|
date: '2021-11-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-01',
|
date: '2021-12-01',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-02',
|
date: '2021-12-02',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-03',
|
date: '2021-12-03',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-04',
|
date: '2021-12-04',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-05',
|
date: '2021-12-05',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-06',
|
date: '2021-12-06',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-07',
|
date: '2021-12-07',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-08',
|
date: '2021-12-08',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-09',
|
date: '2021-12-09',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-10',
|
date: '2021-12-10',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-11',
|
date: '2021-12-11',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-12',
|
date: '2021-12-12',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-13',
|
date: '2021-12-13',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-14',
|
date: '2021-12-14',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-15',
|
date: '2021-12-15',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-16',
|
date: '2021-12-16',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-17',
|
date: '2021-12-17',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-18',
|
date: '2021-12-18',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-19',
|
date: '2021-12-19',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-20',
|
date: '2021-12-20',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-21',
|
date: '2021-12-21',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-22',
|
date: '2021-12-22',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-23',
|
date: '2021-12-23',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-24',
|
date: '2021-12-24',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-25',
|
date: '2021-12-25',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-26',
|
date: '2021-12-26',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-27',
|
date: '2021-12-27',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-28',
|
date: '2021-12-28',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-29',
|
date: '2021-12-29',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-30',
|
date: '2021-12-30',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
},
|
},
|
||||||
{
|
{
|
||||||
date: '2021-12-31',
|
date: '2021-12-31',
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment: new Big('4460.95'),
|
||||||
value: 0
|
value: 0
|
||||||
}
|
}
|
||||||
]);
|
]);
|
||||||
|
@ -14,6 +14,10 @@ import {
|
|||||||
|
|
||||||
const DATE_FORMAT = 'yyyy-MM-dd';
|
const DATE_FORMAT = 'yyyy-MM-dd';
|
||||||
|
|
||||||
|
function dparse(date: string) {
|
||||||
|
return parse(date, DATE_FORMAT, new Date());
|
||||||
|
}
|
||||||
|
|
||||||
export class PortfolioCalculator {
|
export class PortfolioCalculator {
|
||||||
private transactionPoints: TransactionPoint[];
|
private transactionPoints: TransactionPoint[];
|
||||||
|
|
||||||
@ -135,11 +139,12 @@ export class PortfolioCalculator {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const startDate = timelineSpecification[0].start;
|
const startDate = timelineSpecification[0].start;
|
||||||
const start = parse(startDate, DATE_FORMAT, new Date());
|
const start = dparse(startDate);
|
||||||
const end = parse(endDate, DATE_FORMAT, new Date());
|
const end = dparse(endDate);
|
||||||
|
|
||||||
const timelinePeriod: TimelinePeriod[] = [];
|
const timelinePeriod: TimelinePeriod[] = [];
|
||||||
let i = 0;
|
let i = 0;
|
||||||
|
let j = -1;
|
||||||
for (
|
for (
|
||||||
let currentDate = start;
|
let currentDate = start;
|
||||||
!isAfter(currentDate, end);
|
!isAfter(currentDate, end);
|
||||||
@ -151,10 +156,23 @@ export class PortfolioCalculator {
|
|||||||
if (this.isNextItemActive(timelineSpecification, currentDate, i)) {
|
if (this.isNextItemActive(timelineSpecification, currentDate, i)) {
|
||||||
i++;
|
i++;
|
||||||
}
|
}
|
||||||
|
while (
|
||||||
|
j + 1 < this.transactionPoints.length &&
|
||||||
|
!isAfter(dparse(this.transactionPoints[j + 1].date), currentDate)
|
||||||
|
) {
|
||||||
|
j++;
|
||||||
|
}
|
||||||
|
|
||||||
|
let investment: Big = new Big(0);
|
||||||
|
if (j >= 0) {
|
||||||
|
for (const item of this.transactionPoints[j].items) {
|
||||||
|
investment = investment.add(item.investment);
|
||||||
|
}
|
||||||
|
}
|
||||||
timelinePeriod.push({
|
timelinePeriod.push({
|
||||||
date: format(currentDate, DATE_FORMAT),
|
date: format(currentDate, DATE_FORMAT),
|
||||||
grossPerformance: 0,
|
grossPerformance: 0,
|
||||||
investment: 0,
|
investment,
|
||||||
value: 0
|
value: 0
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -196,10 +214,7 @@ export class PortfolioCalculator {
|
|||||||
) {
|
) {
|
||||||
return (
|
return (
|
||||||
i + 1 < timelineSpecification.length &&
|
i + 1 < timelineSpecification.length &&
|
||||||
!isBefore(
|
!isBefore(currentDate, dparse(timelineSpecification[i + 1].start))
|
||||||
currentDate,
|
|
||||||
parse(timelineSpecification[i + 1].start, DATE_FORMAT, new Date())
|
|
||||||
)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -238,7 +253,7 @@ export interface TimelineSpecification {
|
|||||||
export interface TimelinePeriod {
|
export interface TimelinePeriod {
|
||||||
date: string;
|
date: string;
|
||||||
grossPerformance: number;
|
grossPerformance: number;
|
||||||
investment: number;
|
investment: Big;
|
||||||
value: number;
|
value: number;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user