@sheetxl/formulas-extended 0.8.0-beta.1 → 0.8.0-beta.3

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (133) hide show
  1. package/browser/cjs/B4ANcw0mAmhe2Aeb.cjs +1 -0
  2. package/browser/cjs/B6IXpae7f0J8Ocq6.cjs +1 -0
  3. package/browser/cjs/Bncc0oXhFMdj_HuR.cjs +1 -0
  4. package/browser/cjs/C4cZxb9nRtzTCA40.cjs +1 -0
  5. package/browser/cjs/{lEQC21-Sk4lwHy2r.cjs → CFxueP0tbpmvY1Ip.cjs} +1 -1
  6. package/browser/cjs/CRcv32tHTbGSGtkh.cjs +1 -0
  7. package/browser/cjs/CaJGoNwTL6pAJ6a4.cjs +1 -0
  8. package/browser/cjs/CfXcRa4RlFmqU0Op.cjs +1 -0
  9. package/browser/cjs/{CnZfa45XxA-9Jhmp.cjs → DRmo6uoGoqtiVff8.cjs} +1 -1
  10. package/browser/cjs/DSXLVieENYN9qXYl.cjs +1 -0
  11. package/browser/cjs/DpFg69dDCPoOK2BY.cjs +1 -0
  12. package/browser/cjs/PmwvZPFhqmL4DO58.cjs +1 -0
  13. package/browser/cjs/SATfdSwNygvlOSKC.cjs +1 -0
  14. package/browser/cjs/XRCcogT-Iqd3Wv6R.cjs +1 -0
  15. package/browser/cjs/iYn00uzmSLl2T0oN.cjs +1 -0
  16. package/browser/cjs/index.cjs +1 -1
  17. package/browser/esm/6amJZ6Ci7khs1EpQ.mjs +37 -0
  18. package/{node/esm/vu0NRDeeTbEHPMYS.mjs → browser/esm/B8VR_ZAEMWJqOVFM.mjs} +2 -2
  19. package/{node/esm/Bma3CN4_Nec6_4n7.mjs → browser/esm/BGCEjkOTEskgvBSD.mjs} +6 -6
  20. package/{node/esm/DodhOXkSzelSxHmB.mjs → browser/esm/Bm9n_7JWXmhQ_BAb.mjs} +27 -29
  21. package/browser/esm/{DpoZ7h1ScIJvbOY9.mjs → BtNf1hXsR3TvolZ6.mjs} +5 -5
  22. package/{node/esm/COqdI1LYTHd9oLA6.mjs → browser/esm/BwmPpdf2z0FDv9IZ.mjs} +1 -1
  23. package/{node/esm/srpVt74r2zbvm1N0.mjs → browser/esm/C0mSYrr2yF012bGD.mjs} +5 -5
  24. package/browser/esm/{B1VmvhXuEn7zaTB9.mjs → C4vFDf_lYH0QSaE1.mjs} +1 -1
  25. package/browser/esm/{DY3kG36QGyDbrANO.mjs → CU2EkdawYacXSt1c.mjs} +1 -1
  26. package/browser/esm/{BFnDPCjxJcoIItFa.mjs → CugijEQsjGn9ENYE.mjs} +3 -3
  27. package/browser/esm/Cwb0ysaCuxSO5Wp7.mjs +58 -0
  28. package/browser/esm/D5wiSKIeUtCkBDf7.mjs +33 -0
  29. package/browser/esm/DKiPLYQWGk-Ov6wa.mjs +47 -0
  30. package/browser/esm/Da8bWIg7O-5vDAog.mjs +32 -0
  31. package/browser/esm/DdQaTbz0VTi-8RUW.mjs +32 -0
  32. package/{node/esm/CnVJ8GAsshRjRGA-.mjs → browser/esm/Dlpw5YQAcTl-Cfrt.mjs} +2 -2
  33. package/browser/esm/Dq6rGM4iP0zy52lg.mjs +19 -0
  34. package/{node/esm/BuGemmv84T8m0wqw.mjs → browser/esm/Sd9LvsDzMdOmTsXR.mjs} +1 -1
  35. package/browser/esm/WET3PcaveNwVooXd.mjs +119 -0
  36. package/{node/esm/BRwwvGaJ6HvkxjFC.mjs → browser/esm/cNTNUggnKXPO1Ebs.mjs} +1 -1
  37. package/browser/esm/index.mjs +3283 -1677
  38. package/node/esm/6amJZ6Ci7khs1EpQ.mjs +37 -0
  39. package/{browser/esm/vu0NRDeeTbEHPMYS.mjs → node/esm/B8VR_ZAEMWJqOVFM.mjs} +2 -2
  40. package/{browser/esm/Bma3CN4_Nec6_4n7.mjs → node/esm/BGCEjkOTEskgvBSD.mjs} +6 -6
  41. package/{browser/esm/DodhOXkSzelSxHmB.mjs → node/esm/Bm9n_7JWXmhQ_BAb.mjs} +27 -29
  42. package/node/esm/{DpoZ7h1ScIJvbOY9.mjs → BtNf1hXsR3TvolZ6.mjs} +5 -5
  43. package/{browser/esm/COqdI1LYTHd9oLA6.mjs → node/esm/BwmPpdf2z0FDv9IZ.mjs} +1 -1
  44. package/{browser/esm/srpVt74r2zbvm1N0.mjs → node/esm/C0mSYrr2yF012bGD.mjs} +5 -5
  45. package/node/esm/{B1VmvhXuEn7zaTB9.mjs → C4vFDf_lYH0QSaE1.mjs} +1 -1
  46. package/node/esm/Cwb0ysaCuxSO5Wp7.mjs +58 -0
  47. package/node/esm/D5wiSKIeUtCkBDf7.mjs +33 -0
  48. package/node/esm/DKiPLYQWGk-Ov6wa.mjs +47 -0
  49. package/node/esm/Da8bWIg7O-5vDAog.mjs +32 -0
  50. package/node/esm/DdQaTbz0VTi-8RUW.mjs +32 -0
  51. package/node/esm/{LAkTk93odAfpvx50.mjs → Di8nKpCkAReXfW0y.mjs} +1 -1
  52. package/{browser/esm/CnVJ8GAsshRjRGA-.mjs → node/esm/Dlpw5YQAcTl-Cfrt.mjs} +2 -2
  53. package/node/esm/{BQyZVLTMNFLbjVap.mjs → DndwLLj7OgAwCNqT.mjs} +3 -3
  54. package/{browser/esm/BuGemmv84T8m0wqw.mjs → node/esm/Sd9LvsDzMdOmTsXR.mjs} +1 -1
  55. package/node/esm/WET3PcaveNwVooXd.mjs +119 -0
  56. package/node/esm/bC-_uC9o3MGBu2fU.mjs +19 -0
  57. package/{browser/esm/BRwwvGaJ6HvkxjFC.mjs → node/esm/cNTNUggnKXPO1Ebs.mjs} +1 -1
  58. package/node/esm/index.mjs +3607 -1998
  59. package/package.json +3 -3
  60. package/types/src/.generated/decl/financial/Annuity.decl.d.ts +5 -0
  61. package/types/src/.generated/decl/financial/{Financial.decl.d.ts → Cashflow.decl.d.ts} +1 -1
  62. package/types/src/.generated/decl/financial/Convert.decl.d.ts +4 -0
  63. package/types/src/.generated/decl/financial/Coupon.decl.d.ts +4 -0
  64. package/types/src/.generated/decl/financial/{Financial2.decl.d.ts → Depreciation.decl.d.ts} +1 -1
  65. package/types/src/.generated/decl/financial/Growth.decl.d.ts +4 -0
  66. package/types/src/.generated/decl/financial/{ODD.decl.d.ts → Odd.decl.d.ts} +1 -1
  67. package/types/src/.generated/decl/financial/{Financial3.decl.d.ts → STOCKHISTORY.decl.d.ts} +1 -1
  68. package/types/src/.generated/decl/financial/Security.decl.d.ts +4 -0
  69. package/types/src/.generated/decl/financial/{Financial4.decl.d.ts → SecurityMaturity.decl.d.ts} +1 -1
  70. package/types/src/.generated/decl/{statistical/TTEST.decl.d.ts → financial/TBill.decl.d.ts} +1 -1
  71. package/types/src/.generated/decl/statistical/{ETS.decl.d.ts → Ets.decl.d.ts} +1 -1
  72. package/types/src/.generated/decl/statistical/TTest.decl.d.ts +4 -0
  73. package/types/src/.generated/desc/financial/Annuity.desc.d.ts +5 -0
  74. package/types/src/.generated/desc/financial/{Financial.desc.d.ts → Cashflow.desc.d.ts} +1 -1
  75. package/types/src/.generated/desc/financial/Convert.desc.d.ts +4 -0
  76. package/types/src/.generated/desc/financial/Coupon.desc.d.ts +4 -0
  77. package/types/src/.generated/desc/financial/{Financial2.desc.d.ts → Depreciation.desc.d.ts} +1 -1
  78. package/types/src/.generated/desc/financial/Growth.desc.d.ts +4 -0
  79. package/types/src/.generated/desc/financial/{ODD.desc.d.ts → Odd.desc.d.ts} +1 -1
  80. package/types/src/.generated/desc/financial/{Financial3.desc.d.ts → STOCKHISTORY.desc.d.ts} +1 -1
  81. package/types/src/.generated/desc/financial/Security.desc.d.ts +4 -0
  82. package/types/src/.generated/desc/financial/{Financial4.desc.d.ts → SecurityMaturity.desc.d.ts} +1 -1
  83. package/types/src/.generated/desc/{statistical/TTEST.desc.d.ts → financial/TBill.desc.d.ts} +1 -1
  84. package/types/src/.generated/desc/statistical/{ETS.desc.d.ts → Ets.desc.d.ts} +1 -1
  85. package/types/src/.generated/desc/statistical/TTest.desc.d.ts +4 -0
  86. package/types/src/_utils/AnyArgs.d.ts +17 -3
  87. package/types/src/_utils/FinanaceSolver.d.ts +39 -2
  88. package/types/src/_utils/FinanceAmor.d.ts +23 -0
  89. package/types/src/_utils/FinanceCashflow.d.ts +42 -0
  90. package/types/src/_utils/FinanceCoupon.d.ts +92 -82
  91. package/types/src/_utils/FinanceDate.d.ts +24 -0
  92. package/types/src/_utils/FinanceDayCount.d.ts +46 -0
  93. package/types/src/_utils/FinanceOdd.d.ts +93 -0
  94. package/types/src/_utils/FinanceSecurity.d.ts +84 -0
  95. package/types/src/_utils/FinanceUtils.d.ts +34 -0
  96. package/types/src/_utils/LeastSquares.d.ts +20 -22
  97. package/types/src/_utils/RegexCompile.d.ts +33 -0
  98. package/types/src/cube/Cube.d.ts +7 -7
  99. package/types/src/financial/ACCRINT.d.ts +33 -6
  100. package/types/src/financial/AMORDEGRC.d.ts +22 -40
  101. package/types/src/financial/Annuity.d.ts +118 -0
  102. package/types/src/financial/Cashflow.d.ts +84 -0
  103. package/types/src/financial/Convert.d.ts +26 -0
  104. package/types/src/financial/Coupon.d.ts +72 -0
  105. package/types/src/financial/Date.d.ts +34 -5
  106. package/types/src/financial/Depreciation.d.ts +58 -0
  107. package/types/src/financial/Growth.d.ts +22 -0
  108. package/types/src/financial/Odd.d.ts +82 -0
  109. package/types/src/financial/STOCKHISTORY.d.ts +17 -0
  110. package/types/src/financial/Security.d.ts +68 -0
  111. package/types/src/financial/SecurityMaturity.d.ts +107 -0
  112. package/types/src/financial/TBill.d.ts +40 -0
  113. package/types/src/financial/VDB.d.ts +15 -13
  114. package/types/src/statistical/{ETS.d.ts → Ets.d.ts} +14 -14
  115. package/types/src/statistical/Regression.d.ts +13 -18
  116. package/types/src/statistical/{TTEST.d.ts → TTest.d.ts} +5 -5
  117. package/types/src/text/RegEx.d.ts +34 -11
  118. package/browser/cjs/B4JJfKSI4ppwU855.cjs +0 -1
  119. package/browser/cjs/BwLx9ix5Sq7suAYP.cjs +0 -1
  120. package/browser/cjs/Clu7XiAsCB48GDXN.cjs +0 -1
  121. package/browser/cjs/DsFZgtSQpC75d1M0.cjs +0 -1
  122. package/browser/cjs/fqTQ_p3ehzUvc1tF.cjs +0 -1
  123. package/browser/cjs/h3dw1jAp2J5Pu4p3.cjs +0 -1
  124. package/browser/cjs/jev6VGWTdgEgm4Yk.cjs +0 -1
  125. package/browser/esm/CwoMEzOtRihuYUTr.mjs +0 -20
  126. package/browser/esm/Dy6UD7hQRBsT0WNp.mjs +0 -304
  127. package/node/esm/CwoMEzOtRihuYUTr.mjs +0 -20
  128. package/node/esm/Dy6UD7hQRBsT0WNp.mjs +0 -304
  129. package/types/src/financial/Financial.d.ts +0 -288
  130. package/types/src/financial/Financial2.d.ts +0 -99
  131. package/types/src/financial/Financial3.d.ts +0 -95
  132. package/types/src/financial/Financial4.d.ts +0 -82
  133. package/types/src/financial/ODD.d.ts +0 -106
