-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathutils.js
More file actions
793 lines (687 loc) · 20.7 KB
/
Copy pathutils.js
File metadata and controls
793 lines (687 loc) · 20.7 KB
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
import { vacationDates } from "./js/dataLoader.js";
// ================= FORMATTERS =================
// VND – no decimals
export const vndInt = new Intl.NumberFormat("vi-VN", {
style: "currency",
currency: "VND",
maximumFractionDigits: 0,
});
// VND – 6 decimals
export const vnd6 = new Intl.NumberFormat("vi-VN", {
style: "currency",
currency: "VND",
minimumFractionDigits: 6,
maximumFractionDigits: 6,
});
// ================= FACE VALUE INPUT =================
export function formatVNDInput(value) {
const digits = value.replace(/\D/g, "");
return digits.replace(/\B(?=(\d{3})+(?!\d))/g, ".");
}
export function parseVNDInput(value) {
return Number(value.replace(/[.,]/g, ""));
}
// ================= DATE PARSER (DD/MM/YYYY) =================
export function parseDateVN(str) {
if (!str) return null;
// DD/MM/YYYY
if (str.includes("/")) {
const [d, m, y] = str.split("/").map(Number);
return new Date(Date.UTC(y, m - 1, d));
}
// YYYY-MM-DD (fallback)
if (str.includes("-")) {
const [y, m, d] = str.split("-").map(Number);
return new Date(Date.UTC(y, m - 1, d));
}
return null;
}
export function formatDateVN(dt) {
const d = String(dt.getUTCDate()).padStart(2, "0");
const m = String(dt.getUTCMonth() + 1).padStart(2, "0");
const y = dt.getUTCFullYear();
return `${d}/${m}/${y}`;
}
export function getVacationInfo(date) {
if (!date || !(date instanceof Date) || Number.isNaN(date.getTime())) {
return null;
}
const target = formatDateVN(date);
for (const [startStr, info] of Object.entries(vacationDates || {})) {
const duration = info.Last || 1;
const startDate = parseDateVN(startStr);
for (let offset = 0; offset < duration; offset++) {
const current = new Date(startDate);
current.setUTCDate(current.getUTCDate() + offset);
if (formatDateVN(current) === target) {
return {
name: info.Name,
startDate: startStr,
dayIndex: offset + 1,
duration,
};
}
}
}
return null;
}
// ================= DATE MATH =================
function addMonthsUTC(dt, months) {
const y = dt.getUTCFullYear();
const m = dt.getUTCMonth();
const d = dt.getUTCDate();
const tmp = new Date(Date.UTC(y, m + months, 1));
const last = new Date(
Date.UTC(tmp.getUTCFullYear(), tmp.getUTCMonth() + 1, 0),
).getUTCDate();
let result = new Date(
Date.UTC(tmp.getUTCFullYear(), tmp.getUTCMonth(), Math.min(d, last)),
);
return result;
}
function subtractWorkingDays(dt, days, vacationData) {
let result = new Date(dt);
let remaining = days;
// Build holiday set inside this function
const holidaySet = new Set();
Object.entries(vacationData).forEach(([startStr, info]) => {
const startDate = parseDateVN(startStr);
const duration = info.Last || 1;
for (let i = 0; i < duration; i++) {
const d = new Date(startDate);
d.setDate(d.getDate() + i);
holidaySet.add(d.toDateString());
}
});
// Subtract working days
while (remaining > 0) {
result.setDate(result.getDate() - 1);
const day = result.getDay();
const isWeekend = day === 0 || day === 6;
const isHoliday = holidaySet.has(result.toDateString());
if (!isWeekend && !isHoliday) {
remaining--;
}
}
return result;
}
// Get next working day (skip weekends and holidays)
export function getNextWorkingDay(dt, vacationData = null) {
if (!dt || !(dt instanceof Date)) {
return null;
}
let result = new Date(dt);
const holidaySet = new Set();
if (vacationData) {
Object.entries(vacationData).forEach(([startStr, info]) => {
const startDate = parseDateVN(startStr);
const duration = info.Last || 1;
for (let i = 0; i < duration; i++) {
const d = new Date(startDate);
d.setUTCDate(d.getUTCDate() + i);
holidaySet.add(formatDateVN(d));
}
});
}
// Move forward by at least one day first
result.setUTCDate(result.getUTCDate() + 1);
// Then find the next working day
while (true) {
const day = result.getUTCDay();
const isWeekend = day === 0 || day === 6;
const isHoliday = holidaySet.has(formatDateVN(result));
if (!isWeekend && !isHoliday) {
break;
}
result.setUTCDate(result.getUTCDate() + 1);
}
return result;
}
function actualDays(d1, d2) {
return Math.round((d2 - d1) / (24 * 60 * 60 * 1000));
}
function yearFrac(d1, d2) {
return actualDays(d1, d2) / 365;
}
// Check if settlement date is in recording period
export function isInRecordingPeriod(
settleDate,
couponDate,
recordingDays = 10,
) {
const recordingStart = subtractWorkingDays(
couponDate,
recordingDays,
vacationDates,
);
return settleDate >= recordingStart && settleDate < couponDate;
}
// ================= SCHEDULE =================
function buildSchedule(issue, maturity, freq, vacationData, regime = "NORMAL") {
const step = 12 / freq;
let dates = [];
let cur = new Date(issue); // Start from issue date
dates.push(cur);
let i = 1;
while (cur < maturity) {
cur = addMonthsUTC(new Date(issue), i * step);
if (regime != "NORMAL") {
const holidaySet = new Set();
Object.entries(vacationData).forEach(([startStr, info]) => {
const startDate = parseDateVN(startStr);
const duration = info.Last || 1;
for (let i = 0; i < duration; i++) {
const d = new Date(startDate);
d.setDate(d.getDate() + i);
holidaySet.add(d.toDateString());
}
});
// Adjust to next working day (Monday) if Saturday (6) or Sunday (0)
const dayOfWeek = cur.getUTCDay();
if (dayOfWeek === 0) {
// Sunday → next Monday
cur = new Date(
Date.UTC(
cur.getUTCFullYear(),
cur.getUTCMonth(),
cur.getUTCDate() + 1,
),
);
} else if (dayOfWeek === 6) {
// Saturday → next Monday
cur = new Date(
Date.UTC(
cur.getUTCFullYear(),
cur.getUTCMonth(),
cur.getUTCDate() + 2,
),
);
} else if (holidaySet.has(cur.toDateString())) {
// If the current date is a holiday, move to the next working day
cur = new Date(
Date.UTC(
cur.getUTCFullYear(),
cur.getUTCMonth(),
cur.getUTCDate() + 1,
),
);
// Keep moving forward until we find a non-holiday working day
while (holidaySet.has(cur.toDateString())) {
cur = new Date(
Date.UTC(
cur.getUTCFullYear(),
cur.getUTCMonth(),
cur.getUTCDate() + 1,
),
);
}
}
}
dates.push(cur);
i++;
// If we overshoot maturity, stop
if (cur > maturity) {
dates[dates.length - 1] = maturity; // Set last date to maturity
break;
}
}
return dates;
}
function findPrevNext(schedule, settle) {
let i = 0;
let prev = null,
next = null;
for (let d of schedule) {
i++;
if (d <= settle) prev = d;
if (d > settle && !next) next = d;
}
return { prev, next };
}
// ================= FLOATING RATE HELPERS =================
export function getPaymentNumber(schedule, payDate) {
let count = 0;
for (let d of schedule) {
if (+d === +payDate) return count;
count++;
}
return count;
}
export function getInterestRate(interestSchedule, paymentNum) {
// Find the rate for this payment number
for (let i = interestSchedule.length - 1; i >= 0; i--) {
if (paymentNum >= interestSchedule[i].payment) {
return interestSchedule[i];
}
}
// Default to first rate if payment number is before first defined payment
return interestSchedule[0] || { rate: 0, payment: 0, isFloat: false };
}
export function calculateAverageBankRate(referenceBank, bankRates) {
if (!referenceBank || referenceBank.length === 0) return 0;
let sum = 0;
let count = 0;
for (let bank of referenceBank) {
if (bankRates[bank] !== undefined) {
sum += bankRates[bank];
count++;
}
}
return count > 0 ? sum / count : 0;
}
// ================= PRICING (FLOATING RATE) =================
export function priceFloatingBond({
fv,
ytm,
freq,
issue,
settle,
maturity,
interestSchedule,
baseBankRate,
recordingDays = 10,
regime = "NORMAL",
}) {
const schedule = buildSchedule(issue, maturity, freq, vacationDates, regime);
const { prev, next } = findPrevNext(schedule, settle);
let accrued = 0;
let inRecordingPeriod = false;
let upcomingCouponDate = null;
let recordingStartDate = null;
// Check if we're in recording period for the next coupon
if (next) {
inRecordingPeriod = isInRecordingPeriod(settle, next, recordingDays);
if (inRecordingPeriod) {
upcomingCouponDate = next;
recordingStartDate = subtractWorkingDays(
next,
recordingDays,
vacationDates,
);
}
}
// If in recording period, don't calculate accrued interest
if (!inRecordingPeriod && prev && settle >= prev) {
const paymentNum = getPaymentNumber(schedule, prev);
const scheduleRate = getInterestRate(interestSchedule, paymentNum);
let effectiveRate =
scheduleRate.rate + (scheduleRate.isFloat ? baseBankRate : 0);
if (scheduleRate.floorRate && effectiveRate < scheduleRate.floorRate) {
effectiveRate = scheduleRate.floorRate;
}
accrued = fv * effectiveRate * yearFrac(prev, settle);
}
let dirty = 0;
let cfs = [];
function df(payDate) {
const yf = yearFrac(settle, payDate);
const r = ytm / 100;
return Math.pow(1 + r, -yf);
}
for (let i = 0; i < schedule.length; i++) {
const payDate = schedule[i];
if (payDate <= settle) continue;
// Skip the next coupon if we're in its recording period
if (inRecordingPeriod && +payDate === +next) {
cfs.push({
date: formatDateVN(payDate),
yf: 0,
cf: 0,
pv: 0,
rate: 0,
paymentNum: getPaymentNumber(schedule, payDate),
scheduleRate: 0,
baseBankRate,
skipped: true,
reason: "In recording period",
});
continue;
}
const prevDate = schedule[i - 1] ?? issue;
const yf = yearFrac(prevDate, payDate);
// Get payment number and corresponding rate
const paymentNum = getPaymentNumber(schedule, payDate);
const scheduleRate = getInterestRate(interestSchedule, paymentNum);
let effectiveRate =
scheduleRate.rate + (scheduleRate.isFloat ? baseBankRate : 0);
if (scheduleRate.floorRate && effectiveRate < scheduleRate.floorRate) {
effectiveRate = scheduleRate.floorRate;
}
let cf = fv * effectiveRate * yf;
if (+payDate === +maturity) cf += fv;
const pv = cf * df(payDate);
dirty += pv;
cfs.push({
date: formatDateVN(payDate),
yf,
cf,
pv,
rate: effectiveRate,
paymentNum,
scheduleRate: scheduleRate.rate,
baseBankRate,
skipped: false,
});
}
return {
dirty,
clean: dirty - accrued,
accrued,
prev,
next,
cfs,
inRecordingPeriod,
upcomingCouponDate,
recordingStartDate,
};
}
// ================= YTM CALCULATION (NEWTON-RAPHSON) =================
export function calculateYTM({
fv,
targetPrice,
freq,
issue,
settle,
maturity,
interestSchedule,
baseBankRate,
recordingDays = 10,
initialGuess = 8, // Initial YTM guess in %
tolerance = 0.0001, // Price difference tolerance in VND
maxIterations = 100,
regime = "NORMAL",
}) {
let ytm = initialGuess;
let iteration = 0;
let priceDiff = Infinity;
while (iteration < maxIterations && Math.abs(priceDiff) > tolerance) {
// Calculate price at current YTM
const result = priceFloatingBond({
fv,
ytm,
freq,
issue,
settle,
maturity,
interestSchedule,
baseBankRate,
recordingDays,
regime
});
priceDiff = result.dirty - targetPrice;
// If close enough, return
if (Math.abs(priceDiff) <= tolerance) {
return {
success: true,
ytm,
iterations: iteration,
precision: Math.abs(priceDiff),
bondData: result,
};
}
// Calculate derivative (numerical approximation)
const delta = 0.001; // Small change in YTM for derivative
const resultUp = priceFloatingBond({
fv,
ytm: ytm + delta,
freq,
issue,
settle,
maturity,
interestSchedule,
baseBankRate,
recordingDays,
regime
});
const derivative = (resultUp.dirty - result.dirty) / delta;
// Prevent division by zero
if (Math.abs(derivative) < 1e-10) {
return {
success: false,
message: `Convergence failed: derivative too small at iteration ${iteration}`,
ytm,
iterations: iteration,
};
}
// Newton-Raphson update
const ytmNew = ytm - priceDiff / derivative;
// Prevent unrealistic YTM values
if (ytmNew < -50 || ytmNew > 100) {
return {
success: false,
message: `YTM out of reasonable range (${ytmNew.toFixed(2)}%) at iteration ${iteration}`,
ytm,
iterations: iteration,
};
}
ytm = ytmNew;
iteration++;
}
if (iteration >= maxIterations) {
return {
success: false,
message: `Maximum iterations (${maxIterations}) reached. Last price difference: ${vndInt.format(Math.abs(priceDiff))}`,
ytm,
iterations: iteration,
};
}
// Final calculation with converged YTM
const finalResult = priceFloatingBond({
fv,
ytm,
freq,
issue,
settle,
maturity,
interestSchedule,
baseBankRate,
recordingDays,
regime
});
return {
success: true,
ytm,
iterations: iteration,
precision: Math.abs(finalResult.dirty - targetPrice),
bondData: finalResult,
};
}
// ================= TRANSACTION CALCULATION =================
export function calculateTransaction({
numBonds,
faceValue,
paymentDateBuying,
discountYield,
paymentDateSelling,
holdingRate,
coverFees,
isInstitution = false,
transactionFeeRate = 0.001, // Default 0.1%, can be 0.015% for private bonds
freq,
issue,
maturity,
interestSchedule,
baseBankRate,
recordingDays = 10,
regime = "NORMAL",
couponPrecision = 0,
}) {
// ========== LEG 1 (BUYING) ==========
const leg1Bond = priceFloatingBond({
fv: faceValue,
ytm: discountYield,
freq,
issue,
settle: paymentDateBuying,
maturity,
interestSchedule,
baseBankRate,
recordingDays,
regime
});
const leg1PricePerBond = Math.round(leg1Bond.dirty + 0.5);
const leg1SettlementAmount = leg1PricePerBond * numBonds;
const leg1TransactionFee = Math.round(leg1SettlementAmount * transactionFeeRate);
const leg1TotalInvestment = leg1SettlementAmount + leg1TransactionFee;
// ========== CALCULATE COUPONS RECEIVED ==========
const schedule = buildSchedule(issue, maturity, freq, vacationDates, regime);
let couponsReceived = 0;
const couponFlows = []; // NEW: Track individual coupon payments
const couponTaxRate = isInstitution ? 0 : 0.05;
for (let i = 0; i < schedule.length; i++) {
const couponDate = schedule[i];
if (
subtractWorkingDays(couponDate, recordingDays, vacationDates) >=
paymentDateBuying &&
subtractWorkingDays(couponDate, recordingDays, vacationDates) <
paymentDateSelling
) {
const prevDate = schedule[i - 1] ?? issue;
const yf = yearFrac(prevDate, couponDate);
const paymentNum = getPaymentNumber(schedule, couponDate);
const scheduleRate = getInterestRate(interestSchedule, paymentNum);
let effectiveRate =
scheduleRate.rate + (scheduleRate.isFloat ? baseBankRate : 0);
if (scheduleRate.floorRate && effectiveRate < scheduleRate.floorRate) {
effectiveRate = scheduleRate.floorRate;
}
const grossCouponAmount = Math.round(Math.round(faceValue * effectiveRate * yf * Math.pow(10, couponPrecision)) / Math.pow(10, couponPrecision) * numBonds);
const couponTax = grossCouponAmount * couponTaxRate;
const netCouponAmount = grossCouponAmount - couponTax;
couponsReceived += grossCouponAmount;
// NEW: Store coupon flow details
couponFlows.push({
date: couponDate,
grossAmount: grossCouponAmount,
tax: couponTax,
netAmount: netCouponAmount,
});
}
}
const couponTax = couponsReceived * couponTaxRate;
const netCoupons = couponsReceived - couponTax;
// ========== CALCULATE TARGET AMOUNT ==========
const daysHolding = actualDays(paymentDateBuying, paymentDateSelling);
let targetAmount;
if (coverFees) {
targetAmount = Math.round(leg1TotalInvestment * (1 + (holdingRate / 100) * (daysHolding / 365)));
}
else {
targetAmount = Math.round(leg1SettlementAmount * (1 + (holdingRate / 100) * (daysHolding / 365)));
}
// ========== LEG 2 (SELLING) ==========
let leg2SettlementAmount;
let leg2PricePerBond;
let leg2TransactionFee;
let leg2TransferTax;
let leg2TransferFee;
let leg2TotalReceived;
if (coverFees) {
if (isInstitution) {
const transferFee = Math.min(300000, numBonds * 0.3);
leg2SettlementAmount = (targetAmount - netCoupons + transferFee) / (1 - transactionFeeRate);
leg2PricePerBond = Math.round(leg2SettlementAmount / numBonds);
leg2SettlementAmount = leg2PricePerBond * numBonds;
leg2TransactionFee = leg2SettlementAmount * transactionFeeRate;
leg2TransferFee = transferFee;
leg2TransferTax = 0.0
leg2TotalReceived =
leg2SettlementAmount -
leg2TransactionFee -
leg2TransferFee +
netCoupons;
} else
{
const transferFee = Math.min(300000, numBonds * 0.3);
leg2SettlementAmount = (targetAmount - netCoupons + transferFee) / (1 - transactionFeeRate - 0.001);
leg2PricePerBond = Math.round(leg2SettlementAmount / numBonds);
leg2SettlementAmount = leg2PricePerBond * numBonds;
leg2TransactionFee = leg2SettlementAmount * transactionFeeRate;
leg2TransferTax = leg2SettlementAmount * 0.001;
leg2TransferFee = transferFee;
leg2TotalReceived =
leg2SettlementAmount -
leg2TransactionFee -
leg2TransferTax -
leg2TransferFee +
netCoupons;
}
} else {
leg2SettlementAmount = targetAmount - netCoupons;
leg2PricePerBond = leg2SettlementAmount / numBonds;
leg2TransactionFee = leg2SettlementAmount * transactionFeeRate;
leg2TransferTax = leg2SettlementAmount * 0.001;
leg2TransferFee = Math.min(300000, numBonds * 0.3);
leg2TotalReceived = leg2SettlementAmount + netCoupons;
}
// Calculate remaining YTM based on leg2 price
const leg2YTMResult = calculateYTM({
fv: faceValue,
targetPrice: leg2PricePerBond,
freq,
issue,
settle: paymentDateSelling,
maturity,
interestSchedule,
baseBankRate,
recordingDays,
initialGuess: holdingRate,
tolerance: 0.0001,
maxIterations: 100,
regime
});
// ========== PROFIT CALCULATION ==========
const expectedInterest =
leg1TotalInvestment * (holdingRate / 100) * (daysHolding / 365);
let totalProfit;
if (coverFees) {
totalProfit = leg2TotalReceived - leg1TotalInvestment;
} else {
totalProfit =
leg2TotalReceived -
leg1TotalInvestment -
leg2TransferFee -
leg2TransferTax -
leg2TransactionFee;
}
const annualizedReturn =
(totalProfit / leg1TotalInvestment) * (365 / daysHolding) * 100;
return {
leg1: {
pricePerBond: leg1PricePerBond,
settlementAmount: leg1SettlementAmount,
transactionFee: leg1TransactionFee,
totalInvestment: leg1TotalInvestment,
paymentDate: paymentDateBuying,
inRecordingPeriod: leg1Bond.inRecordingPeriod,
upcomingCouponDate: leg1Bond.upcomingCouponDate,
recordingStartDate: leg1Bond.recordingStartDate,
},
leg2: {
pricePerBond: leg2PricePerBond,
settlementAmount: leg2SettlementAmount,
transactionFee: leg2TransactionFee,
transferTax: leg2TransferTax,
transferFee: leg2TransferFee,
totalReceived: leg2TotalReceived,
paymentDate: paymentDateSelling,
remainingYTM: leg2YTMResult.success ? leg2YTMResult.ytm : null,
ytmCalculationSuccess: leg2YTMResult.success,
ytmCalculationMessage: leg2YTMResult.success ? null : leg2YTMResult.message,
inRecordingPeriod: leg2YTMResult.success ? leg2YTMResult.bondData.inRecordingPeriod : false,
upcomingCouponDate: leg2YTMResult.success ? leg2YTMResult.bondData.upcomingCouponDate : null,
recordingStartDate: leg2YTMResult.success ? leg2YTMResult.bondData.recordingStartDate : null,
},
profit: {
daysHolding,
expectedInterest,
couponsReceived,
couponTax,
netCoupons,
couponFlows,
totalProfit,
holdingInterestRate: annualizedReturn,
targetAmount,
},
};
}