@sheetxl/formulas-extended 0.7.28-beta.4 → 0.8.0-beta.10
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.
- package/browser/esm/{BKnXVC21NesUzU9t.mjs → B8U2Eza2ZD4YA-kx.mjs} +1 -1
- package/browser/esm/{DxiRpwBhgWoK5Erd.mjs → BFtgupqxZCxn0dyD.mjs} +5 -5
- package/browser/esm/{DsJzZKURvUm7apNu.mjs → Bg1eKDrYnq3wm8Vk.mjs} +2 -2
- package/browser/esm/Bg54DWqi-iRcswhc.mjs +119 -0
- package/browser/esm/BiXqZc5QZjxe9VkT.mjs +32 -0
- package/browser/esm/BskZz_6FiOeOABjK.mjs +20 -0
- package/browser/esm/C2QrdSuGHG9jhlMh.mjs +23 -0
- package/browser/esm/{CN-pAKHIFQkkdFFB.mjs → C9G09aQXW2LLuPt3.mjs} +1 -1
- package/browser/esm/CFee1d5IBiv4fv1i.mjs +37 -0
- package/browser/esm/{BybuwnuafVL8RdTx.mjs → CHIJMJGn8-ecsv3s.mjs} +3 -3
- package/browser/esm/CJjzoao3hDloxUGc.mjs +19 -0
- package/browser/esm/CcDbY4A8EXqKtmVV.mjs +47 -0
- package/browser/esm/{fhXUc-E6MSehd9Ep.mjs → Cl3Yo2J4W4DMr8oz.mjs} +27 -29
- package/browser/esm/D02eJGMi5PwKHsoL.mjs +58 -0
- package/browser/esm/{XATNfSb9mKkYP5Fr.mjs → DEQlCPiGb8bsBizr.mjs} +6 -6
- package/{node/esm/CsrMSYiKGo3-I_Qk.mjs → browser/esm/DSBsgMaUW3RQ6ceC.mjs} +1 -1
- package/{node/esm/ffkoQUSdLhFyILRL.mjs → browser/esm/Db0ejvxhdCFJuDKI.mjs} +1 -1
- package/{node/esm/DoS1jziW_TXjkH37.mjs → browser/esm/Dcl4zSjM1tlh53wy.mjs} +5 -5
- package/browser/esm/Djzfm7ZsIsQvtPGt.mjs +32 -0
- package/browser/esm/{y9VKeU12ARR9HmtI.mjs → WS_eaJSI0r2L5MVv.mjs} +2 -2
- package/browser/esm/g9IHvvfn4bYTwHgl.mjs +33 -0
- package/browser/esm/index.mjs +3857 -1638
- package/browser/esm/{DnFUggiR6cNYknMt.mjs → yS93vAhNdRw2bt-z.mjs} +1 -1
- package/node/esm/{BKnXVC21NesUzU9t.mjs → B8U2Eza2ZD4YA-kx.mjs} +1 -1
- package/node/esm/{DxiRpwBhgWoK5Erd.mjs → BFtgupqxZCxn0dyD.mjs} +5 -5
- package/node/esm/BHHFJIl22DBeM9aP.mjs +19 -0
- package/node/esm/{DsJzZKURvUm7apNu.mjs → Bg1eKDrYnq3wm8Vk.mjs} +2 -2
- package/node/esm/Bg54DWqi-iRcswhc.mjs +119 -0
- package/node/esm/BiXqZc5QZjxe9VkT.mjs +32 -0
- package/node/esm/BskZz_6FiOeOABjK.mjs +20 -0
- package/node/esm/C2QrdSuGHG9jhlMh.mjs +23 -0
- package/node/esm/{CN-pAKHIFQkkdFFB.mjs → C9G09aQXW2LLuPt3.mjs} +1 -1
- package/node/esm/CFee1d5IBiv4fv1i.mjs +37 -0
- package/node/esm/{v9tvQuvQYcFQ0zOs.mjs → C_IrfNxfWXKc8kjo.mjs} +3 -3
- package/node/esm/{C21UeAwlG4Qkfu1Z.mjs → Cc4Bkwtihl8DmEub.mjs} +1 -1
- package/node/esm/CcDbY4A8EXqKtmVV.mjs +47 -0
- package/node/esm/{fhXUc-E6MSehd9Ep.mjs → Cl3Yo2J4W4DMr8oz.mjs} +27 -29
- package/node/esm/D02eJGMi5PwKHsoL.mjs +58 -0
- package/node/esm/{XATNfSb9mKkYP5Fr.mjs → DEQlCPiGb8bsBizr.mjs} +6 -6
- package/{browser/esm/CsrMSYiKGo3-I_Qk.mjs → node/esm/DSBsgMaUW3RQ6ceC.mjs} +1 -1
- package/{browser/esm/ffkoQUSdLhFyILRL.mjs → node/esm/Db0ejvxhdCFJuDKI.mjs} +1 -1
- package/{browser/esm/DoS1jziW_TXjkH37.mjs → node/esm/Dcl4zSjM1tlh53wy.mjs} +5 -5
- package/node/esm/Djzfm7ZsIsQvtPGt.mjs +32 -0
- package/node/esm/{y9VKeU12ARR9HmtI.mjs → WS_eaJSI0r2L5MVv.mjs} +2 -2
- package/node/esm/g9IHvvfn4bYTwHgl.mjs +33 -0
- package/node/esm/index.mjs +4208 -1970
- package/package.json +5 -6
- package/types/src/.generated/decl/financial/Annuity.decl.d.ts +5 -0
- package/types/src/.generated/decl/financial/{Financial.decl.d.ts → Cashflow.decl.d.ts} +1 -1
- package/types/src/.generated/decl/financial/Convert.decl.d.ts +4 -0
- package/types/src/.generated/decl/financial/Coupon.decl.d.ts +4 -0
- package/types/src/.generated/decl/financial/{Financial2.decl.d.ts → Depreciation.decl.d.ts} +1 -1
- package/types/src/.generated/decl/financial/Growth.decl.d.ts +4 -0
- package/types/src/.generated/decl/financial/{ODD.decl.d.ts → Odd.decl.d.ts} +1 -1
- package/types/src/.generated/decl/financial/{Financial3.decl.d.ts → STOCKHISTORY.decl.d.ts} +1 -1
- package/types/src/.generated/decl/financial/Security.decl.d.ts +4 -0
- package/types/src/.generated/decl/financial/{Financial4.decl.d.ts → SecurityMaturity.decl.d.ts} +1 -1
- package/types/src/.generated/decl/{statistical/TTEST.decl.d.ts → financial/TBill.decl.d.ts} +1 -1
- package/types/src/.generated/decl/lookupReference/GroupBy.decl.d.ts +4 -0
- package/types/src/.generated/decl/lookupReference/PivotBy.decl.d.ts +4 -0
- package/types/src/.generated/decl/statistical/{ETS.decl.d.ts → Ets.decl.d.ts} +1 -1
- package/types/src/.generated/decl/statistical/TTest.decl.d.ts +4 -0
- package/types/src/.generated/desc/financial/Annuity.desc.d.ts +5 -0
- package/types/src/.generated/desc/financial/{Financial.desc.d.ts → Cashflow.desc.d.ts} +1 -1
- package/types/src/.generated/desc/financial/Convert.desc.d.ts +4 -0
- package/types/src/.generated/desc/financial/Coupon.desc.d.ts +4 -0
- package/types/src/.generated/desc/financial/{Financial2.desc.d.ts → Depreciation.desc.d.ts} +1 -1
- package/types/src/.generated/desc/financial/Growth.desc.d.ts +4 -0
- package/types/src/.generated/desc/financial/{ODD.desc.d.ts → Odd.desc.d.ts} +1 -1
- package/types/src/.generated/desc/financial/{Financial3.desc.d.ts → STOCKHISTORY.desc.d.ts} +1 -1
- package/types/src/.generated/desc/financial/Security.desc.d.ts +4 -0
- package/types/src/.generated/desc/financial/{Financial4.desc.d.ts → SecurityMaturity.desc.d.ts} +1 -1
- package/types/src/.generated/desc/{statistical/TTEST.desc.d.ts → financial/TBill.desc.d.ts} +1 -1
- package/types/src/.generated/desc/lookupReference/GroupBy.desc.d.ts +4 -0
- package/types/src/.generated/desc/lookupReference/PivotBy.desc.d.ts +4 -0
- package/types/src/.generated/desc/statistical/{ETS.desc.d.ts → Ets.desc.d.ts} +1 -1
- package/types/src/.generated/desc/statistical/TTest.desc.d.ts +4 -0
- package/types/src/_utils/AnyArgs.d.ts +17 -3
- package/types/src/_utils/Consts.d.ts +2 -2
- package/types/src/_utils/FinanaceSolver.d.ts +39 -2
- package/types/src/_utils/FinanceAmor.d.ts +23 -0
- package/types/src/_utils/FinanceCashflow.d.ts +42 -0
- package/types/src/_utils/FinanceCoupon.d.ts +92 -82
- package/types/src/_utils/FinanceDate.d.ts +24 -0
- package/types/src/_utils/FinanceDayCount.d.ts +46 -0
- package/types/src/_utils/FinanceOdd.d.ts +93 -0
- package/types/src/_utils/FinanceSecurity.d.ts +84 -0
- package/types/src/_utils/FinanceUtils.d.ts +37 -1
- package/types/src/_utils/LeastSquares.d.ts +20 -22
- package/types/src/_utils/Pivot.d.ts +205 -0
- package/types/src/_utils/RegexCompile.d.ts +33 -0
- package/types/src/cube/Cube.d.ts +7 -7
- package/types/src/financial/ACCRINT.d.ts +33 -6
- package/types/src/financial/AMORDEGRC.d.ts +22 -40
- package/types/src/financial/Annuity.d.ts +118 -0
- package/types/src/financial/Cashflow.d.ts +84 -0
- package/types/src/financial/Convert.d.ts +26 -0
- package/types/src/financial/Coupon.d.ts +72 -0
- package/types/src/financial/Date.d.ts +34 -5
- package/types/src/financial/Depreciation.d.ts +58 -0
- package/types/src/financial/Growth.d.ts +22 -0
- package/types/src/financial/Odd.d.ts +82 -0
- package/types/src/financial/STOCKHISTORY.d.ts +17 -0
- package/types/src/financial/Security.d.ts +68 -0
- package/types/src/financial/SecurityMaturity.d.ts +107 -0
- package/types/src/financial/TBill.d.ts +40 -0
- package/types/src/financial/VDB.d.ts +15 -13
- package/types/src/lookupReference/GroupBy.d.ts +14 -0
- package/types/src/lookupReference/PivotBy.d.ts +17 -0
- package/types/src/statistical/{ETS.d.ts → Ets.d.ts} +14 -14
- package/types/src/statistical/Regression.d.ts +13 -18
- package/types/src/statistical/{TTEST.d.ts → TTest.d.ts} +5 -5
- package/types/src/text/RegEx.d.ts +34 -11
- package/browser/cjs/B4JJfKSI4ppwU855.cjs +0 -1
- package/browser/cjs/BWDfauDHqB6U_2ka.cjs +0 -1
- package/browser/cjs/BwLx9ix5Sq7suAYP.cjs +0 -1
- package/browser/cjs/C2uDl8VIJqh58YF_.cjs +0 -1
- package/browser/cjs/CW-b31_-r-_raT8Y.cjs +0 -1
- package/browser/cjs/Clu7XiAsCB48GDXN.cjs +0 -1
- package/browser/cjs/CnZfa45XxA-9Jhmp.cjs +0 -1
- package/browser/cjs/DsFZgtSQpC75d1M0.cjs +0 -1
- package/browser/cjs/JfM6P_qoQQTWakZf.cjs +0 -1
- package/browser/cjs/bM25C5avKgBAJVfk.cjs +0 -1
- package/browser/cjs/fqTQ_p3ehzUvc1tF.cjs +0 -1
- package/browser/cjs/h3dw1jAp2J5Pu4p3.cjs +0 -1
- package/browser/cjs/index.cjs +0 -1
- package/browser/cjs/jev6VGWTdgEgm4Yk.cjs +0 -1
- package/browser/cjs/lEQC21-Sk4lwHy2r.cjs +0 -1
- package/browser/esm/C2TyRseZg5dWtMq1.mjs +0 -304
- package/browser/esm/CShl-IMQIPnBMVpb.mjs +0 -20
- package/node/esm/C2TyRseZg5dWtMq1.mjs +0 -304
- package/node/esm/CShl-IMQIPnBMVpb.mjs +0 -20
- package/types/src/financial/Financial.d.ts +0 -283
- package/types/src/financial/Financial2.d.ts +0 -99
- package/types/src/financial/Financial3.d.ts +0 -95
- package/types/src/financial/Financial4.d.ts +0 -82
- package/types/src/financial/ODD.d.ts +0 -106
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sheetxl/formulas-extended",
|
|
3
3
|
"description": "Formulas Enterprise - TypeScript formulas compatible with Excel built-ins.",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.8.0-beta.10",
|
|
5
5
|
"license": "SEE LICENSE IN <LICENSE>",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"exports": {
|
|
@@ -9,13 +9,12 @@
|
|
|
9
9
|
"types": "./types/index.d.ts",
|
|
10
10
|
"browser": "./browser/esm/index.mjs",
|
|
11
11
|
"node": "./node/esm/index.mjs",
|
|
12
|
-
"
|
|
13
|
-
"require": "./browser/cjs/index.cjs"
|
|
12
|
+
"default": "./browser/esm/index.mjs"
|
|
14
13
|
}
|
|
15
14
|
},
|
|
16
15
|
"types": "./types/index.d.ts",
|
|
17
16
|
"module": "./browser/esm/index.mjs",
|
|
18
|
-
"main": "./browser/
|
|
17
|
+
"main": "./browser/esm/index.mjs",
|
|
19
18
|
"sideEffects": false,
|
|
20
19
|
"engineStrict": true,
|
|
21
20
|
"homepage": "https://sheetxl.com",
|
|
@@ -37,7 +36,7 @@
|
|
|
37
36
|
"formulas"
|
|
38
37
|
],
|
|
39
38
|
"dependencies": {
|
|
40
|
-
"@sheetxl/primitives": "^0.
|
|
41
|
-
"@sheetxl/scripting": "^0.
|
|
39
|
+
"@sheetxl/primitives": "^0.8.0-beta.10",
|
|
40
|
+
"@sheetxl/scripting": "^0.8.0-beta.10"
|
|
42
41
|
}
|
|
43
42
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Scalar } from '@sheetxl/primitives';
|
|
1
|
+
import { Scalar, Omittable } from '@sheetxl/primitives';
|
|
2
2
|
/**
|
|
3
3
|
* Readers for arguments Excel declares `any` rather than `number`.
|
|
4
4
|
*
|
|
@@ -23,10 +23,17 @@ import { Scalar } from '@sheetxl/primitives';
|
|
|
23
23
|
* `parseAsSerialDate` supplies the refusal — `#VALUE!` for a boolean, whether it arrived as a
|
|
24
24
|
* literal or as a cell, and an incoming error rethrown with its own identity.
|
|
25
25
|
*
|
|
26
|
-
* A blank CELL is serial 0.
|
|
27
|
-
*
|
|
26
|
+
* A blank CELL is serial 0. A genuinely empty SLOT is `#N/A` in Excel (`EOMONTH(,0)`,
|
|
27
|
+
* `YEARFRAC(,39814)` — fn-battery financial/YEARFRAC, 2026-08-28); a parameter declared
|
|
28
|
+
* `Omittable<Scalar>` sees that slot as `undefined` and reads it through {@link anyDateRequired}.
|
|
28
29
|
*/
|
|
29
30
|
export declare function anyDate(value: Scalar): number;
|
|
31
|
+
/**
|
|
32
|
+
* A REQUIRED date parameter Excel declares `any` (`Omittable<Scalar>` on the declaration): an
|
|
33
|
+
* argument supplied EMPTY is a missing argument (#N/A); everything else reads through
|
|
34
|
+
* {@link anyDate}, so a blank CELL is still serial 0.
|
|
35
|
+
*/
|
|
36
|
+
export declare function anyDateRequired(value: Omittable<Scalar>): number;
|
|
30
37
|
/**
|
|
31
38
|
* Reads a plain NUMERIC argument declared `any` — the `months`/`basis` slots.
|
|
32
39
|
*
|
|
@@ -35,4 +42,11 @@ export declare function anyDate(value: Scalar): number;
|
|
|
35
42
|
* text parsed, boolean refused, error identity preserved.
|
|
36
43
|
*/
|
|
37
44
|
export declare function anyNumber(value: Scalar): number;
|
|
45
|
+
/**
|
|
46
|
+
* A REQUIRED parameter Excel declares `any` (`Omittable<Scalar>` on the declaration): an argument
|
|
47
|
+
* supplied EMPTY is a missing argument (#N/A) rather than a zero, and everything else reads
|
|
48
|
+
* through `anyNumber`. The `undefined` check must come first — `anyNumber` reads a blank cell's
|
|
49
|
+
* `null` as 0, which is what a blank CELL is measured to be.
|
|
50
|
+
*/
|
|
51
|
+
export declare function anyRequired(value: Omittable<Scalar>): number;
|
|
38
52
|
//# sourceMappingURL=AnyArgs.d.ts.map
|
|
@@ -7,8 +7,8 @@ export declare const ColumnOriented: Readonly<{
|
|
|
7
7
|
export declare const RowOriented: Readonly<{
|
|
8
8
|
axis: "row";
|
|
9
9
|
}>;
|
|
10
|
-
export declare const
|
|
10
|
+
export declare const RowOrientedNumbers: Readonly<{
|
|
11
11
|
type: "number";
|
|
12
|
-
axis: "
|
|
12
|
+
axis: "row";
|
|
13
13
|
}>;
|
|
14
14
|
//# sourceMappingURL=Consts.d.ts.map
|
|
@@ -1,4 +1,34 @@
|
|
|
1
1
|
type IterFn = (x: number) => number;
|
|
2
|
+
/**
|
|
3
|
+
* The approximate yield a bond-yield iteration starts from: the annual coupon plus the pull to par
|
|
4
|
+
* spread over `years`, against a denominator that is the mid-point of par and the price less a
|
|
5
|
+
* `years`-scaled share of the same pull. At par it returns the coupon rate exactly, which is why
|
|
6
|
+
* a bond priced at 100 answers in one step.
|
|
7
|
+
*
|
|
8
|
+
* `years` is {@link getYearsToMaturity}, never the coupon count over the frequency. Measured on
|
|
9
|
+
* 1,154 rows of fn-battery financial/adhoc-yield-start, -n, -n2 and -n3 — bonds whose redemption
|
|
10
|
+
* dwarfs the price, where a hundred Newton steps carry the start out to a number that inverts.
|
|
11
|
+
*
|
|
12
|
+
* Used by: YIELD, ODDFYIELD.
|
|
13
|
+
*/
|
|
14
|
+
export declare function approximateYield(rate: number, pr: number, years: number): number;
|
|
15
|
+
/**
|
|
16
|
+
* Excel's bond-yield iteration: Newton on the price with its ANALYTIC slope, at most a hundred
|
|
17
|
+
* steps from {@link approximateYield}, stopping the first time a step moves the yield by less than
|
|
18
|
+
* `1e-5` and answering the iterate the step just produced — so the answer is a PARTIALLY converged
|
|
19
|
+
* one, ~1e-10 from the root on an ordinary bond, and on a bond that cannot converge it is simply
|
|
20
|
+
* where the walk stood after a hundred steps.
|
|
21
|
+
*
|
|
22
|
+
* A slope that overflows to infinity, or a step that lands where the price cannot be evaluated
|
|
23
|
+
* (a `1 + y/f` at or below zero), is `NaN` — the caller's #NUM!.
|
|
24
|
+
*
|
|
25
|
+
* Measured on YIELD's 1,134-row battery and fn-battery financial/adhoc-yield-fingerprint,
|
|
26
|
+
* -start, -n, -n2, -n3, -domain (2026-09-09).
|
|
27
|
+
*
|
|
28
|
+
* Used by: YIELD, ODDFYIELD.
|
|
29
|
+
*/
|
|
30
|
+
export declare function solveYieldByNewton(start: number, priceFn: IterFn, slopeFn: IterFn): number;
|
|
31
|
+
export {};
|
|
2
32
|
/**
|
|
3
33
|
* Solve `iterFn(x) = 0` numerically, starting from `guess`.
|
|
4
34
|
*
|
|
@@ -14,6 +44,13 @@ type IterFn = (x: number) => number;
|
|
|
14
44
|
*
|
|
15
45
|
* Used by: YIELD, ODDFYIELD, ODDLYIELD.
|
|
16
46
|
*/
|
|
17
|
-
|
|
18
|
-
|
|
47
|
+
/**
|
|
48
|
+
* Bisection fallback when Newton-Raphson fails to converge.
|
|
49
|
+
*
|
|
50
|
+
* Phase 1: Expand a small bracket around guess until the function changes sign
|
|
51
|
+
* (guarantees a root is bracketed, or gives up with NaN).
|
|
52
|
+
* Phase 2: Standard bisection to isolate the root.
|
|
53
|
+
*
|
|
54
|
+
* Returns NaN if no bracket is found within the iteration budget.
|
|
55
|
+
*/
|
|
19
56
|
//# sourceMappingURL=FinanaceSolver.d.ts.map
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { Scalar, Omittable } from '@sheetxl/primitives';
|
|
2
|
+
/** The arguments of AMORLINC/AMORDEGRC once read and validated. */
|
|
3
|
+
export interface AmorArgs {
|
|
4
|
+
cost: number;
|
|
5
|
+
salvage: number;
|
|
6
|
+
/** The period as Excel indexes it: under 1 is period 1, above 1 truncates. */
|
|
7
|
+
periodIndex: number;
|
|
8
|
+
rate: number;
|
|
9
|
+
/** The stub period's day count (`getAmorDayCount`); its year fraction is `days / yearDays`. */
|
|
10
|
+
days: number;
|
|
11
|
+
yearDays: number;
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* The seven arguments of AMORLINC/AMORDEGRC — measured against Excel 16.0 (fn-battery
|
|
15
|
+
* financial/AMORLINC, /AMORDEGRC, 2026-08-28). Every one is Excel-declared `any`, so they are
|
|
16
|
+
* read here in declaration order, with the basis read AFTER the dates are validated (a reversed
|
|
17
|
+
* date pair beats a text basis: `…, DATE(2008,12,31), DATE(2008,8,19), …, "x")` is #NUM!). The
|
|
18
|
+
* serials truncate; the shared domain is `cost > 0`, `0 ≤ salvage ≤ cost`, `period ≥ 0`,
|
|
19
|
+
* `rate > 0`, both dates in the calendar and in order, and a truncated basis of 0, 1, 3 or 4.
|
|
20
|
+
* Returns `null` for #NUM!.
|
|
21
|
+
*/
|
|
22
|
+
export declare function amorArgs(cost: Omittable<Scalar>, datePurchased: Omittable<Scalar>, firstPeriod: Omittable<Scalar>, salvage: Omittable<Scalar>, period: Omittable<Scalar>, rate: Omittable<Scalar>, basis: Omittable<Scalar>): AmorArgs | null;
|
|
23
|
+
//# sourceMappingURL=FinanceAmor.d.ts.map
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
import { IRange } from '@sheetxl/primitives';
|
|
2
|
+
/**
|
|
3
|
+
* The dated cash-flow operands of XNPV and XIRR, read the way Excel reads them (measured against
|
|
4
|
+
* Excel 16.0, fn-battery financial/XNPV, 2026-08-29).
|
|
5
|
+
*
|
|
6
|
+
* @remarks
|
|
7
|
+
* Both functions take two operands that are read TOGETHER, member by member, by flattened
|
|
8
|
+
* row-major ordinal — a 3x1 pairs fully with a 1x3 and a 2x2 pairs with a 4x1
|
|
9
|
+
* (DESIGN-RANGE-PAIRING). That makes the reading order a pair scan rather than a slot order, and
|
|
10
|
+
* it is one pass that stops at the first fault: a bad ordinal 2 is answered before ordinal 3's
|
|
11
|
+
* error is looked at.
|
|
12
|
+
*
|
|
13
|
+
* Ordinal 0 is not like the rest. Its DATE is read before its value (an error there wins over an
|
|
14
|
+
* error in the first flow) and range-checked before either, and a member of EITHER operand that
|
|
15
|
+
* is not a number is `#VALUE!` there where the same member at any later ordinal is `#NUM!` —
|
|
16
|
+
* so a whole operand of numeric text, or of blanks, answers `#VALUE!` while one number among
|
|
17
|
+
* them answers `#NUM!`.
|
|
18
|
+
*/
|
|
19
|
+
export interface DatedFlows {
|
|
20
|
+
/** The flow at each ordinal. */
|
|
21
|
+
values: number[];
|
|
22
|
+
/** Days from the first date, every serial truncated first. */
|
|
23
|
+
days: number[];
|
|
24
|
+
}
|
|
25
|
+
/**
|
|
26
|
+
* `(values, dates)` as XNPV and XIRR read them. `valuesSlot` is the argument index of the values
|
|
27
|
+
* operand (the dates operand is the next one), which is what tells a one-cell operand from a list
|
|
28
|
+
* of one; `dialect` picks between the two functions' member rules.
|
|
29
|
+
*
|
|
30
|
+
* The pair scan is common to both: a count mismatch is `#NUM!` before anything else, and then, per
|
|
31
|
+
* ordinal, an error in the values operand, an error in the dates operand, and only then the kinds
|
|
32
|
+
* and the date's own domain.
|
|
33
|
+
*
|
|
34
|
+
* What differs is what a member may BE. XNPV's list members must already be numbers — a text, a
|
|
35
|
+
* boolean, an empty string or a blank is `#VALUE!` at ordinal 0 and `#NUM!` after it — and its
|
|
36
|
+
* serials run `[1, MAX_SERIAL_DATE]` with every date at or after the first. XIRR COERCES its
|
|
37
|
+
* members instead (numeric text and date text parse, a boolean or a true text is `#VALUE!`
|
|
38
|
+
* wherever it sits), drops a pair whose VALUE is blank, answers `#NUM!` for a blank DATE beside a
|
|
39
|
+
* present value, admits serial 0, and does not order the dates at all.
|
|
40
|
+
*/
|
|
41
|
+
export declare function readDatedFlows(values: IRange, dates: IRange, valuesSlot: number, dialect?: 'xnpv' | 'xirr'): DatedFlows;
|
|
42
|
+
//# sourceMappingURL=FinanceCashflow.d.ts.map
|
|
@@ -1,26 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
* Shared pure-math helpers for bond pricing and coupon date functions.
|
|
3
|
-
*
|
|
4
|
-
* All formulas follow the Excel spec:
|
|
5
|
-
* https://support.microsoft.com/en-us/office/financial-functions-reference
|
|
6
|
-
*
|
|
7
|
-
* Date arithmetic delegates to SheetXL's existing date utilities
|
|
8
|
-
* (dateAddMonths, getDaysInMonth, isLastDayOfMonth, getDayCount), and serial
|
|
9
|
-
* <-> Date conversion to FormulaContext's `dateOnly` flavors — same interface
|
|
10
|
-
* SheetXL uses throughout the financial module.
|
|
11
|
-
*
|
|
12
|
-
* Basis codes (used throughout):
|
|
13
|
-
* 0 US 30/360 (NASD)
|
|
14
|
-
* 1 Actual/actual
|
|
15
|
-
* 2 Actual/360
|
|
16
|
-
* 3 Actual/365
|
|
17
|
-
* 4 European 30/360
|
|
18
|
-
*
|
|
19
|
-
* These are plain number-in / number-out helpers that the formula wrappers
|
|
20
|
-
* call after doing all parameter validation and coercion — they touch
|
|
21
|
-
* FormulaContext only for serial<->Date conversion, never IRange or
|
|
22
|
-
* FormulaError.
|
|
23
|
-
*/
|
|
1
|
+
import { Omittable, Scalar } from '@sheetxl/primitives';
|
|
24
2
|
/**
|
|
25
3
|
* Returns the signed day count between two Excel serial dates using the given
|
|
26
4
|
* day-count basis. The result is always positive (or zero) — we clamp
|
|
@@ -33,70 +11,117 @@
|
|
|
33
11
|
export declare function daysBetween(startSerial: number, endSerial: number, basis: number): number;
|
|
34
12
|
/**
|
|
35
13
|
* Previous coupon date (COUPPCD):
|
|
36
|
-
* Returns the Excel serial number of the last coupon date before or on the
|
|
37
|
-
*
|
|
38
|
-
*
|
|
39
|
-
* Used by: COUPPCD, COUPDAYBS, COUPDAYS (basis=1), PRICE, YIELD, DURATION…
|
|
14
|
+
* Returns the Excel serial number of the last coupon date before or on the settlement date.
|
|
15
|
+
* A coupon date below the calendar answers 0 — Excel's clamp, measured.
|
|
40
16
|
*/
|
|
41
17
|
export declare function calculateCouppcd(settlementSerial: number, maturitySerial: number, frequency: number): number;
|
|
42
18
|
/**
|
|
43
19
|
* Next coupon date (COUPNCD):
|
|
44
20
|
* Returns the Excel serial number of the first coupon date after settlement.
|
|
45
|
-
*
|
|
46
|
-
* Used by: COUPNCD, COUPDAYSNC, ODDLPRICE (basis 2 / 3 branch).
|
|
47
21
|
*/
|
|
48
22
|
export declare function calculateCoupncd(settlementSerial: number, maturitySerial: number, frequency: number): number;
|
|
49
23
|
/**
|
|
50
|
-
*
|
|
51
|
-
*
|
|
52
|
-
*
|
|
53
|
-
|
|
54
|
-
|
|
24
|
+
* Number of remaining coupons from settlement to maturity (COUPNUM). `NaN` (the caller's
|
|
25
|
+
* #NUM!) when the previous coupon date is at or below serial 0 — `COUPNUM(DATE(1900,1,1),
|
|
26
|
+
* DATE(1900,12,31),4)` is #NUM! while its COUPPCD is 0 (measured).
|
|
27
|
+
*/
|
|
28
|
+
export declare function calculateCoupnum(settlementSerial: number, maturitySerial: number, frequency: number): number;
|
|
29
|
+
/**
|
|
30
|
+
* Days from previous coupon to settlement (COUPDAYBS): the day count of the basis from the
|
|
31
|
+
* (clamped) previous coupon date to the settlement — the NASD rules `getDayCount` keeps for
|
|
32
|
+
* basis 0, actual days for 1–3, the European 30/360 for 4.
|
|
55
33
|
*/
|
|
56
34
|
export declare function calculateCoupdaybs(settlementSerial: number, maturitySerial: number, frequency: number, basis: number): number;
|
|
57
35
|
/**
|
|
58
|
-
* Days
|
|
59
|
-
*
|
|
60
|
-
*
|
|
61
|
-
*
|
|
62
|
-
*
|
|
63
|
-
*
|
|
36
|
+
* Days from settlement to the next coupon date (COUPDAYSNC). Actual days for bases 1–3. The
|
|
37
|
+
* 30/360 bases are NOT `getDayCount`'s (measured, 556 of 556 rows): the count runs from the
|
|
38
|
+
* settlement's own day — a 31 is 30, and a February month end is NOT 30 unless the
|
|
39
|
+
* settlement IS the previous coupon date, in which case the coupon date's unclamped day is
|
|
40
|
+
* read instead (`COUPDAYSNC(DATE(2011,2,28),DATE(2011,5,31),2,0)` is 92, from day 28;
|
|
41
|
+
* `COUPDAYSNC(DATE(2011,2,28),DATE(2011,8,29),2,0)` is 179, from the chain's `Feb 29`) — to
|
|
42
|
+
* the next coupon date carrying the maturity's day unclamped: at basis 0 a February day at or
|
|
43
|
+
* past the month's end is 30 and a 31 is 30 with no advance into the next month; basis 4
|
|
44
|
+
* caps both ends at 30.
|
|
45
|
+
*/
|
|
46
|
+
export declare function calculateCoupdaysnc(settlementSerial: number, maturitySerial: number, frequency: number, basis: number): number;
|
|
47
|
+
/**
|
|
48
|
+
* Days in the coupon period that contains settlement (COUPDAYS). Basis 3 is `365/frequency`
|
|
49
|
+
* and the 30/360 bases `360/frequency`. Basis 1 is Excel's own construction, measured on
|
|
50
|
+
* 2,302 rows (fn-battery financial/COUPDAYS + adhoc-coupdays-b1 + adhoc-coupdays-sweep) and
|
|
51
|
+
* NOT the next coupon minus the previous one (LibreOffice's reading; wrong on 30 of the
|
|
52
|
+
* battery's 225 rows). Excel walks TWO chains back from maturity: one whose day of month
|
|
53
|
+
* decays as it is clamped (`Aug 30 → Feb 29 → Aug 29 → Feb 28 → Aug 28`) and one that stays
|
|
54
|
+
* on the month's last day once a clamp lands there (`Aug 30 → Feb 29 → Aug 31 → Feb 28 →
|
|
55
|
+
* Aug 31`). The decaying chain is walked to the first date on or before the settlement; if
|
|
56
|
+
* the coupon after that date is not the same date in both chains, the period is the decaying
|
|
57
|
+
* chain's, otherwise it is the month-end chain's period around the settlement. So for a Nov 30
|
|
58
|
+
* maturity paid twice a year a settlement of Dec 15 sits in `Nov 30 → May 30` (181) while a
|
|
59
|
+
* settlement of May 30 sits in `Nov 30 → May 31` (182) and one of May 31 in `May 31 → Nov 30`
|
|
60
|
+
* (183). A period that begins below serial 1 is counted in real days (`_periodDays`).
|
|
61
|
+
*
|
|
62
|
+
* Used by: COUPDAYS and {@link couponPeriod}.
|
|
64
63
|
*/
|
|
65
64
|
export declare function calculateCoupdays(settlementSerial: number, maturitySerial: number, frequency: number, basis: number): number;
|
|
66
65
|
/**
|
|
67
|
-
*
|
|
68
|
-
*
|
|
69
|
-
*
|
|
70
|
-
*
|
|
71
|
-
*
|
|
66
|
+
* The four arguments of the six coupon functions, read in Excel's order — every one is
|
|
67
|
+
* Excel-declared `any` (a boolean is #VALUE!, an empty argument #N/A, a blank cell 0, a
|
|
68
|
+
* multi-cell reference does not broadcast: `NoLift<>` on every slot): the two dates
|
|
69
|
+
* are coerced and validated (#NUM! for a serial outside the calendar or a settlement not
|
|
70
|
+
* strictly before the maturity once both are truncated), then the frequency is read and
|
|
71
|
+
* validated (1, 2 or 4 after truncation), then the basis — so
|
|
72
|
+
* `COUPDAYS(DATE(2020,1,1),DATE(2019,1,1),"x",0)` is #NUM! and so is the same with a text
|
|
73
|
+
* basis, while a text frequency against a bad basis is #VALUE!. Basis truncates; a negative
|
|
74
|
+
* one is #NUM! before truncation.
|
|
72
75
|
*/
|
|
73
|
-
export declare function
|
|
76
|
+
export declare function readCouponArgs(settlement: Omittable<Scalar>, maturity: Omittable<Scalar>, frequency: Omittable<Scalar>, basis: Omittable<Scalar>): {
|
|
77
|
+
settlement: number;
|
|
78
|
+
maturity: number;
|
|
79
|
+
frequency: number;
|
|
80
|
+
basis: number;
|
|
81
|
+
};
|
|
74
82
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
-
*
|
|
81
|
-
*
|
|
82
|
-
*
|
|
83
|
-
*
|
|
84
|
-
* Reference:
|
|
85
|
-
* https://support.microsoft.com/en-us/office/oddfprice-function-d7d664a8-34df-4233-8d2b-922bcf6a69e1
|
|
83
|
+
* The coupon-period numbers PRICE, YIELD, DURATION and MDURATION are built on, as Excel
|
|
84
|
+
* composes them (measured against Excel's own COUPNUM/COUPDAYBS/COUPDAYS/COUPDAYSNC answers on
|
|
85
|
+
* 572 shapes, fn-battery financial/PRICE + /DURATION, 2026-08-28): `N` is COUPNUM (NaN, the
|
|
86
|
+
* caller's #NUM!, when the previous coupon is below the calendar), `A` is COUPDAYBS, and the
|
|
87
|
+
* period length `E` is COUPDAYS — EXCEPT at basis 1, where it is the real span from the
|
|
88
|
+
* previous coupon to the next (`COUPDAYBS + COUPDAYSNC`), not COUPDAYS' two-chain value; the
|
|
89
|
+
* two differ on the month-end and February maturities (22 of the 225 basis-1 shapes). `DSC` is
|
|
90
|
+
* `E − A`, never COUPDAYSNC.
|
|
86
91
|
*/
|
|
87
|
-
export declare function
|
|
92
|
+
export declare function couponPeriod(settlementSerial: number, maturitySerial: number, frequency: number, basis: number): {
|
|
93
|
+
N: number;
|
|
94
|
+
A: number;
|
|
95
|
+
E: number;
|
|
96
|
+
DSC: number;
|
|
97
|
+
};
|
|
88
98
|
/**
|
|
89
|
-
* Standard coupon bond price
|
|
90
|
-
*
|
|
91
|
-
*
|
|
92
|
-
*
|
|
93
|
-
*
|
|
94
|
-
*
|
|
95
|
-
*
|
|
96
|
-
*
|
|
97
|
-
*
|
|
99
|
+
* Standard coupon bond price per $100 face value — the doc's closed form over
|
|
100
|
+
* {@link couponPeriod}'s numbers: with one coupon left `(coupon + redemption) / (1 + DSC/E ·
|
|
101
|
+
* yld/f) − coupon · A/E` (linear, not the power form), otherwise the redemption and each coupon
|
|
102
|
+
* discounted by `(1 + yld/f)^(k − 1 + DSC/E)` less the accrued coupon. Measured bit-for-bit on
|
|
103
|
+
* PRICE's battery (fn-battery financial/PRICE, 2026-08-28).
|
|
104
|
+
*
|
|
105
|
+
* The grouping is measured too, as ODDFPRICE's is: the coupon sum is accumulated on its own,
|
|
106
|
+
* forward, then the redemption term is added to it and the accrued coupon subtracted. Starting
|
|
107
|
+
* the accumulator at the redemption instead costs 146 of PRICE's 779 census rows and 74 of
|
|
108
|
+
* YIELD's 785 (SXL_CENSUS over the financial suite, 2026-09-09) — the terms and the divisions
|
|
109
|
+
* are identical either way, only the order the additions round in differs. It is visible in
|
|
110
|
+
* YIELD because that answer is a PARTIAL iterate.
|
|
111
|
+
*
|
|
112
|
+
* Used by: PRICE, YIELD.
|
|
98
113
|
*/
|
|
99
114
|
export declare function calculatePrice(settlementSerial: number, maturitySerial: number, rate: number, yld: number, redemption: number, frequency: number, basis: number): number;
|
|
115
|
+
/**
|
|
116
|
+
* `d/dy` of {@link calculatePrice}, term by term — the slope YIELD's Newton divides by. Analytic,
|
|
117
|
+
* not a difference quotient: a finite difference of any step reproduces neither the hundred-step
|
|
118
|
+
* answers of a redemption that dwarfs the price nor the partially-converged ones (fn-battery
|
|
119
|
+
* financial/adhoc-yield-fingerprint, 2026-09-09). A term that overflows makes the slope infinite,
|
|
120
|
+
* which the caller answers as #NUM!.
|
|
121
|
+
*
|
|
122
|
+
* Used by: YIELD.
|
|
123
|
+
*/
|
|
124
|
+
export declare function calculatePriceSlope(settlementSerial: number, maturitySerial: number, rate: number, yld: number, redemption: number, frequency: number, basis: number): number;
|
|
100
125
|
/**
|
|
101
126
|
* Macaulay duration of a coupon bond.
|
|
102
127
|
*
|
|
@@ -123,19 +148,4 @@ export declare function calculateDuration(settlementSerial: number, maturitySeri
|
|
|
123
148
|
*/
|
|
124
149
|
export declare function calculateDDB(cost: number, salvage: number, life: number, period: number, // 1-based period number
|
|
125
150
|
factor: number): number;
|
|
126
|
-
/**
|
|
127
|
-
* Returns true if the settlement and maturity dates are aligned to coupon
|
|
128
|
-
* dates — i.e., the day-of-month matches and the month difference is an exact
|
|
129
|
-
* multiple of (12/frequency).
|
|
130
|
-
*
|
|
131
|
-
* Used by ODDFPRICE / ODDFYIELD / ODDLPRICE / ODDLYIELD validators.
|
|
132
|
-
*/
|
|
133
|
-
export declare function isDatesAreAlignedToCoupon(date1Serial: number, date2Serial: number, frequency: number): boolean;
|
|
134
|
-
/**
|
|
135
|
-
* Returns true if calculateCouppcd(d1, d2, frequency) >= 0.
|
|
136
|
-
*
|
|
137
|
-
* Used by ODDFPRICE / ODDFYIELD validators.
|
|
138
|
-
*/
|
|
139
|
-
export declare function isCouppcdIsNonNegative(date1Serial: number, date2Serial: number, frequency: number): boolean;
|
|
140
|
-
export declare function isValidFrequency(frequency: number): boolean;
|
|
141
151
|
//# sourceMappingURL=FinanceCoupon.d.ts.map
|