@@ -77,4 +77,50 @@ export declare function getDayCount(startSerial: number, endSerial: number, basi
77
77
  *
78
78
  */
79
79
  export declare function getDays360US(startSerial: number, endSerial: number): number;
80
+ /** The last serial of the 1900 calendar (9999-12-31). */
81
+ export declare const MAX_SERIAL_DATE = 2958465;
82
+ /**
83
+ * Excel's date-slot domain for the day-count family, measured on DAYS360, YEARFRAC, DATEDIF
84
+ * and the six coupon functions (fn-battery financial/*, 2026-08-28): the RAW value must not be
85
+ * negative (`-1E-9` is #NUM!) and the truncated serial must not pass 9999-12-31 (`2958465.9` is
86
+ * a legal 9999-12-31). The fraction is otherwise discarded by every function in the family.
87
+ */
88
+ export declare function isSerialDateInRange(serial: number): boolean;
89
+ /**
90
+ * `YEARFRAC` — measured against Excel 16.0 (fn-battery financial/YEARFRAC, 2026-08-28). Both
91
+ * serials are truncated first, the earlier date becomes the start, and basis 0 is then the
92
+ * SIGNED NASD count: Excel orders the dates but never takes a magnitude, so
93
+ * `YEARFRAC(59,60,0)` — 1900-02-28, a real month end, against the phantom 1900-02-29 that is
94
+ * not — is `-1/360`. The other bases cannot go negative once ordered. The caller has validated
95
+ * the serials and the basis.
96
+ */
97
+ export declare function getYearFrac(startSerial: number, endSerial: number, basis: number): number;
98
+ /**
99
+ * The years to maturity a bond-yield ITERATION starts from — not `YEARFRAC`, and not the coupon
100
+ * count over the frequency. Whole years are stepped off the settlement (the day clamped to each
101
+ * destination month) and the remainder is the basis's own day count over the basis's year: the
102
+ * 30/360 counts over 360 at bases 0 and 4, real days over 360 at basis 2 and over 365 at basis 3,
103
+ * and real days over the MATURITY'S OWN year at basis 1 — 366 out of a leap year, whatever the
104
+ * remainder itself covers. Basis 0's February here is the LEGACY calendar's: a Feb 29 start is a
105
+ * month end and a Feb 28 is not, which is neither `getDayCount`'s rule (the real calendar's month
106
+ * end, so Feb 28 counts too) nor `getDays360US`'s (which also lets the conversion steer the end).
107
+ *
108
+ * Measured on 1,154 rows where the answer depends on nothing else (fn-battery
109
+ * financial/adhoc-yield-n, -n2, -n3), 2026-09-09.
110
+ *
111
+ * Used by: YIELD, ODDFYIELD.
112
+ */
113
+ export declare function getYearsToMaturity(settlement: number, maturity: number, basis: number): number;
114
+ /**
115
+ * The stub-period day count of AMORLINC/AMORDEGRC (the year fraction is `days / yearDays`, and
116
+ * the caller groups that as Excel does) — measured against Excel 16.0 (fn-battery
117
+ * financial/AMORLINC, /AMORDEGRC, 2026-08-28), and NOT YEARFRAC's: serials are truncated, the
118
+ * 30/360 bases count days as `getDayCount` does over 360, basis 3 is actual days over 365, and
119
+ * basis 1 is actual days over the length of the PURCHASE year (366 only when that year is a
120
+ * Gregorian leap year — 1900 is not — whatever the span crosses; 2007-12-31 → 2008-12-31 is
121
+ * 366/365), and in both actual bases a real Feb 29 counts as the 28th (`_feb29AsFeb28`). A zero-day stub is a whole period (`purchase = first period`, or Dec 30 → Dec 31
122
+ * at basis 0), and a stub longer than a year is not capped. Basis 2 is not accepted by either
123
+ * function; the caller has refused it before this is called.
124
+ */
125
+ export declare function getAmorDayCount(purchased: number, firstPeriod: number, basis: number): DayCount;
80
126
  //# sourceMappingURL=FinanceDayCount.d.ts.map
@@ -0,0 +1,93 @@
1
+ import { Omittable, Scalar } from '@sheetxl/primitives';
2
+ /**
3
+ * The odd-coupon securities' shared machinery — the quasi-coupon chain of an irregular period
4
+ * and the day-count sums the price and yield forms are built from, measured against Excel 16.0
5
+ * (fn-battery financial/ODDLPRICE + /ODDLYIELD + /ODDFPRICE and the `adhoc-oddl-*` /
6
+ * `adhoc-oddf-*` probes, 2026-08-28/29).
7
+ */
8
+ /**
9
+ * `(settlement, maturity, …dates, …numbers, frequency, [basis])` as the four ODD functions read
10
+ * it: every slot is Excel-declared `any` (a boolean is #VALUE!, an empty argument #N/A, a blank
11
+ * cell 0, a multi-cell reference does not broadcast — `NoLift<>` on every slot), and the order is
12
+ * coupon six's, not PRICE's. Each DATE is coerced and range-checked as it is read, so a negative
13
+ * `last_interest` is #NUM! over a text frequency; then the numbers are coerced; then the
14
+ * frequency is validated (1, 2 or 4 after truncation); then the BASIS, last. Only after all of
15
+ * that do the date ORDER and the signs decide — a text frequency beats a settlement that is
16
+ * after its maturity. Serials come back truncated.
17
+ */
18
+ export declare function readOddArgs(dates: Omittable<Scalar>[], numbers: Omittable<Scalar>[], frequency: Omittable<Scalar>, basis: Omittable<Scalar>): {
19
+ dates: number[];
20
+ numbers: number[];
21
+ frequency: number;
22
+ basis: number;
23
+ };
24
+ /**
25
+ * The three day-count sums of the odd LAST period `[lastInterest, maturity]`, in coupon-period
26
+ * units — the numbers ODDLPRICE and ODDLYIELD are built from. Measured on 1,780
27
+ * (shape, frequency, basis) triples, each sum exact (`fn-battery/financial/fit-oddl.mjs`).
28
+ *
29
+ * It takes TWO chains, as COUPDAYS' basis 1 did (batch 3): the DECAYING chain anchored at
30
+ * `lastInterest` gives the period ends and their lengths, while the STICKY chain decides only
31
+ * which period the maturity lands in — so an Aug 31 maturity against a decayed Aug 28 boundary
32
+ * is still inside the period that ENDS there and overhangs it by three days.
33
+ *
34
+ * Over the periods `[B₀ = lastInterest, B₁] … [B_{J−1}, B_J]`:
35
+ *
36
+ * - `A` and `DSC` walk their span (`lastInterest → settlement`, `settlement → maturity`) period
37
+ * by period, no period contributing more than itself — a 31st period end counted raw runs one
38
+ * day past its own length.
39
+ * - `DC` counts every period 1 except the last, which is measured BACKWARD from its end,
40
+ * `(NL − count(maturity, B_J)) / NL`. That is what makes `DC ≠ A + DSC` at basis 0.
41
+ *
42
+ * A chain that leaves the calendar is #NUM!: past its end going forward, and — stepping BACK
43
+ * from the MATURITY to the first date at or below `lastInterest` — below serial 1 going back
44
+ * (measured: a ladder landing on serial 1 computes, one landing on serial 0 is #NUM!).
45
+ */
46
+ export declare function oddLastSums(settlement: number, maturity: number, lastInterest: number, frequency: number, basis: number): {
47
+ A: number;
48
+ DC: number;
49
+ DSC: number;
50
+ };
51
+ /**
52
+ * The numbers ODDFPRICE's form is built from — `N` regular coupons after `firstCoupon`, the
53
+ * accrued sum `A` and the first coupon's sum `DC` (both in coupon-period units), and `u`, the
54
+ * fractional exponent every cash flow after the settlement is discounted by. Measured on 1,125
55
+ * (shape, frequency, basis) triples, the four sums solved out of Excel by linearity
56
+ * (`fn-battery/financial/oddf-model.mjs`, `verify-oddf.mjs`, `adhoc-oddf-*`, 2026-08-29).
57
+ *
58
+ * The maturity must sit on `firstCoupon`'s grid — `COUPPCD(firstCoupon, maturity) = firstCoupon`
59
+ * — and the doc's two branches are real, on DIFFERENT date machinery. `E` is the regular period
60
+ * around the settlement on that grid, PRICE's {@link couponPeriod} (`COUPDAYBS + COUPDAYSNC` at
61
+ * basis 1); `DFC` the basis's count issue → firstCoupon:
62
+ *
63
+ * - `DFC = E` is #NUM! — an odd period that is exactly a regular one.
64
+ * - SHORT (`DFC < E`): one period, every count over `E` — `A = issue→settlement`, `DC = DFC`,
65
+ * `u = settlement→firstCoupon`, the last straight from the settlement (the NASD advance
66
+ * included). `N` is `COUPNUM(settlement, maturity) − 1`, which counts a grid date between the
67
+ * settlement and the first coupon when there is one (a settlement in the gap between a
68
+ * decayed boundary and its sticky twin).
69
+ * - LONG (`DFC > E`): `COUPNUM(issue, firstCoupon)` quasi periods on the STICKY grid, their
70
+ * boundaries walked DECAYED back from `firstCoupon` (each step subtracts `12/f` months from
71
+ * the previous date and clamps: an Aug 31 anchor semiannual is Feb 28, then Aug 28) — so the
72
+ * earliest period can end at or before the issue and count nothing. `NL` is each period's
73
+ * own actual span at basis 1, `360/f` or `365/f` elsewhere; `A` walks issue → settlement as
74
+ * days over `NL`; `DC` is the issue's period as days over `NL` and every later period exactly
75
+ * 1 (the doc's DCᵢ — visible at bases 2 and 3). The exponent `u = Nq + DSC/E` is on the
76
+ * sticky grid instead: `DSC = E − COUPDAYBS` at bases 0/1/4 and the actual days to the next
77
+ * grid date at 2/3, and `Nq` is `COUPNUM(settlement, firstCoupon) − 1` PLUS ONE on a
78
+ * month-end first coupon — Excel discounts every cash flow one period too far — unless the
79
+ * settlement is itself a month end or its month holds an earlier quasi-coupon date
80
+ * (`adhoc-oddf-nq`, 957 settlements swept day by day).
81
+ *
82
+ * A chain that walks below the calendar is #NUM! in either branch (a settlement in the first
83
+ * days of 1900 has quasi dates in 1899).
84
+ */
85
+ export declare function oddFirstSums(settlement: number, maturity: number, issue: number, firstCoupon: number, frequency: number, basis: number): {
86
+ N: number;
87
+ A: number;
88
+ DC: number;
89
+ u: number;
90
+ };
91
+ /** The ATP arithmetic of the family: a product that overflowed is 0 (batch 4's `overflowIsZero`). */
92
+ export declare const zeroIfOverflow: (value: number) => number;
93
+ //# sourceMappingURL=FinanceOdd.d.ts.map
@@ -0,0 +1,84 @@
1
+ import { Omittable, Scalar } from '@sheetxl/primitives';
2
+ /**
3
+ * Argument readers for the securities functions — every slot Excel-declared `any`, read in the
4
+ * order Excel reads them (measured against Excel 16.0, fn-battery financial/*, 2026-08-28).
5
+ *
6
+ * Two orders exist in the family. The discount securities (DISC PRICEDISC YIELDDISC INTRATE
7
+ * RECEIVED) CONVERT from the last slot to the first and only then look for errors in slot
8
+ * order; ACCRINTM, ACCRINT and the coupon functions convert and validate each slot from the
9
+ * first. Each function names its own.
10
+ */
11
+ /** The basis slot: omitted or blank is 0, text parses, a boolean is #VALUE!, out of 0–4 after truncation is #NUM!. */
12
+ export declare function readBasis(basis: Omittable<Scalar>): number;
13
+ /** The two dates of a security, truncated, both in the calendar and the settlement strictly first — else #NUM!. */
14
+ export declare function checkDateOrder(settlement: number, maturity: number): {
15
+ settlement: number;
16
+ maturity: number;
17
+ };
18
+ /**
19
+ * `(settlement, maturity, x, y, [basis])` as DISC, PRICEDISC, YIELDDISC, INTRATE and RECEIVED
20
+ * read it: the basis FIRST — coerced and range-checked, so a text basis is #VALUE!, a basis of 5
21
+ * is #NUM! and an error there is the answer whatever an earlier slot holds — then the four
22
+ * slots from the first, each coerced (its error or a text answered) before the next is read;
23
+ * then the domain: serials in the calendar, `settlement < maturity` once truncated, `x > 0`,
24
+ * `y > 0`. An omitted required slot is #N/A, a blank cell 0.
25
+ */
26
+ export declare function readDiscountArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, x: Omittable<Scalar>, y: Omittable<Scalar>, basis: Omittable<Scalar>): {
27
+ settlement: number;
28
+ maturity: number;
29
+ x: number;
30
+ y: number;
31
+ basis: number;
32
+ };
33
+ /**
34
+ * `(settlement, maturity, x)` as TBILLEQ, TBILLPRICE and TBILLYIELD read it: each slot coerced
35
+ * from the first (an error or a text is answered before the next slot is read, so a text `x`
36
+ * beats swapped dates), then the domain: both serials in the calendar, `settlement < maturity`
37
+ * once truncated, the maturity at most one calendar year out ({@link _anniversary}), `x > 0`.
38
+ * `days` is the actual span of the truncated serials.
39
+ */
40
+ export declare function readTbillArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, x: Omittable<Scalar>): {
41
+ settlement: number;
42
+ maturity: number;
43
+ x: number;
44
+ days: number;
45
+ };
46
+ /**
47
+ * `(settlement, maturity, issue, rate, x, [basis])` as PRICEMAT and YIELDMAT read it: the basis
48
+ * first (coerced and range-checked, so a text basis is #VALUE! and a basis of 5 #NUM! whatever
49
+ * the other slots hold, and an error there wins), then the five slots from the first, each
50
+ * coerced before the next is read; then the domain — every serial in the calendar,
51
+ * `issue < settlement < maturity` once truncated, and the signs the caller checks. The three
52
+ * day counts come back with `DSM` as `DIM − A`, which is how Excel has it: at basis 0 a Feb 28
53
+ * settlement against a Mar 31 maturity counts 32 days inside a Jan 31 issue (60 − 28), where
54
+ * the NASD count of the pair alone is 31. `B` is the year length of the issue→settlement pair.
55
+ */
56
+ export declare function readMatArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, issue: Omittable<Scalar>, rate: Omittable<Scalar>, x: Omittable<Scalar>, basis: Omittable<Scalar>): {
57
+ rate: number;
58
+ x: number;
59
+ DIM: number;
60
+ DSM: number;
61
+ A: number;
62
+ B: number;
63
+ };
64
+ /**
65
+ * `(settlement, maturity, …numbers, frequency, [basis])` as PRICE, YIELD, DURATION and
66
+ * MDURATION read it (measured on all four, fn-battery 2026-08-28). PRICE and YIELD read the
67
+ * basis FIRST — coerced and range-checked, so a text basis is #VALUE! and a 5 is #NUM! whatever
68
+ * else is wrong, and an error there wins over an error in the settlement; DURATION and
69
+ * MDURATION read it LAST (`basisLast`), the coupon functions' way. In between, the settlement
70
+ * and the maturity are each coerced and checked against the calendar before the next slot is
71
+ * read (a negative settlement is #NUM! over a text frequency), then the numeric slots are
72
+ * coerced, then the frequency is coerced and validated (1, 2 or 4 after truncation); the date
73
+ * order (`settlement < maturity` once truncated) and the signs of the numbers come last.
74
+ */
75
+ export declare function readBondArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, numbers: Omittable<Scalar>[], frequency: Omittable<Scalar>, basis: Omittable<Scalar>, basisLast?: boolean): {
76
+ settlement: number;
77
+ maturity: number;
78
+ numbers: number[];
79
+ frequency: number;
80
+ basis: number;
81
+ };
82
+ /** Excel's Analysis-ToolPak arithmetic answers 0 for a product that overflowed (measured on ACCRINTM, TBILLEQ, TBILLPRICE, PRICEMAT). */
83
+ export declare const overflowIsZero: (value: number) => number;
84
+ //# sourceMappingURL=FinanceSecurity.d.ts.map
@@ -1,4 +1,25 @@
1
1
  import { IRuntime } from '@sheetxl/primitives';
