Press n or j to go to the next uncovered block, b, p or k for the previous block.
| 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | 40x 40x 40x 768x 17x 768x 768x 1x 1x 1x 1x 1x 1x 1x 13x 13x 13x 13x 1x 1x 768x 768x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 17x 768x 40x | 'use strict';
Object.defineProperty(exports, "__esModule", { value: true });
module.exports = () => ({
loadFormatData(journal) {
return journal.commodities({ usage: 'all' });
},
formatCsv(report, _cliOptions, { csvField }) {
const fields = [
'from', 'to', 'commodities', 'valuationCommodity', 'openingValue',
'endingValue', 'netContributions', 'profitLoss', 'timeWeightedReturn',
'timeWeightedReturnAnnualized',
'moneyWeightedReturn', 'moneyWeightedReturnTotal', 'points',
];
const value = (field) => {
const fieldValue = report[field];
if (fieldValue === null || fieldValue === undefined)
return '';
return Array.isArray(fieldValue) ? JSON.stringify(fieldValue) : fieldValue;
};
return `${fields.join(',')}\n${fields.map((field) => csvField(value(field))).join(',')}\n`;
},
formatText(report, _cliOptions, { commodityFormats, displayQuantity }, descriptions) {
const formats = commodityFormats(descriptions);
const money = (value) => `${displayQuantity(String(value), report.valuationCommodity, formats, 2, false)} ${report.valuationCommodity}`;
const percent = (value) => value === null ? 'n/a' : `${(value * 100).toFixed(2)} %`;
return [
`Investment performance from ${report.from ?? 'n/a'} to ${report.to ?? 'n/a'}`,
`Instruments: ${report.commodities.length}`,
`Opening value: ${money(report.openingValue)}`,
`Net contributions: ${money(report.netContributions)}`,
`Ending value: ${money(report.endingValue)}`,
`Profit/loss: ${money(report.profitLoss)}`,
`Time-weighted return (total): ${percent(report.timeWeightedReturn)}`,
`Time-weighted return (annualized): ${percent(report.timeWeightedReturnAnnualized)}`,
`Money-weighted return (total): ${percent(report.moneyWeightedReturnTotal)}`,
`Money-weighted return (annualized): ${percent(report.moneyWeightedReturn)}`,
].join('\n') + '\n';
},
});
|