2
+ /**
3
+ * The secant step cap shared by RATE and IRR — Excel gives up after 200, not the documented 20
4
+ * (measured on one 24-period loan: a path of 200 steps converges, one of 203 is #NUM!). IRR runs
5
+ * the same iteration on the discount factor rather than the rate, so the cap is one fact.
6
+ */
7
+ export declare const RATE_MAX_ITERATIONS = 200;
8
+ /**
9
+ * The currency format Excel gives a financial result cell, in the runtime's locale.
10
+ *
11
+ * @remarks
12
+ * Which functions auto-format is a per-function fact and was MEASURED across the category
13
+ * (2026-08-29, `Range.NumberFormat` read after a `Formula2` entry into a General cell): the
14
+ * legacy core formats by result kind — money through this helper (NPV PMT IPMT PPMT FV PV SLN
15
+ * SYD DB DDB VDB) and a rate as `0%` (IRR MIRR RATE) — while everything ATP-era or added later
16
+ * sets nothing at all (XIRR XNPV NPER ISPMT RRI PDURATION EFFECT NOMINAL FVSCHEDULE CUMIPMT
17
+ * CUMPRINC and every security, COUPNCD and COUPPCD included).
18
+ *
19
+ * Excel applies it at ENTRY, before it knows the answer, so a `#NUM!`, `#VALUE!` or `#DIV/0!`
20
+ * cell carries the format too. That is why every `formatResults` call in this category LEADS its
21
+ * body instead of following the domain guards.
22
+ */
2
23
  export declare const defaultCurrencyFormat: (runtime: IRuntime) => string;
3
24
  /**
4
25
  * `base ^ exponent` as Excel evaluates it (the `^` operator, POWER, and the powers inside the
@@ -17,4 +38,17 @@ export declare const defaultCurrencyFormat: (runtime: IRuntime) => string;
17
38
  * A zero base follows the `^` operator: `0^0` is #NUM! and `0^negative` is #DIV/0!.
18
39
  */
19
40
  export declare const excelPow: (base: number, exponent: number) => number;
41
+ /**
42
+ * Excel's C `(int)` cast of an argument: truncation toward zero, and INT_MIN for anything out of
43
+ * the 32-bit range (the x64 `cvttsd2si` convention), NaN included. Measured on DB (fn-battery,
44
+ * 2026-08-28): `DB(…,3E9,2E9)` is #NUM! because only `life` overflows to INT_MIN while
45
+ * `DB(…,1E10,5E9)` is 0 because both do.
46
+ */
47
+ export declare const excelInt32: (value: number) => number;
48
+ /**
49
+ * Round to `digits` decimals as Excel's ROUND does: ties away from zero, decided on the value's
50
+ * 15-significant-digit decimal form rather than its binary one — `550 · 0.45` is
51
+ * 247.49999999999997 in double and Excel rounds it to 248 (AMORDEGRC, measured 2026-08-28).
52
+ */
53
+ export declare const excelRound: (value: number, digits?: number) => number;
20
54
  //# sourceMappingURL=FinanceUtils.d.ts.map
@@ -1,4 +1,4 @@
1
- import { FormulaError, IRange } from '@sheetxl/primitives';
1
+ import { FormulaError, IRange, IReferenceRange, Scalar } from '@sheetxl/primitives';
2
2
  /**
3
3
  * How Excel reads `known_y` / `known_x` into (observations x predictors).
4
4
  *
@@ -33,15 +33,22 @@ export interface RegressionData {
33
33
  /**
34
34
  * Reads `known_y` / `known_x` the way the whole LINEST family does.
35
35
  *
36
- * STRICT membership: any non-numeric member of either range — text, boolean, or BLANK — is
37
- * `#VALUE!`. There is no skipping and no coercion here (`LINEST({2;TRUE;5;4}, …)` and
38
- * `LINEST({2;"3";5;4}, …)` are both `#VALUE!`), which is the opposite of the paired statistics
39
- * (CORREL/SLOPE/…) where a non-numeric member drops its pair. Dropping a member here would shift
40
- * every later observation against its x and silently return a different fit.
36
+ * The SHAPES are judged first — a mismatch is #REF! whatever the members hold — and then the
37
+ * members, in order. Membership is STRICT: any non-numeric member of either range — text,
38
+ * boolean, or BLANK — is `#VALUE!`. There is no skipping and no coercion here
39
+ * (`LINEST({2;TRUE;5;4}, …)` and `LINEST({2;"3";5;4}, …)` are both `#VALUE!`), which is the
40
+ * opposite of the paired statistics (CORREL/SLOPE/…) where a non-numeric member drops its pair.
41
+ * Dropping a member here would shift every later observation against its x and silently return a
42
+ * different fit.
41
43
  *
42
- * @throws #VALUE! on a non-numeric member, #REF! on a dimension mismatch.
44
+ * `log` is the LOGEST/GROWTH read: each y is checked as it is met, so a y at or below zero is
45
+ * #NUM! even when a text member sits later in the range, and the ys come back as their logarithms.
46
+ *
47
+ * @throws #VALUE! on a non-numeric member, #REF! on a dimension mismatch, #NUM! on a y without a
48
+ * logarithm.
43
49
  */
44
- export declare const readRegressionData: (knownYs: IRange, knownXs: IRange | undefined) => RegressionData;
50
+ export declare const readRegressionData: (knownYs: IRange, knownXs: IRange | undefined, log?: boolean) => RegressionData;
51
+ export declare const overLogical: (value: boolean | IReferenceRange | IReferenceRange[] | null | undefined, absent: boolean, compute: (value: boolean) => Scalar[][]) => Scalar[][];
45
52
  /**
46
53
  * Reads a `new_x` range into (observations x k), and reports the shape its predictions spill into.
47
54
  *
@@ -57,15 +64,6 @@ export declare const readNewX: (newXs: IRange, data: RegressionData) => {
57
64
  rows: number;
58
65
  cols: number;
59
66
  };
60
- /**
61
- * `ln(y)` for the log-space members of the family (LOGEST / GROWTH).
62
- *
63
- * A y at or below zero has no logarithm, and Excel reports that as #NUM! — a distinct outcome from
64
- * the #VALUE! a non-numeric member gets, so the two checks stay separate.
65
- *
66
- * @throws #NUM! when any y is <= 0.
67
- */
68
- export declare const toLogYs: (ys: number[]) => number[];
69
67
  /**
70
68
  * Evaluates a fit over `new_x`, in the shape Excel spills.
71
69
  *
@@ -73,7 +71,7 @@ export declare const toLogYs: (ys: number[]) => number[];
73
71
  * the fitted values, so a 6x2 `known_y` spills 6x2. Otherwise the shape comes from `new_x`
74
72
  * ({@link readNewX} decides whether that is element-wise or one row/column per observation).
75
73
  */
76
- export declare const predictInShape: (data: RegressionData, newXs: IRange | undefined, predict: (x: number[]) => number) => number[][];
74
+ export declare const predictInShape: (data: RegressionData, newXs: IRange | undefined, predict: (x: number[]) => Scalar) => Scalar[][];
77
75
  /** A fitted model — coefficients in Excel's slot order plus everything the stats grid needs. */
78
76
  export interface RegressionFit {
79
77
  /**
@@ -81,11 +79,11 @@ export interface RegressionFit {
81
79
  * belongs to the LAST column of `known_x`.
82
80
  */
83
81
  coefficients: number[];
84
- /** Standard errors in the same slot order. `se[k]` is meaningless when `!useConst` (Excel: #N/A). */
82
+ /** Standard errors in the same slot order. `se[k]` is meaningless when `!constant` (Excel: #N/A). */
85
83
  standardErrors: number[];
86
84
  /** Number of predictors actually used — a column dropped for rank deficiency does not count. */
87
85
  kEffective: number;
88
- /** `n - kEffective - (useConst ? 1 : 0)`. */
86
+ /** `n - kEffective - (constant ? 1 : 0)`. */
89
87
  df: number;
90
88
  /** Standard error of the y estimate. 0 when `df <= 0`, which is what Excel returns. */
91
89
  sey: number;
@@ -111,7 +109,7 @@ export interface RegressionFit {
111
109
  * The same path covers "not enough observations": with n = 2 and 2 predictors the second column
112
110
  * has no residual left and is dropped, which is exactly what Excel returns.
113
111
  */
114
- export declare const fitLeastSquares: (ys: number[], xs: number[][], useConst: boolean) => RegressionFit;
112
+ export declare const fitLeastSquares: (ys: number[], xs: number[][], constant: boolean) => RegressionFit;
115
113
  /**
116
114
  * The `stats = TRUE` grid: 5 rows x (k + 1) columns.
117
115
  *
@@ -127,5 +125,5 @@ export declare const fitLeastSquares: (ys: number[], xs: number[][], useConst: b
127
125
  * `se(b)` when the intercept was not fitted — the b slot itself still carries a value (0 for
128
126
  * LINEST, 1 for LOGEST), it is only its error that is #N/A.
129
127
  */
130
- export declare const buildStatsGrid: (fit: RegressionFit, coefficients: number[], useConst: boolean) => (number | FormulaError.Known)[][];
128
+ export declare const buildStatsGrid: (fit: RegressionFit, coefficients: (number | FormulaError.Known)[], constant: boolean) => (number | FormulaError.Known)[][];
131
129
  //# sourceMappingURL=LeastSquares.d.ts.map
@@ -0,0 +1,33 @@
1
+ import { FormulaError } from '@sheetxl/primitives';
2
+ /** A compiled Excel pattern: the regex, and how many capture groups it has. */
3
+ export interface CompiledPattern {
4
+ regex: RegExp;
5
+ groups: number;
6
+ }
7
+ /**
8
+ * Compiles one of Excel's patterns, or `#VALUE!` when neither reading of it will compile.
9
+ *
10
+ * The translated form is tried first, under `u`. A pattern that will not compile that way is
11
+ * retried EXACTLY AS WRITTEN and without `u` — that is the pre-translation reading, and it keeps
12
+ * the patterns that only `u`'s stricter escaping would have broken (`\-` outside a class) working.
13
+ */
14
+ export declare const compilePattern: (pattern: string, caseInsensitive: boolean, extraFlags?: string) => CompiledPattern | FormulaError.Known;
15
+ /**
16
+ * Excel's replacement text, as JavaScript's.
17
+ *
18
+ * The two languages nearly agree — `$1`, `$&`, `` $` `` and `$'` mean the same in both — and
19
+ * differ in three places: Excel's `$0` is the whole match (JavaScript spells that `$&`), its
20
+ * `${1}` and `${name}` are references where JavaScript reads them literally, and a reference to a
21
+ * group that does not exist is `#VALUE!` rather than literal text. That last one is why this
22
+ * returns an error instead of a string: `REGEXREPLACE("ab","(a)(b)","$3")` is refused by Excel,
23
+ * and so is a lone `$`.
24
+ */
25
+ export declare const translateReplacement: (replacement: string, groups: number) => string | FormulaError.Known;
26
+ /**
27
+ * Excel's 0-or-1 enum slots (`caseSensitivity`, and `returnMode`'s three values).
28
+ *
29
+ * Truncated first — 1.5 is 1 — and anything outside the list is `#VALUE!`, including a huge value
30
+ * and non-numeric text.
31
+ */
32
+ export declare const readMode: (value: number, max: number) => number | FormulaError.Known;
33
+ //# sourceMappingURL=RegexCompile.d.ts.map
@@ -1,6 +1,6 @@
1
1
  /**
2
+ * Returns a key performance indicator (KPI) property and displays the KPI name in the cell.
2
3
  * @hidden Unimplemented Cube
3
- * @summary Returns a key performance indicator (KPI) property and displays the KPI name in the cell.
4
4
  * @param connection is the name of a connection to an OLAP cube.
5
5
  * @param kpiName is the KPI name.
6
6
  * @param kpiProperty is the KPI property.
@@ -9,24 +9,24 @@
9
9
  export declare function CUBEKPIMEMBER(connection: string, kpiName: string, kpiProperty: number, // option 1-6
10
10
  caption?: string): Promise<string>;
11
11
  /**
12
+ * Returns a member or tuple from the cube.
12
13
  * @hidden Unimplemented Cube
13
- * @summary Returns a member or tuple from the cube.
14
14
  * @param connection is the name of a connection to an OLAP cube.
15
15
  * @param memberExpression is the expression representing the name of a member or tuple in the OLAP cube.
16
16
  * @param caption is the caption to be displayed in the cell.
17
17
  */
18
18
  export declare function CUBEMEMBER(connection: string, memberExpression: string, caption?: string): Promise<string>;
19
19
  /**
20
+ * Returns the value of a member property from the cube.
20
21
  * @hidden Unimplemented Cube
21
- * @summary Returns the value of a member property from the cube.
22
22
  * @param connection is the name of a connection to an OLAP cube.
23
23
  * @param memberExpression is the expression representing the name of a member in the OLAP cube.
24
24
  * @param kpiProperty is the property name.
25
25
  */
26
26
  export declare function CUBEMEMBERPROPERTY(connection: string, memberExpression: string, kpiProperty: number): Promise<string>;
27
27
  /**
28
+ * Returns the nth, or ranked, member in a set.
28
29
  * @hidden Unimplemented Cube
29
- * @summary Returns the nth, or ranked, member in a set.
30
30
  * @param connection is the name of a connection to an OLAP cube.
31
31
  * @param setExpression is the set from which the element is to be retrieved.
32
32
  * @param rank is the rank of the element to be retrieved.
@@ -35,8 +35,8 @@ export declare function CUBEMEMBERPROPERTY(connection: string, memberExpression:
35
35
  export declare function CUBERANKEDMEMBER(connection: string, setExpression: string, rank: number, // 1 - 5
36
36
  caption?: string): Promise<string>;
37
37
  /**
38
+ * Defines a calculated set of members or tuples by sending a set expression to the cube on the server, which creates the set, and then returns that set to Microsoft Excel.
38
39
  * @hidden Unimplemented Cube
39
- * @summary Defines a calculated set of members or tuples by sending a set expression to the cube on the server, which creates the set, and then returns that set to Microsoft Excel.
40
40
  * @param connection is the name of a connection to an OLAP cube.
41
41
  * @param setExpression is the expression for the set.
42
42
  * @param caption is the caption to be displayed in the cell.
@@ -49,14 +49,14 @@ caption?: string): Promise<string>;
49
49
  export declare function CUBESET(connection: string, setExpression: string, caption?: string, sortOrder?: number, // 1 - 6
50
50
  sortBy?: string): Promise<string>;
51
51
  /**
52
+ * Returns the number of items in a set.
52
53
  * @hidden Unimplemented Cube
53
- * @summary Returns the number of items in a set.
54
54
  * @param set is the set whose elements are to be counted.
55
55
  */
56
56
  export declare function CUBESETCOUNT(set: string): Promise<number>;
57
57
  /**
58
+ * Returns an aggregated value from the cube.
58
59
  * @hidden Unimplemented Cube
59
- * @summary Returns an aggregated value from the cube.
60
60
  * @param connection is the name of a connection to an OLAP cube.
61
61
  * @param memberExpression is a slicer that determines the portion of the OLAP cube for which the aggregation value is to be retrieved.
62
62
  */
@@ -1,5 +1,6 @@
1
+ import { AcceptError, Omittable, Scalar, NoLift } from '@sheetxl/primitives';
1
2
  /**
2
- * @summary Returns the accrued interest for a security that pays periodic interest.
3
+ * Returns the accrued interest for a security that pays periodic interest.
3
4
  * @param issue is the security's issue date, expressed as a serial date number.
4
5
  * @param firstInterest is the security's first interest date, expressed as a serial date number.
5
6
  * @param settlement is the security's settlement date, expressed as a serial date number.
@@ -10,10 +11,36 @@
10
11
  * @param calcMethod is a logical value: to accrued interest from issue date = TRUE; to calculate from last coupon payment date = FALSE.
11
12
  *
12
13
  * @remarks
13
- * {@link https://support.microsoft.com/en-us/office/accrint-function-fe45d089-6722-4fb3-9379-e1f911d8dc74|Docs}
14
+ * `par · rate/frequency · Σ(Aᵢ/NLᵢ)` over the quasi-coupon periods anchored at `first_interest`,
15
+ * as Excel 16.0 composes it (fn-battery financial/ACCRINT and adhoc-accrint-clamped, 1,796 rows,
16
+ * 2026-08-28 / 2026-09-09) — see {@link accruedPeriods}.
17
+ * The seven leading slots are Excel-declared `any` (a boolean is #VALUE!, an empty slot #N/A —
18
+ * except `par`, which is 1000 when omitted — a blank cell 0); `calc_method` is a logical read
19
+ * FIRST: any number is accepted (nonzero is TRUE), text — `"TRUE"` included — is #VALUE!. Then
20
+ * the slots are read from the first, each coerced and validated before the next (a negative
21
+ * issue is #NUM! over a text frequency, a frequency of 3 over a text basis): every date in the
22
+ * calendar, the frequency 1/2/4 and the basis 0–4 after truncation; then `issue < settlement`,
23
+ * `rate > 0`, `par > 0`, and a quasi-coupon date the walk needs below serial 1 or past the
24
+ * calendar's end is #NUM!. A product that overflows is 0.
14
25
  */
15
- export declare function ACCRINT(issue: number, // date
16
- firstInterest: number, //date
17
- settlement: number, //date
18
- rate: number, par: number, frequency: number, basis?: number, calcMethod?: boolean): number;
26
+ export declare function ACCRINT(issue: NoLift<Omittable<AcceptError<Scalar>>>, firstInterest: NoLift<Omittable<AcceptError<Scalar>>>, settlement: NoLift<Omittable<AcceptError<Scalar>>>, rate: NoLift<Omittable<AcceptError<Scalar>>>, par: NoLift<Omittable<AcceptError<Scalar>>>, frequency: NoLift<Omittable<AcceptError<Scalar>>>, basis?: NoLift<Omittable<AcceptError<Scalar>>>, calcMethod?: NoLift<Omittable<AcceptError<Scalar>>>): number;
27
+ /**
28
+ * Returns the accrued interest for a security that pays interest at maturity.
29
+ * @param issue is the security's issue date, expressed as a serial date number.
30
+ * @param settlement is the security's maturity date, expressed as a serial date number.
31
+ * @param rate is the security's annual coupon rate.
32
+ * @param par is the security's par value.
33
+ * @param basis is the type of day count basis to use.
34
+ *
35
+ * @remarks
36
+ * `par · rate · yearfrac(issue, settlement)` with YEARFRAC's year fraction (the signed NASD
37
+ * count at basis 0), measured against Excel 16.0 (fn-battery financial/ACCRINTM, 2026-08-28).
38
+ * There is no quasi-coupon walk here — a security paying at maturity has one period — so the
39
+ * two share their reading and nothing else. The slots read from the first: each date is coerced
40
+ * and checked against the calendar before the next slot is looked at, then the rate, the par and
41
+ * the basis are coerced, and only then the date order (`issue ≤ settlement` once truncated —
42
+ * equal is 0) and the signs of the rate and the par. An OMITTED par is 1000 (a blank cell is 0,
43
+ * and #NUM!). A product that overflows is 0.
44
+ */
45
+ export declare function ACCRINTM(issue: NoLift<Omittable<AcceptError<Scalar>>>, settlement: NoLift<Omittable<AcceptError<Scalar>>>, rate: NoLift<Omittable<AcceptError<Scalar>>>, par: NoLift<Omittable<AcceptError<Scalar>>>, basis?: NoLift<Omittable<AcceptError<Scalar>>>): number;
19
46
  //# sourceMappingURL=ACCRINT.d.ts.map
@@ -1,6 +1,6 @@
1
+ import { Scalar, Omittable, NoLift } from '@sheetxl/primitives';
1
2
  /**
2
- * @summary Returns the depreciation for each accounting period using a
3
- * depreciation coefficient (French degressive / accelerated depreciation).
3
+ * Returns the depreciation for each accounting period using a depreciation coefficient (French degressive / accelerated depreciation).
4
4
  * @param cost is the cost of the asset.
5
5
  * @param datePurchased is the date the asset is purchased.
6
6
  * @param firstPeriod is the date of the end of the first period.
@@ -10,44 +10,26 @@
10
10
  * @param basis is the type of day count basis to use.
11
11
  *
12
12
  * @remarks
13
- * AMORDEGRC is the accelerated counterpart to AMORLINC. The depreciation
14
- * rate is multiplied by a coefficient that depends on the asset's useful life
15
- * (computed as `1 / rate`):
13
+ * Measured against Excel 16.0 (fn-battery financial/AMORDEGRC, 2026-08-28), where it differs from
14
+ * the documentation in most places:
16
15
  *
17
- * life (1/rate) │ coefficient
18
- * ───────────────┼────────────
19
- * < 3 years │ 1.5 (special algorithm — see below)
20
- * 3–4 years │ 1.5
21
- * 5–6 years │ 2.0
22
- * > 6 years │ 2.5
23
- *
24
- * The accelerated rate = rate × coefficient.
25
- *
26
- * Normal algorithm (life >= 3, per Excel spec):
27
- * Period 0: FLOOR(cost × rateAccel × (days / 365)) [basis=1 always uses 365]
28
- * bv carry-forward uses actual yearDays (366 for leap years)
29
- * Period N: FLOOR(max(DDB, SL)) where:
30
- * DDB = bv × rateAccel
31
- * SL = bv / (ceil(1/rate) − period) [no salvage subtraction]
32
- * No clamping to (bv − salvage) — Excel deprecates past salvage.
33
- * Returns 0 when bv ≤ salvage at start of period.
34
- *
35
- * Special algorithm (life < 3):
36
- * Period 0: FLOOR(cost × rateAccel × (days / actualYearDays))
37
- * Period N: CEIL(bv / (ceil(1/rate) − 1)) — same value for all remaining periods
38
- * Returns 0 once all remaining periods are exhausted.
39
- *
40
- * Excel-verified behaviors:
41
- * - basis=2 and basis=4 return #NUM! (unlike AMORLINC which rejects basis=2
42
- * only; AMORDEGRC rejects both)
43
- * - life < 3 does NOT return #NUM! despite documentation — Excel computes
44
- * using coeff=1.5 with the simplified equal-split algorithm above
45
- * - period 0 for basis=1 with life >= 3: return value uses yearDays=365,
46
- * but the bv carried into period 1 uses the actual yearDays (366 for leap).
47
- * This means total depreciation across all periods can exceed cost by 1
48
- * for the life < 3 case — this matches Excel's behavior exactly.
16
+ * - The life is `1/rate`. A life of 2 or less is #NUM!; the coefficient is 1.5 up to a life of 4,
17
+ * 2 up to 6, 2.5 beyond (the documented "1 to 2 years" and "4 to 5 years" bands do not exist).
18
+ * - Period 0 is `cost · rate · coefficient · stub fraction` (the AMORLINC stub, see
19
+ * `getAmorDayCount`), capped at `cost − salvage`, ROUNDED — half away from zero, not
20
+ * floored — and carried into the balance rounded.
21
+ * - Each later period is the declining charge `balance · rate · coefficient`, except the LAST
22
+ * TWO periods of `ceil(life)`, which split the balance in two and then take the rest. There is
23
+ * no other straight-line switch (a 10-year asset stays on the declining charge in period 7
24
+ * although straight line is larger). Every returned charge is rounded, but the balance carries
25
+ * the UNROUNDED charge.
26
+ * - A balance already below salvage at the start of a period returns 0; one equal to salvage is
27
+ * still depreciated (`AMORDEGRC(2400,…,2399,1,0.15,1)` is 900).
28
+ * - A period under 1 is period 1 and above 1 truncates — except that Excel answers other
29
+ * periods' values for some fractions below 1 (0.1 and 1E-300 answer period 5, 0.5 answers 0);
30
+ * those rows are accepted differences.
31
+ * - Every argument is Excel-declared `any`: a boolean is refused, an empty argument is missing, a
32
+ * multi-cell reference does not broadcast. Basis truncates and 2 is refused; 4 is accepted.
49
33
  */
50
- export declare function AMORDEGRC(cost: number, datePurchased: number, // date serial
51
- firstPeriod: number, // date serial
52
- salvage: number, period: number, rate: number, basis?: number): number;
34
+ export declare function AMORDEGRC(cost: NoLift<Omittable<Scalar>>, datePurchased: NoLift<Omittable<Scalar>>, firstPeriod: NoLift<Omittable<Scalar>>, salvage: NoLift<Omittable<Scalar>>, period: NoLift<Omittable<Scalar>>, rate: NoLift<Omittable<Scalar>>, basis?: NoLift<Omittable<Scalar>>): number;
53
35
  //# sourceMappingURL=AMORDEGRC.d.ts.map