@insiderfinance/totalfinance 0.1.0
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/LICENSE +201 -0
- package/README.md +339 -0
- package/STABILITY.md +23 -0
- package/modules/backtest/dist/artifacts.d.ts +23 -0
- package/modules/backtest/dist/artifacts.d.ts.map +1 -0
- package/modules/backtest/dist/artifacts.js +22 -0
- package/modules/backtest/dist/artifacts.js.map +1 -0
- package/modules/backtest/dist/broker.d.ts +265 -0
- package/modules/backtest/dist/broker.d.ts.map +1 -0
- package/modules/backtest/dist/broker.js +1228 -0
- package/modules/backtest/dist/broker.js.map +1 -0
- package/modules/backtest/dist/costs.d.ts +67 -0
- package/modules/backtest/dist/costs.d.ts.map +1 -0
- package/modules/backtest/dist/costs.js +171 -0
- package/modules/backtest/dist/costs.js.map +1 -0
- package/modules/backtest/dist/cross-sectional/engine.d.ts +21 -0
- package/modules/backtest/dist/cross-sectional/engine.d.ts.map +1 -0
- package/modules/backtest/dist/cross-sectional/engine.js +1399 -0
- package/modules/backtest/dist/cross-sectional/engine.js.map +1 -0
- package/modules/backtest/dist/cross-sectional/folds.d.ts +134 -0
- package/modules/backtest/dist/cross-sectional/folds.d.ts.map +1 -0
- package/modules/backtest/dist/cross-sectional/folds.js +375 -0
- package/modules/backtest/dist/cross-sectional/folds.js.map +1 -0
- package/modules/backtest/dist/cross-sectional/grid.d.ts +142 -0
- package/modules/backtest/dist/cross-sectional/grid.d.ts.map +1 -0
- package/modules/backtest/dist/cross-sectional/grid.js +394 -0
- package/modules/backtest/dist/cross-sectional/grid.js.map +1 -0
- package/modules/backtest/dist/cross-sectional/index.d.ts +18 -0
- package/modules/backtest/dist/cross-sectional/index.d.ts.map +1 -0
- package/modules/backtest/dist/cross-sectional/index.js +15 -0
- package/modules/backtest/dist/cross-sectional/index.js.map +1 -0
- package/modules/backtest/dist/cross-sectional/types.d.ts +331 -0
- package/modules/backtest/dist/cross-sectional/types.d.ts.map +1 -0
- package/modules/backtest/dist/cross-sectional/types.js +12 -0
- package/modules/backtest/dist/cross-sectional/types.js.map +1 -0
- package/modules/backtest/dist/cross-sectional/validate.d.ts +22 -0
- package/modules/backtest/dist/cross-sectional/validate.d.ts.map +1 -0
- package/modules/backtest/dist/cross-sectional/validate.js +489 -0
- package/modules/backtest/dist/cross-sectional/validate.js.map +1 -0
- package/modules/backtest/dist/diagnostics.d.ts +16 -0
- package/modules/backtest/dist/diagnostics.d.ts.map +1 -0
- package/modules/backtest/dist/diagnostics.js +63 -0
- package/modules/backtest/dist/diagnostics.js.map +1 -0
- package/modules/backtest/dist/environment/bench.d.ts +34 -0
- package/modules/backtest/dist/environment/bench.d.ts.map +1 -0
- package/modules/backtest/dist/environment/bench.js +724 -0
- package/modules/backtest/dist/environment/bench.js.map +1 -0
- package/modules/backtest/dist/environment/environment.d.ts +5 -0
- package/modules/backtest/dist/environment/environment.d.ts.map +1 -0
- package/modules/backtest/dist/environment/environment.js +618 -0
- package/modules/backtest/dist/environment/environment.js.map +1 -0
- package/modules/backtest/dist/environment/episode.d.ts +4 -0
- package/modules/backtest/dist/environment/episode.d.ts.map +1 -0
- package/modules/backtest/dist/environment/episode.js +121 -0
- package/modules/backtest/dist/environment/episode.js.map +1 -0
- package/modules/backtest/dist/environment/episodes.d.ts +14 -0
- package/modules/backtest/dist/environment/episodes.d.ts.map +1 -0
- package/modules/backtest/dist/environment/episodes.js +644 -0
- package/modules/backtest/dist/environment/episodes.js.map +1 -0
- package/modules/backtest/dist/environment/features.d.ts +31 -0
- package/modules/backtest/dist/environment/features.d.ts.map +1 -0
- package/modules/backtest/dist/environment/features.js +157 -0
- package/modules/backtest/dist/environment/features.js.map +1 -0
- package/modules/backtest/dist/environment/index.d.ts +14 -0
- package/modules/backtest/dist/environment/index.d.ts.map +1 -0
- package/modules/backtest/dist/environment/index.js +12 -0
- package/modules/backtest/dist/environment/index.js.map +1 -0
- package/modules/backtest/dist/environment/limits.d.ts +63 -0
- package/modules/backtest/dist/environment/limits.d.ts.map +1 -0
- package/modules/backtest/dist/environment/limits.js +253 -0
- package/modules/backtest/dist/environment/limits.js.map +1 -0
- package/modules/backtest/dist/environment/reward.d.ts +5 -0
- package/modules/backtest/dist/environment/reward.d.ts.map +1 -0
- package/modules/backtest/dist/environment/reward.js +80 -0
- package/modules/backtest/dist/environment/reward.js.map +1 -0
- package/modules/backtest/dist/environment/types.d.ts +540 -0
- package/modules/backtest/dist/environment/types.d.ts.map +1 -0
- package/modules/backtest/dist/environment/types.js +2 -0
- package/modules/backtest/dist/environment/types.js.map +1 -0
- package/modules/backtest/dist/environment/validate.d.ts +23 -0
- package/modules/backtest/dist/environment/validate.d.ts.map +1 -0
- package/modules/backtest/dist/environment/validate.js +264 -0
- package/modules/backtest/dist/environment/validate.js.map +1 -0
- package/modules/backtest/dist/event-driven.d.ts +111 -0
- package/modules/backtest/dist/event-driven.d.ts.map +1 -0
- package/modules/backtest/dist/event-driven.js +325 -0
- package/modules/backtest/dist/event-driven.js.map +1 -0
- package/modules/backtest/dist/execution/conformance.d.ts +33 -0
- package/modules/backtest/dist/execution/conformance.d.ts.map +1 -0
- package/modules/backtest/dist/execution/conformance.js +269 -0
- package/modules/backtest/dist/execution/conformance.js.map +1 -0
- package/modules/backtest/dist/execution/fill-models.d.ts +35 -0
- package/modules/backtest/dist/execution/fill-models.d.ts.map +1 -0
- package/modules/backtest/dist/execution/fill-models.js +375 -0
- package/modules/backtest/dist/execution/fill-models.js.map +1 -0
- package/modules/backtest/dist/execution/fill-order.d.ts +55 -0
- package/modules/backtest/dist/execution/fill-order.d.ts.map +1 -0
- package/modules/backtest/dist/execution/fill-order.js +156 -0
- package/modules/backtest/dist/execution/fill-order.js.map +1 -0
- package/modules/backtest/dist/execution/index.d.ts +33 -0
- package/modules/backtest/dist/execution/index.d.ts.map +1 -0
- package/modules/backtest/dist/execution/index.js +27 -0
- package/modules/backtest/dist/execution/index.js.map +1 -0
- package/modules/backtest/dist/execution/intrabar.d.ts +46 -0
- package/modules/backtest/dist/execution/intrabar.d.ts.map +1 -0
- package/modules/backtest/dist/execution/intrabar.js +130 -0
- package/modules/backtest/dist/execution/intrabar.js.map +1 -0
- package/modules/backtest/dist/execution/normalized.d.ts +56 -0
- package/modules/backtest/dist/execution/normalized.d.ts.map +1 -0
- package/modules/backtest/dist/execution/normalized.js +154 -0
- package/modules/backtest/dist/execution/normalized.js.map +1 -0
- package/modules/backtest/dist/execution/policy.d.ts +84 -0
- package/modules/backtest/dist/execution/policy.d.ts.map +1 -0
- package/modules/backtest/dist/execution/policy.js +341 -0
- package/modules/backtest/dist/execution/policy.js.map +1 -0
- package/modules/backtest/dist/execution/types.d.ts +217 -0
- package/modules/backtest/dist/execution/types.d.ts.map +1 -0
- package/modules/backtest/dist/execution/types.js +8 -0
- package/modules/backtest/dist/execution/types.js.map +1 -0
- package/modules/backtest/dist/execution/validate.d.ts +35 -0
- package/modules/backtest/dist/execution/validate.d.ts.map +1 -0
- package/modules/backtest/dist/execution/validate.js +666 -0
- package/modules/backtest/dist/execution/validate.js.map +1 -0
- package/modules/backtest/dist/generated/validation-specs.d.ts +12 -0
- package/modules/backtest/dist/generated/validation-specs.d.ts.map +1 -0
- package/modules/backtest/dist/generated/validation-specs.js +1129 -0
- package/modules/backtest/dist/generated/validation-specs.js.map +1 -0
- package/modules/backtest/dist/index.d.ts +33 -0
- package/modules/backtest/dist/index.d.ts.map +1 -0
- package/modules/backtest/dist/index.js +28 -0
- package/modules/backtest/dist/index.js.map +1 -0
- package/modules/backtest/dist/options/chain.d.ts +68 -0
- package/modules/backtest/dist/options/chain.d.ts.map +1 -0
- package/modules/backtest/dist/options/chain.js +303 -0
- package/modules/backtest/dist/options/chain.js.map +1 -0
- package/modules/backtest/dist/options/engine.d.ts +28 -0
- package/modules/backtest/dist/options/engine.d.ts.map +1 -0
- package/modules/backtest/dist/options/engine.js +1859 -0
- package/modules/backtest/dist/options/engine.js.map +1 -0
- package/modules/backtest/dist/options/index.d.ts +23 -0
- package/modules/backtest/dist/options/index.d.ts.map +1 -0
- package/modules/backtest/dist/options/index.js +21 -0
- package/modules/backtest/dist/options/index.js.map +1 -0
- package/modules/backtest/dist/options/tearsheet.d.ts +77 -0
- package/modules/backtest/dist/options/tearsheet.d.ts.map +1 -0
- package/modules/backtest/dist/options/tearsheet.js +205 -0
- package/modules/backtest/dist/options/tearsheet.js.map +1 -0
- package/modules/backtest/dist/options/types.d.ts +571 -0
- package/modules/backtest/dist/options/types.d.ts.map +1 -0
- package/modules/backtest/dist/options/types.js +19 -0
- package/modules/backtest/dist/options/types.js.map +1 -0
- package/modules/backtest/dist/paper/index.d.ts +13 -0
- package/modules/backtest/dist/paper/index.d.ts.map +1 -0
- package/modules/backtest/dist/paper/index.js +12 -0
- package/modules/backtest/dist/paper/index.js.map +1 -0
- package/modules/backtest/dist/paper/paper.d.ts +8 -0
- package/modules/backtest/dist/paper/paper.d.ts.map +1 -0
- package/modules/backtest/dist/paper/paper.js +950 -0
- package/modules/backtest/dist/paper/paper.js.map +1 -0
- package/modules/backtest/dist/paper/types.d.ts +190 -0
- package/modules/backtest/dist/paper/types.d.ts.map +1 -0
- package/modules/backtest/dist/paper/types.js +3 -0
- package/modules/backtest/dist/paper/types.js.map +1 -0
- package/modules/backtest/dist/paper/validate.d.ts +9 -0
- package/modules/backtest/dist/paper/validate.d.ts.map +1 -0
- package/modules/backtest/dist/paper/validate.js +112 -0
- package/modules/backtest/dist/paper/validate.js.map +1 -0
- package/modules/backtest/dist/portfolio/adapters.d.ts +37 -0
- package/modules/backtest/dist/portfolio/adapters.d.ts.map +1 -0
- package/modules/backtest/dist/portfolio/adapters.js +555 -0
- package/modules/backtest/dist/portfolio/adapters.js.map +1 -0
- package/modules/backtest/dist/portfolio/engine.d.ts +35 -0
- package/modules/backtest/dist/portfolio/engine.d.ts.map +1 -0
- package/modules/backtest/dist/portfolio/engine.js +1300 -0
- package/modules/backtest/dist/portfolio/engine.js.map +1 -0
- package/modules/backtest/dist/portfolio/index.d.ts +12 -0
- package/modules/backtest/dist/portfolio/index.d.ts.map +1 -0
- package/modules/backtest/dist/portfolio/index.js +11 -0
- package/modules/backtest/dist/portfolio/index.js.map +1 -0
- package/modules/backtest/dist/portfolio/types.d.ts +418 -0
- package/modules/backtest/dist/portfolio/types.d.ts.map +1 -0
- package/modules/backtest/dist/portfolio/types.js +8 -0
- package/modules/backtest/dist/portfolio/types.js.map +1 -0
- package/modules/backtest/dist/portfolio/validate.d.ts +26 -0
- package/modules/backtest/dist/portfolio/validate.d.ts.map +1 -0
- package/modules/backtest/dist/portfolio/validate.js +556 -0
- package/modules/backtest/dist/portfolio/validate.js.map +1 -0
- package/modules/backtest/dist/run-artifacts.d.ts +425 -0
- package/modules/backtest/dist/run-artifacts.d.ts.map +1 -0
- package/modules/backtest/dist/run-artifacts.js +1843 -0
- package/modules/backtest/dist/run-artifacts.js.map +1 -0
- package/modules/backtest/dist/signals.d.ts +110 -0
- package/modules/backtest/dist/signals.d.ts.map +1 -0
- package/modules/backtest/dist/signals.js +207 -0
- package/modules/backtest/dist/signals.js.map +1 -0
- package/modules/backtest/dist/tearsheet.d.ts +126 -0
- package/modules/backtest/dist/tearsheet.d.ts.map +1 -0
- package/modules/backtest/dist/tearsheet.js +266 -0
- package/modules/backtest/dist/tearsheet.js.map +1 -0
- package/modules/backtest/dist/types.d.ts +175 -0
- package/modules/backtest/dist/types.d.ts.map +1 -0
- package/modules/backtest/dist/types.js +29 -0
- package/modules/backtest/dist/types.js.map +1 -0
- package/modules/backtest/dist/validate.d.ts +13 -0
- package/modules/backtest/dist/validate.d.ts.map +1 -0
- package/modules/backtest/dist/validate.js +37 -0
- package/modules/backtest/dist/validate.js.map +1 -0
- package/modules/backtest/dist/vectorized.d.ts +53 -0
- package/modules/backtest/dist/vectorized.d.ts.map +1 -0
- package/modules/backtest/dist/vectorized.js +383 -0
- package/modules/backtest/dist/vectorized.js.map +1 -0
- package/modules/backtest/dist/walk-forward.d.ts +57 -0
- package/modules/backtest/dist/walk-forward.d.ts.map +1 -0
- package/modules/backtest/dist/walk-forward.js +125 -0
- package/modules/backtest/dist/walk-forward.js.map +1 -0
- package/modules/backtest/etc/backtest.api.md +139 -0
- package/modules/backtest/src/artifacts.ts +54 -0
- package/modules/backtest/src/broker.ts +1529 -0
- package/modules/backtest/src/costs.ts +225 -0
- package/modules/backtest/src/cross-sectional/engine.ts +1608 -0
- package/modules/backtest/src/cross-sectional/folds.ts +718 -0
- package/modules/backtest/src/cross-sectional/grid.ts +646 -0
- package/modules/backtest/src/cross-sectional/index.ts +76 -0
- package/modules/backtest/src/cross-sectional/types.ts +363 -0
- package/modules/backtest/src/cross-sectional/validate.ts +906 -0
- package/modules/backtest/src/diagnostics.ts +66 -0
- package/modules/backtest/src/environment/bench.ts +1022 -0
- package/modules/backtest/src/environment/environment.ts +766 -0
- package/modules/backtest/src/environment/episode.ts +146 -0
- package/modules/backtest/src/environment/episodes.ts +786 -0
- package/modules/backtest/src/environment/features.ts +184 -0
- package/modules/backtest/src/environment/index.ts +79 -0
- package/modules/backtest/src/environment/limits.ts +383 -0
- package/modules/backtest/src/environment/reward.ts +98 -0
- package/modules/backtest/src/environment/types.ts +595 -0
- package/modules/backtest/src/environment/validate.ts +415 -0
- package/modules/backtest/src/event-driven.ts +528 -0
- package/modules/backtest/src/execution/conformance.ts +346 -0
- package/modules/backtest/src/execution/fill-models.ts +410 -0
- package/modules/backtest/src/execution/fill-order.ts +261 -0
- package/modules/backtest/src/execution/index.ts +91 -0
- package/modules/backtest/src/execution/intrabar.ts +185 -0
- package/modules/backtest/src/execution/normalized.ts +216 -0
- package/modules/backtest/src/execution/policy.ts +447 -0
- package/modules/backtest/src/execution/types.ts +239 -0
- package/modules/backtest/src/execution/validate.ts +889 -0
- package/modules/backtest/src/generated/validation-specs.ts +1132 -0
- package/modules/backtest/src/index.ts +157 -0
- package/modules/backtest/src/options/chain.ts +410 -0
- package/modules/backtest/src/options/engine.ts +2240 -0
- package/modules/backtest/src/options/index.ts +68 -0
- package/modules/backtest/src/options/tearsheet.ts +327 -0
- package/modules/backtest/src/options/types.ts +573 -0
- package/modules/backtest/src/paper/index.ts +27 -0
- package/modules/backtest/src/paper/paper.ts +1288 -0
- package/modules/backtest/src/paper/types.ts +221 -0
- package/modules/backtest/src/paper/validate.ts +168 -0
- package/modules/backtest/src/portfolio/adapters.ts +651 -0
- package/modules/backtest/src/portfolio/engine.ts +1518 -0
- package/modules/backtest/src/portfolio/index.ts +64 -0
- package/modules/backtest/src/portfolio/types.ts +456 -0
- package/modules/backtest/src/portfolio/validate.ts +861 -0
- package/modules/backtest/src/run-artifacts.ts +2873 -0
- package/modules/backtest/src/signals.ts +267 -0
- package/modules/backtest/src/tearsheet.ts +425 -0
- package/modules/backtest/src/types.ts +200 -0
- package/modules/backtest/src/validate.ts +43 -0
- package/modules/backtest/src/vectorized.ts +541 -0
- package/modules/backtest/src/walk-forward.ts +215 -0
- package/modules/calendars/dist/cboe.d.ts +15 -0
- package/modules/calendars/dist/cboe.d.ts.map +1 -0
- package/modules/calendars/dist/cboe.js +16 -0
- package/modules/calendars/dist/cboe.js.map +1 -0
- package/modules/calendars/dist/crypto.d.ts +15 -0
- package/modules/calendars/dist/crypto.d.ts.map +1 -0
- package/modules/calendars/dist/crypto.js +16 -0
- package/modules/calendars/dist/crypto.js.map +1 -0
- package/modules/calendars/dist/expirations.d.ts +35 -0
- package/modules/calendars/dist/expirations.d.ts.map +1 -0
- package/modules/calendars/dist/expirations.js +158 -0
- package/modules/calendars/dist/expirations.js.map +1 -0
- package/modules/calendars/dist/index.d.ts +16 -0
- package/modules/calendars/dist/index.d.ts.map +1 -0
- package/modules/calendars/dist/index.js +13 -0
- package/modules/calendars/dist/index.js.map +1 -0
- package/modules/calendars/dist/nyse.d.ts +11 -0
- package/modules/calendars/dist/nyse.d.ts.map +1 -0
- package/modules/calendars/dist/nyse.js +12 -0
- package/modules/calendars/dist/nyse.js.map +1 -0
- package/modules/calendars/dist/trading-calendar.d.ts +32 -0
- package/modules/calendars/dist/trading-calendar.d.ts.map +1 -0
- package/modules/calendars/dist/trading-calendar.js +67 -0
- package/modules/calendars/dist/trading-calendar.js.map +1 -0
- package/modules/calendars/dist/us-market.d.ts +29 -0
- package/modules/calendars/dist/us-market.d.ts.map +1 -0
- package/modules/calendars/dist/us-market.js +72 -0
- package/modules/calendars/dist/us-market.js.map +1 -0
- package/modules/calendars/etc/calendars.api.md +22 -0
- package/modules/calendars/src/cboe.ts +17 -0
- package/modules/calendars/src/crypto.ts +17 -0
- package/modules/calendars/src/expirations.ts +200 -0
- package/modules/calendars/src/index.ts +23 -0
- package/modules/calendars/src/nyse.ts +13 -0
- package/modules/calendars/src/trading-calendar.ts +85 -0
- package/modules/calendars/src/us-market.ts +86 -0
- package/modules/cli/dist/bin.d.ts +9 -0
- package/modules/cli/dist/bin.d.ts.map +1 -0
- package/modules/cli/dist/bin.js +458 -0
- package/modules/cli/dist/bin.js.map +1 -0
- package/modules/cli/dist/commands.d.ts +7 -0
- package/modules/cli/dist/commands.d.ts.map +1 -0
- package/modules/cli/dist/commands.js +17 -0
- package/modules/cli/dist/commands.js.map +1 -0
- package/modules/cli/dist/exit-codes.d.ts +20 -0
- package/modules/cli/dist/exit-codes.d.ts.map +1 -0
- package/modules/cli/dist/exit-codes.js +19 -0
- package/modules/cli/dist/exit-codes.js.map +1 -0
- package/modules/cli/dist/index.d.ts +13 -0
- package/modules/cli/dist/index.d.ts.map +1 -0
- package/modules/cli/dist/index.js +10 -0
- package/modules/cli/dist/index.js.map +1 -0
- package/modules/cli/etc/cli.api.md +25 -0
- package/modules/cli/src/bin.ts +530 -0
- package/modules/cli/src/commands.ts +19 -0
- package/modules/cli/src/exit-codes.ts +21 -0
- package/modules/cli/src/index.ts +29 -0
- package/modules/commodities/dist/forwards.d.ts +274 -0
- package/modules/commodities/dist/forwards.d.ts.map +1 -0
- package/modules/commodities/dist/forwards.js +359 -0
- package/modules/commodities/dist/forwards.js.map +1 -0
- package/modules/commodities/dist/index.d.ts +10 -0
- package/modules/commodities/dist/index.d.ts.map +1 -0
- package/modules/commodities/dist/index.js +10 -0
- package/modules/commodities/dist/index.js.map +1 -0
- package/modules/commodities/dist/internal.d.ts +6 -0
- package/modules/commodities/dist/internal.d.ts.map +1 -0
- package/modules/commodities/dist/internal.js +6 -0
- package/modules/commodities/dist/internal.js.map +1 -0
- package/modules/commodities/dist/term-structure.d.ts +327 -0
- package/modules/commodities/dist/term-structure.d.ts.map +1 -0
- package/modules/commodities/dist/term-structure.js +416 -0
- package/modules/commodities/dist/term-structure.js.map +1 -0
- package/modules/commodities/etc/commodities.api.md +53 -0
- package/modules/commodities/src/forwards.ts +791 -0
- package/modules/commodities/src/index.ts +10 -0
- package/modules/commodities/src/internal.ts +6 -0
- package/modules/commodities/src/term-structure.ts +828 -0
- package/modules/core/dist/artifacts/analysis-artifact.d.ts +140 -0
- package/modules/core/dist/artifacts/analysis-artifact.d.ts.map +1 -0
- package/modules/core/dist/artifacts/analysis-artifact.js +356 -0
- package/modules/core/dist/artifacts/analysis-artifact.js.map +1 -0
- package/modules/core/dist/artifacts/calculation-comparison.d.ts +125 -0
- package/modules/core/dist/artifacts/calculation-comparison.d.ts.map +1 -0
- package/modules/core/dist/artifacts/calculation-comparison.js +444 -0
- package/modules/core/dist/artifacts/calculation-comparison.js.map +1 -0
- package/modules/core/dist/artifacts/canonical-scan.d.ts +58 -0
- package/modules/core/dist/artifacts/canonical-scan.d.ts.map +1 -0
- package/modules/core/dist/artifacts/canonical-scan.js +250 -0
- package/modules/core/dist/artifacts/canonical-scan.js.map +1 -0
- package/modules/core/dist/artifacts/comparison.d.ts +179 -0
- package/modules/core/dist/artifacts/comparison.d.ts.map +1 -0
- package/modules/core/dist/artifacts/comparison.js +383 -0
- package/modules/core/dist/artifacts/comparison.js.map +1 -0
- package/modules/core/dist/artifacts/content-hash.d.ts +38 -0
- package/modules/core/dist/artifacts/content-hash.d.ts.map +1 -0
- package/modules/core/dist/artifacts/content-hash.js +170 -0
- package/modules/core/dist/artifacts/content-hash.js.map +1 -0
- package/modules/core/dist/artifacts/deep-freeze.d.ts +8 -0
- package/modules/core/dist/artifacts/deep-freeze.d.ts.map +1 -0
- package/modules/core/dist/artifacts/deep-freeze.js +16 -0
- package/modules/core/dist/artifacts/deep-freeze.js.map +1 -0
- package/modules/core/dist/artifacts/fitted-model-kit.d.ts +123 -0
- package/modules/core/dist/artifacts/fitted-model-kit.d.ts.map +1 -0
- package/modules/core/dist/artifacts/fitted-model-kit.js +281 -0
- package/modules/core/dist/artifacts/fitted-model-kit.js.map +1 -0
- package/modules/core/dist/artifacts/fitted-model-summary.d.ts +73 -0
- package/modules/core/dist/artifacts/fitted-model-summary.d.ts.map +1 -0
- package/modules/core/dist/artifacts/fitted-model-summary.js +254 -0
- package/modules/core/dist/artifacts/fitted-model-summary.js.map +1 -0
- package/modules/core/dist/artifacts/index.d.ts +52 -0
- package/modules/core/dist/artifacts/index.d.ts.map +1 -0
- package/modules/core/dist/artifacts/index.js +47 -0
- package/modules/core/dist/artifacts/index.js.map +1 -0
- package/modules/core/dist/artifacts/market-snapshot.d.ts +189 -0
- package/modules/core/dist/artifacts/market-snapshot.d.ts.map +1 -0
- package/modules/core/dist/artifacts/market-snapshot.js +517 -0
- package/modules/core/dist/artifacts/market-snapshot.js.map +1 -0
- package/modules/core/dist/artifacts/migration.d.ts +60 -0
- package/modules/core/dist/artifacts/migration.d.ts.map +1 -0
- package/modules/core/dist/artifacts/migration.js +106 -0
- package/modules/core/dist/artifacts/migration.js.map +1 -0
- package/modules/core/dist/artifacts/numeric-comparison.d.ts +12 -0
- package/modules/core/dist/artifacts/numeric-comparison.d.ts.map +1 -0
- package/modules/core/dist/artifacts/numeric-comparison.js +53 -0
- package/modules/core/dist/artifacts/numeric-comparison.js.map +1 -0
- package/modules/core/dist/artifacts/scenario-set.d.ts +97 -0
- package/modules/core/dist/artifacts/scenario-set.d.ts.map +1 -0
- package/modules/core/dist/artifacts/scenario-set.js +249 -0
- package/modules/core/dist/artifacts/scenario-set.js.map +1 -0
- package/modules/core/dist/artifacts/table-handle.d.ts +96 -0
- package/modules/core/dist/artifacts/table-handle.d.ts.map +1 -0
- package/modules/core/dist/artifacts/table-handle.js +253 -0
- package/modules/core/dist/artifacts/table-handle.js.map +1 -0
- package/modules/core/dist/assumptions.d.ts +52 -0
- package/modules/core/dist/assumptions.d.ts.map +1 -0
- package/modules/core/dist/assumptions.js +13 -0
- package/modules/core/dist/assumptions.js.map +1 -0
- package/modules/core/dist/calendar.d.ts +98 -0
- package/modules/core/dist/calendar.d.ts.map +1 -0
- package/modules/core/dist/calendar.js +301 -0
- package/modules/core/dist/calendar.js.map +1 -0
- package/modules/core/dist/canonical-json.d.ts +63 -0
- package/modules/core/dist/canonical-json.d.ts.map +1 -0
- package/modules/core/dist/canonical-json.js +241 -0
- package/modules/core/dist/canonical-json.js.map +1 -0
- package/modules/core/dist/computed.d.ts +31 -0
- package/modules/core/dist/computed.d.ts.map +1 -0
- package/modules/core/dist/computed.js +40 -0
- package/modules/core/dist/computed.js.map +1 -0
- package/modules/core/dist/contracts.d.ts +59 -0
- package/modules/core/dist/contracts.d.ts.map +1 -0
- package/modules/core/dist/contracts.js +9 -0
- package/modules/core/dist/contracts.js.map +1 -0
- package/modules/core/dist/dates.d.ts +31 -0
- package/modules/core/dist/dates.d.ts.map +1 -0
- package/modules/core/dist/dates.js +126 -0
- package/modules/core/dist/dates.js.map +1 -0
- package/modules/core/dist/diagnostics.d.ts +278 -0
- package/modules/core/dist/diagnostics.d.ts.map +1 -0
- package/modules/core/dist/diagnostics.js +287 -0
- package/modules/core/dist/diagnostics.js.map +1 -0
- package/modules/core/dist/errors.d.ts +324 -0
- package/modules/core/dist/errors.d.ts.map +1 -0
- package/modules/core/dist/errors.js +363 -0
- package/modules/core/dist/errors.js.map +1 -0
- package/modules/core/dist/facade.d.ts +97 -0
- package/modules/core/dist/facade.d.ts.map +1 -0
- package/modules/core/dist/facade.js +354 -0
- package/modules/core/dist/facade.js.map +1 -0
- package/modules/core/dist/index.d.ts +45 -0
- package/modules/core/dist/index.d.ts.map +1 -0
- package/modules/core/dist/index.js +23 -0
- package/modules/core/dist/index.js.map +1 -0
- package/modules/core/dist/invariants.d.ts +112 -0
- package/modules/core/dist/invariants.d.ts.map +1 -0
- package/modules/core/dist/invariants.js +240 -0
- package/modules/core/dist/invariants.js.map +1 -0
- package/modules/core/dist/market-data.d.ts +219 -0
- package/modules/core/dist/market-data.d.ts.map +1 -0
- package/modules/core/dist/market-data.js +183 -0
- package/modules/core/dist/market-data.js.map +1 -0
- package/modules/core/dist/numeric.d.ts +46 -0
- package/modules/core/dist/numeric.d.ts.map +1 -0
- package/modules/core/dist/numeric.js +145 -0
- package/modules/core/dist/numeric.js.map +1 -0
- package/modules/core/dist/orders.d.ts +28 -0
- package/modules/core/dist/orders.d.ts.map +1 -0
- package/modules/core/dist/orders.js +49 -0
- package/modules/core/dist/orders.js.map +1 -0
- package/modules/core/dist/pricing.d.ts +418 -0
- package/modules/core/dist/pricing.d.ts.map +1 -0
- package/modules/core/dist/pricing.js +987 -0
- package/modules/core/dist/pricing.js.map +1 -0
- package/modules/core/dist/provenance.d.ts +25 -0
- package/modules/core/dist/provenance.d.ts.map +1 -0
- package/modules/core/dist/provenance.js +75 -0
- package/modules/core/dist/provenance.js.map +1 -0
- package/modules/core/dist/schema/index.d.ts +14 -0
- package/modules/core/dist/schema/index.d.ts.map +1 -0
- package/modules/core/dist/schema/index.js +12 -0
- package/modules/core/dist/schema/index.js.map +1 -0
- package/modules/core/dist/schema/json-schema-guard.d.ts +21 -0
- package/modules/core/dist/schema/json-schema-guard.d.ts.map +1 -0
- package/modules/core/dist/schema/json-schema-guard.js +114 -0
- package/modules/core/dist/schema/json-schema-guard.js.map +1 -0
- package/modules/core/dist/schema/json-schema.d.ts +33 -0
- package/modules/core/dist/schema/json-schema.d.ts.map +1 -0
- package/modules/core/dist/schema/json-schema.js +3 -0
- package/modules/core/dist/schema/json-schema.js.map +1 -0
- package/modules/core/dist/schema/payloads.d.ts +429 -0
- package/modules/core/dist/schema/payloads.d.ts.map +1 -0
- package/modules/core/dist/schema/payloads.js +323 -0
- package/modules/core/dist/schema/payloads.js.map +1 -0
- package/modules/core/dist/schema/schema.d.ts +282 -0
- package/modules/core/dist/schema/schema.d.ts.map +1 -0
- package/modules/core/dist/schema/schema.js +780 -0
- package/modules/core/dist/schema/schema.js.map +1 -0
- package/modules/core/dist/schema/standard.d.ts +32 -0
- package/modules/core/dist/schema/standard.d.ts.map +1 -0
- package/modules/core/dist/schema/standard.js +8 -0
- package/modules/core/dist/schema/standard.js.map +1 -0
- package/modules/core/dist/symbology.d.ts +30 -0
- package/modules/core/dist/symbology.d.ts.map +1 -0
- package/modules/core/dist/symbology.js +126 -0
- package/modules/core/dist/symbology.js.map +1 -0
- package/modules/core/dist/time.d.ts +122 -0
- package/modules/core/dist/time.d.ts.map +1 -0
- package/modules/core/dist/time.js +349 -0
- package/modules/core/dist/time.js.map +1 -0
- package/modules/core/dist/validation-codes.d.ts +24 -0
- package/modules/core/dist/validation-codes.d.ts.map +1 -0
- package/modules/core/dist/validation-codes.js +24 -0
- package/modules/core/dist/validation-codes.js.map +1 -0
- package/modules/core/dist/validation.d.ts +117 -0
- package/modules/core/dist/validation.d.ts.map +1 -0
- package/modules/core/dist/validation.js +415 -0
- package/modules/core/dist/validation.js.map +1 -0
- package/modules/core/etc/core.api.md +157 -0
- package/modules/core/src/artifacts/analysis-artifact.ts +515 -0
- package/modules/core/src/artifacts/calculation-comparison.ts +641 -0
- package/modules/core/src/artifacts/canonical-scan.ts +358 -0
- package/modules/core/src/artifacts/comparison.ts +586 -0
- package/modules/core/src/artifacts/content-hash.ts +183 -0
- package/modules/core/src/artifacts/deep-freeze.ts +15 -0
- package/modules/core/src/artifacts/fitted-model-kit.ts +402 -0
- package/modules/core/src/artifacts/fitted-model-summary.ts +478 -0
- package/modules/core/src/artifacts/index.ts +155 -0
- package/modules/core/src/artifacts/market-snapshot.ts +787 -0
- package/modules/core/src/artifacts/migration.ts +195 -0
- package/modules/core/src/artifacts/numeric-comparison.ts +71 -0
- package/modules/core/src/artifacts/scenario-set.ts +383 -0
- package/modules/core/src/artifacts/table-handle.ts +329 -0
- package/modules/core/src/assumptions.ts +62 -0
- package/modules/core/src/calendar.ts +407 -0
- package/modules/core/src/canonical-json.ts +289 -0
- package/modules/core/src/computed.ts +55 -0
- package/modules/core/src/contracts.ts +63 -0
- package/modules/core/src/dates.ts +163 -0
- package/modules/core/src/diagnostics.ts +397 -0
- package/modules/core/src/errors.ts +404 -0
- package/modules/core/src/facade.ts +436 -0
- package/modules/core/src/index.ts +185 -0
- package/modules/core/src/invariants.ts +339 -0
- package/modules/core/src/market-data.ts +481 -0
- package/modules/core/src/numeric.ts +205 -0
- package/modules/core/src/orders.ts +71 -0
- package/modules/core/src/pricing.ts +1647 -0
- package/modules/core/src/provenance.ts +121 -0
- package/modules/core/src/schema/index.ts +61 -0
- package/modules/core/src/schema/json-schema-guard.ts +172 -0
- package/modules/core/src/schema/json-schema.ts +52 -0
- package/modules/core/src/schema/payloads.ts +364 -0
- package/modules/core/src/schema/schema.ts +986 -0
- package/modules/core/src/schema/standard.ts +40 -0
- package/modules/core/src/symbology.ts +170 -0
- package/modules/core/src/time.ts +458 -0
- package/modules/core/src/validation-codes.ts +23 -0
- package/modules/core/src/validation.ts +607 -0
- package/modules/crypto/dist/carry.d.ts +176 -0
- package/modules/crypto/dist/carry.d.ts.map +1 -0
- package/modules/crypto/dist/carry.js +349 -0
- package/modules/crypto/dist/carry.js.map +1 -0
- package/modules/crypto/dist/curve.d.ts +69 -0
- package/modules/crypto/dist/curve.d.ts.map +1 -0
- package/modules/crypto/dist/curve.js +180 -0
- package/modules/crypto/dist/curve.js.map +1 -0
- package/modules/crypto/dist/index.d.ts +20 -0
- package/modules/crypto/dist/index.d.ts.map +1 -0
- package/modules/crypto/dist/index.js +16 -0
- package/modules/crypto/dist/index.js.map +1 -0
- package/modules/crypto/dist/inverse.d.ts +61 -0
- package/modules/crypto/dist/inverse.d.ts.map +1 -0
- package/modules/crypto/dist/inverse.js +89 -0
- package/modules/crypto/dist/inverse.js.map +1 -0
- package/modules/crypto/dist/liquidation.d.ts +67 -0
- package/modules/crypto/dist/liquidation.d.ts.map +1 -0
- package/modules/crypto/dist/liquidation.js +103 -0
- package/modules/crypto/dist/liquidation.js.map +1 -0
- package/modules/crypto/etc/crypto.api.md +45 -0
- package/modules/crypto/src/carry.ts +656 -0
- package/modules/crypto/src/curve.ts +273 -0
- package/modules/crypto/src/index.ts +62 -0
- package/modules/crypto/src/inverse.ts +172 -0
- package/modules/crypto/src/liquidation.ts +174 -0
- package/modules/fixed-income/dist/artifacts.d.ts +24 -0
- package/modules/fixed-income/dist/artifacts.d.ts.map +1 -0
- package/modules/fixed-income/dist/artifacts.js +21 -0
- package/modules/fixed-income/dist/artifacts.js.map +1 -0
- package/modules/fixed-income/dist/bonds.d.ts +298 -0
- package/modules/fixed-income/dist/bonds.d.ts.map +1 -0
- package/modules/fixed-income/dist/bonds.js +951 -0
- package/modules/fixed-income/dist/bonds.js.map +1 -0
- package/modules/fixed-income/dist/conventions.d.ts +77 -0
- package/modules/fixed-income/dist/conventions.d.ts.map +1 -0
- package/modules/fixed-income/dist/conventions.js +266 -0
- package/modules/fixed-income/dist/conventions.js.map +1 -0
- package/modules/fixed-income/dist/convertible.d.ts +76 -0
- package/modules/fixed-income/dist/convertible.d.ts.map +1 -0
- package/modules/fixed-income/dist/convertible.js +182 -0
- package/modules/fixed-income/dist/convertible.js.map +1 -0
- package/modules/fixed-income/dist/credit.d.ts +227 -0
- package/modules/fixed-income/dist/credit.d.ts.map +1 -0
- package/modules/fixed-income/dist/credit.js +653 -0
- package/modules/fixed-income/dist/credit.js.map +1 -0
- package/modules/fixed-income/dist/cross-currency.d.ts +82 -0
- package/modules/fixed-income/dist/cross-currency.d.ts.map +1 -0
- package/modules/fixed-income/dist/cross-currency.js +93 -0
- package/modules/fixed-income/dist/cross-currency.js.map +1 -0
- package/modules/fixed-income/dist/curve-data.d.ts +70 -0
- package/modules/fixed-income/dist/curve-data.d.ts.map +1 -0
- package/modules/fixed-income/dist/curve-data.js +254 -0
- package/modules/fixed-income/dist/curve-data.js.map +1 -0
- package/modules/fixed-income/dist/curve-mappers.d.ts +57 -0
- package/modules/fixed-income/dist/curve-mappers.d.ts.map +1 -0
- package/modules/fixed-income/dist/curve-mappers.js +131 -0
- package/modules/fixed-income/dist/curve-mappers.js.map +1 -0
- package/modules/fixed-income/dist/curve-state.d.ts +47 -0
- package/modules/fixed-income/dist/curve-state.d.ts.map +1 -0
- package/modules/fixed-income/dist/curve-state.js +33 -0
- package/modules/fixed-income/dist/curve-state.js.map +1 -0
- package/modules/fixed-income/dist/curves.d.ts +198 -0
- package/modules/fixed-income/dist/curves.d.ts.map +1 -0
- package/modules/fixed-income/dist/curves.js +803 -0
- package/modules/fixed-income/dist/curves.js.map +1 -0
- package/modules/fixed-income/dist/fitted-model-artifacts.d.ts +277 -0
- package/modules/fixed-income/dist/fitted-model-artifacts.d.ts.map +1 -0
- package/modules/fixed-income/dist/fitted-model-artifacts.js +839 -0
- package/modules/fixed-income/dist/fitted-model-artifacts.js.map +1 -0
- package/modules/fixed-income/dist/fitted-model-families.d.ts +170 -0
- package/modules/fixed-income/dist/fitted-model-families.d.ts.map +1 -0
- package/modules/fixed-income/dist/fitted-model-families.js +461 -0
- package/modules/fixed-income/dist/fitted-model-families.js.map +1 -0
- package/modules/fixed-income/dist/futures.d.ts +264 -0
- package/modules/fixed-income/dist/futures.d.ts.map +1 -0
- package/modules/fixed-income/dist/futures.js +630 -0
- package/modules/fixed-income/dist/futures.js.map +1 -0
- package/modules/fixed-income/dist/generated/validation-specs.d.ts +12 -0
- package/modules/fixed-income/dist/generated/validation-specs.d.ts.map +1 -0
- package/modules/fixed-income/dist/generated/validation-specs.js +556 -0
- package/modules/fixed-income/dist/generated/validation-specs.js.map +1 -0
- package/modules/fixed-income/dist/index.d.ts +36 -0
- package/modules/fixed-income/dist/index.d.ts.map +1 -0
- package/modules/fixed-income/dist/index.js +37 -0
- package/modules/fixed-income/dist/index.js.map +1 -0
- package/modules/fixed-income/dist/inflation.d.ts +174 -0
- package/modules/fixed-income/dist/inflation.d.ts.map +1 -0
- package/modules/fixed-income/dist/inflation.js +335 -0
- package/modules/fixed-income/dist/inflation.js.map +1 -0
- package/modules/fixed-income/dist/lattice.d.ts +156 -0
- package/modules/fixed-income/dist/lattice.d.ts.map +1 -0
- package/modules/fixed-income/dist/lattice.js +433 -0
- package/modules/fixed-income/dist/lattice.js.map +1 -0
- package/modules/fixed-income/dist/models.d.ts +187 -0
- package/modules/fixed-income/dist/models.d.ts.map +1 -0
- package/modules/fixed-income/dist/models.js +580 -0
- package/modules/fixed-income/dist/models.js.map +1 -0
- package/modules/fixed-income/dist/pricer.d.ts +48 -0
- package/modules/fixed-income/dist/pricer.d.ts.map +1 -0
- package/modules/fixed-income/dist/pricer.js +445 -0
- package/modules/fixed-income/dist/pricer.js.map +1 -0
- package/modules/fixed-income/dist/rates.d.ts +305 -0
- package/modules/fixed-income/dist/rates.d.ts.map +1 -0
- package/modules/fixed-income/dist/rates.js +686 -0
- package/modules/fixed-income/dist/rates.js.map +1 -0
- package/modules/fixed-income/dist/validate.d.ts +28 -0
- package/modules/fixed-income/dist/validate.d.ts.map +1 -0
- package/modules/fixed-income/dist/validate.js +123 -0
- package/modules/fixed-income/dist/validate.js.map +1 -0
- package/modules/fixed-income/dist/xva.d.ts +88 -0
- package/modules/fixed-income/dist/xva.d.ts.map +1 -0
- package/modules/fixed-income/dist/xva.js +316 -0
- package/modules/fixed-income/dist/xva.js.map +1 -0
- package/modules/fixed-income/etc/fixed-income.api.md +195 -0
- package/modules/fixed-income/src/artifacts.ts +60 -0
- package/modules/fixed-income/src/bonds.ts +1514 -0
- package/modules/fixed-income/src/conventions.ts +387 -0
- package/modules/fixed-income/src/convertible.ts +286 -0
- package/modules/fixed-income/src/credit.ts +1065 -0
- package/modules/fixed-income/src/cross-currency.ts +176 -0
- package/modules/fixed-income/src/curve-data.ts +381 -0
- package/modules/fixed-income/src/curve-mappers.ts +170 -0
- package/modules/fixed-income/src/curve-state.ts +70 -0
- package/modules/fixed-income/src/curves.ts +1169 -0
- package/modules/fixed-income/src/fitted-model-artifacts.ts +1414 -0
- package/modules/fixed-income/src/fitted-model-families.ts +834 -0
- package/modules/fixed-income/src/futures.ts +1018 -0
- package/modules/fixed-income/src/generated/validation-specs.ts +559 -0
- package/modules/fixed-income/src/index.ts +241 -0
- package/modules/fixed-income/src/inflation.ts +554 -0
- package/modules/fixed-income/src/lattice.ts +675 -0
- package/modules/fixed-income/src/models.ts +897 -0
- package/modules/fixed-income/src/pricer.ts +624 -0
- package/modules/fixed-income/src/rates.ts +1086 -0
- package/modules/fixed-income/src/validate.ts +169 -0
- package/modules/fixed-income/src/xva.ts +466 -0
- package/modules/foreign-exchange/dist/exposure.d.ts +140 -0
- package/modules/foreign-exchange/dist/exposure.d.ts.map +1 -0
- package/modules/foreign-exchange/dist/exposure.js +253 -0
- package/modules/foreign-exchange/dist/exposure.js.map +1 -0
- package/modules/foreign-exchange/dist/forwards.d.ts +159 -0
- package/modules/foreign-exchange/dist/forwards.d.ts.map +1 -0
- package/modules/foreign-exchange/dist/forwards.js +310 -0
- package/modules/foreign-exchange/dist/forwards.js.map +1 -0
- package/modules/foreign-exchange/dist/index.d.ts +11 -0
- package/modules/foreign-exchange/dist/index.d.ts.map +1 -0
- package/modules/foreign-exchange/dist/index.js +11 -0
- package/modules/foreign-exchange/dist/index.js.map +1 -0
- package/modules/foreign-exchange/dist/internal.d.ts +6 -0
- package/modules/foreign-exchange/dist/internal.d.ts.map +1 -0
- package/modules/foreign-exchange/dist/internal.js +6 -0
- package/modules/foreign-exchange/dist/internal.js.map +1 -0
- package/modules/foreign-exchange/dist/spot.d.ts +150 -0
- package/modules/foreign-exchange/dist/spot.d.ts.map +1 -0
- package/modules/foreign-exchange/dist/spot.js +289 -0
- package/modules/foreign-exchange/dist/spot.js.map +1 -0
- package/modules/foreign-exchange/etc/foreign-exchange.api.md +52 -0
- package/modules/foreign-exchange/src/exposure.ts +485 -0
- package/modules/foreign-exchange/src/forwards.ts +595 -0
- package/modules/foreign-exchange/src/index.ts +11 -0
- package/modules/foreign-exchange/src/internal.ts +6 -0
- package/modules/foreign-exchange/src/spot.ts +530 -0
- package/modules/fundamentals/dist/analyze.d.ts +90 -0
- package/modules/fundamentals/dist/analyze.d.ts.map +1 -0
- package/modules/fundamentals/dist/analyze.js +293 -0
- package/modules/fundamentals/dist/analyze.js.map +1 -0
- package/modules/fundamentals/dist/index.d.ts +17 -0
- package/modules/fundamentals/dist/index.d.ts.map +1 -0
- package/modules/fundamentals/dist/index.js +15 -0
- package/modules/fundamentals/dist/index.js.map +1 -0
- package/modules/fundamentals/dist/periods.d.ts +47 -0
- package/modules/fundamentals/dist/periods.d.ts.map +1 -0
- package/modules/fundamentals/dist/periods.js +106 -0
- package/modules/fundamentals/dist/periods.js.map +1 -0
- package/modules/fundamentals/dist/ratio-heads.d.ts +47 -0
- package/modules/fundamentals/dist/ratio-heads.d.ts.map +1 -0
- package/modules/fundamentals/dist/ratio-heads.js +766 -0
- package/modules/fundamentals/dist/ratio-heads.js.map +1 -0
- package/modules/fundamentals/dist/ratio-internals.d.ts +187 -0
- package/modules/fundamentals/dist/ratio-internals.d.ts.map +1 -0
- package/modules/fundamentals/dist/ratio-internals.js +299 -0
- package/modules/fundamentals/dist/ratio-internals.js.map +1 -0
- package/modules/fundamentals/dist/ratios.d.ts +9 -0
- package/modules/fundamentals/dist/ratios.d.ts.map +1 -0
- package/modules/fundamentals/dist/ratios.js +8 -0
- package/modules/fundamentals/dist/ratios.js.map +1 -0
- package/modules/fundamentals/dist/score-heads.d.ts +130 -0
- package/modules/fundamentals/dist/score-heads.d.ts.map +1 -0
- package/modules/fundamentals/dist/score-heads.js +364 -0
- package/modules/fundamentals/dist/score-heads.js.map +1 -0
- package/modules/fundamentals/dist/scores.d.ts +6 -0
- package/modules/fundamentals/dist/scores.d.ts.map +1 -0
- package/modules/fundamentals/dist/scores.js +6 -0
- package/modules/fundamentals/dist/scores.js.map +1 -0
- package/modules/fundamentals/dist/statement-contracts.d.ts +170 -0
- package/modules/fundamentals/dist/statement-contracts.d.ts.map +1 -0
- package/modules/fundamentals/dist/statement-contracts.js +207 -0
- package/modules/fundamentals/dist/statement-contracts.js.map +1 -0
- package/modules/fundamentals/dist/statement-utilities.d.ts +190 -0
- package/modules/fundamentals/dist/statement-utilities.d.ts.map +1 -0
- package/modules/fundamentals/dist/statement-utilities.js +501 -0
- package/modules/fundamentals/dist/statement-utilities.js.map +1 -0
- package/modules/fundamentals/dist/statements.d.ts +8 -0
- package/modules/fundamentals/dist/statements.d.ts.map +1 -0
- package/modules/fundamentals/dist/statements.js +7 -0
- package/modules/fundamentals/dist/statements.js.map +1 -0
- package/modules/fundamentals/etc/fundamentals.api.md +110 -0
- package/modules/fundamentals/src/analyze.ts +401 -0
- package/modules/fundamentals/src/index.ts +24 -0
- package/modules/fundamentals/src/periods.ts +197 -0
- package/modules/fundamentals/src/ratio-heads.ts +945 -0
- package/modules/fundamentals/src/ratio-internals.ts +562 -0
- package/modules/fundamentals/src/ratios.ts +23 -0
- package/modules/fundamentals/src/score-heads.ts +651 -0
- package/modules/fundamentals/src/scores.ts +6 -0
- package/modules/fundamentals/src/statement-contracts.ts +393 -0
- package/modules/fundamentals/src/statement-utilities.ts +833 -0
- package/modules/fundamentals/src/statements.ts +22 -0
- package/modules/http/dist/bin.d.ts +7 -0
- package/modules/http/dist/bin.d.ts.map +1 -0
- package/modules/http/dist/bin.js +167 -0
- package/modules/http/dist/bin.js.map +1 -0
- package/modules/http/dist/index.d.ts +10 -0
- package/modules/http/dist/index.d.ts.map +1 -0
- package/modules/http/dist/index.js +8 -0
- package/modules/http/dist/index.js.map +1 -0
- package/modules/http/dist/openapi.d.ts +38 -0
- package/modules/http/dist/openapi.d.ts.map +1 -0
- package/modules/http/dist/openapi.js +431 -0
- package/modules/http/dist/openapi.js.map +1 -0
- package/modules/http/dist/security.d.ts +21 -0
- package/modules/http/dist/security.d.ts.map +1 -0
- package/modules/http/dist/security.js +116 -0
- package/modules/http/dist/security.js.map +1 -0
- package/modules/http/dist/server.d.ts +63 -0
- package/modules/http/dist/server.d.ts.map +1 -0
- package/modules/http/dist/server.js +544 -0
- package/modules/http/dist/server.js.map +1 -0
- package/modules/http/etc/http.api.md +15 -0
- package/modules/http/etc/openapi.json +51958 -0
- package/modules/http/src/bin.ts +190 -0
- package/modules/http/src/index.ts +10 -0
- package/modules/http/src/openapi.ts +488 -0
- package/modules/http/src/security.ts +158 -0
- package/modules/http/src/server.ts +941 -0
- package/modules/math/dist/bivariate.d.ts +17 -0
- package/modules/math/dist/bivariate.d.ts.map +1 -0
- package/modules/math/dist/bivariate.js +123 -0
- package/modules/math/dist/bivariate.js.map +1 -0
- package/modules/math/dist/distributions.d.ts +66 -0
- package/modules/math/dist/distributions.d.ts.map +1 -0
- package/modules/math/dist/distributions.js +465 -0
- package/modules/math/dist/distributions.js.map +1 -0
- package/modules/math/dist/filters.d.ts +96 -0
- package/modules/math/dist/filters.d.ts.map +1 -0
- package/modules/math/dist/filters.js +347 -0
- package/modules/math/dist/filters.js.map +1 -0
- package/modules/math/dist/index.d.ts +34 -0
- package/modules/math/dist/index.d.ts.map +1 -0
- package/modules/math/dist/index.js +23 -0
- package/modules/math/dist/index.js.map +1 -0
- package/modules/math/dist/integration.d.ts +58 -0
- package/modules/math/dist/integration.d.ts.map +1 -0
- package/modules/math/dist/integration.js +176 -0
- package/modules/math/dist/integration.js.map +1 -0
- package/modules/math/dist/interpolation.d.ts +57 -0
- package/modules/math/dist/interpolation.d.ts.map +1 -0
- package/modules/math/dist/interpolation.js +464 -0
- package/modules/math/dist/interpolation.js.map +1 -0
- package/modules/math/dist/linalg.d.ts +251 -0
- package/modules/math/dist/linalg.d.ts.map +1 -0
- package/modules/math/dist/linalg.js +1503 -0
- package/modules/math/dist/linalg.js.map +1 -0
- package/modules/math/dist/lowdiscrepancy.d.ts +21 -0
- package/modules/math/dist/lowdiscrepancy.d.ts.map +1 -0
- package/modules/math/dist/lowdiscrepancy.js +200 -0
- package/modules/math/dist/lowdiscrepancy.js.map +1 -0
- package/modules/math/dist/montecarlo.d.ts +58 -0
- package/modules/math/dist/montecarlo.d.ts.map +1 -0
- package/modules/math/dist/montecarlo.js +248 -0
- package/modules/math/dist/montecarlo.js.map +1 -0
- package/modules/math/dist/normal.d.ts +40 -0
- package/modules/math/dist/normal.d.ts.map +1 -0
- package/modules/math/dist/normal.js +157 -0
- package/modules/math/dist/normal.js.map +1 -0
- package/modules/math/dist/optimize.d.ts +83 -0
- package/modules/math/dist/optimize.d.ts.map +1 -0
- package/modules/math/dist/optimize.js +784 -0
- package/modules/math/dist/optimize.js.map +1 -0
- package/modules/math/dist/random.d.ts +76 -0
- package/modules/math/dist/random.d.ts.map +1 -0
- package/modules/math/dist/random.js +261 -0
- package/modules/math/dist/random.js.map +1 -0
- package/modules/math/dist/regression.d.ts +58 -0
- package/modules/math/dist/regression.d.ts.map +1 -0
- package/modules/math/dist/regression.js +283 -0
- package/modules/math/dist/regression.js.map +1 -0
- package/modules/math/dist/resource-validation.d.ts +18 -0
- package/modules/math/dist/resource-validation.d.ts.map +1 -0
- package/modules/math/dist/resource-validation.js +60 -0
- package/modules/math/dist/resource-validation.js.map +1 -0
- package/modules/math/dist/sobol-data.d.ts +36 -0
- package/modules/math/dist/sobol-data.d.ts.map +1 -0
- package/modules/math/dist/sobol-data.js +172 -0
- package/modules/math/dist/sobol-data.js.map +1 -0
- package/modules/math/dist/solvers.d.ts +90 -0
- package/modules/math/dist/solvers.d.ts.map +1 -0
- package/modules/math/dist/solvers.js +663 -0
- package/modules/math/dist/solvers.js.map +1 -0
- package/modules/math/dist/statistics-internal.d.ts +73 -0
- package/modules/math/dist/statistics-internal.d.ts.map +1 -0
- package/modules/math/dist/statistics-internal.js +217 -0
- package/modules/math/dist/statistics-internal.js.map +1 -0
- package/modules/math/dist/statistics.d.ts +113 -0
- package/modules/math/dist/statistics.d.ts.map +1 -0
- package/modules/math/dist/statistics.js +545 -0
- package/modules/math/dist/statistics.js.map +1 -0
- package/modules/math/dist/timeseries.d.ts +131 -0
- package/modules/math/dist/timeseries.d.ts.map +1 -0
- package/modules/math/dist/timeseries.js +502 -0
- package/modules/math/dist/timeseries.js.map +1 -0
- package/modules/math/etc/math.api.md +178 -0
- package/modules/math/src/bivariate.ts +124 -0
- package/modules/math/src/distributions.ts +481 -0
- package/modules/math/src/filters.ts +452 -0
- package/modules/math/src/index.ts +223 -0
- package/modules/math/src/integration.ts +259 -0
- package/modules/math/src/interpolation.ts +588 -0
- package/modules/math/src/linalg.ts +1892 -0
- package/modules/math/src/lowdiscrepancy.ts +241 -0
- package/modules/math/src/montecarlo.ts +326 -0
- package/modules/math/src/normal.ts +161 -0
- package/modules/math/src/optimize.ts +943 -0
- package/modules/math/src/random.ts +372 -0
- package/modules/math/src/regression.ts +340 -0
- package/modules/math/src/resource-validation.ts +79 -0
- package/modules/math/src/sobol-data.ts +187 -0
- package/modules/math/src/solvers.ts +859 -0
- package/modules/math/src/statistics-internal.ts +256 -0
- package/modules/math/src/statistics.ts +636 -0
- package/modules/math/src/timeseries.ts +611 -0
- package/modules/options/dist/american-iv.d.ts +116 -0
- package/modules/options/dist/american-iv.d.ts.map +1 -0
- package/modules/options/dist/american-iv.js +385 -0
- package/modules/options/dist/american-iv.js.map +1 -0
- package/modules/options/dist/arbitrage.d.ts +42 -0
- package/modules/options/dist/arbitrage.d.ts.map +1 -0
- package/modules/options/dist/arbitrage.js +79 -0
- package/modules/options/dist/arbitrage.js.map +1 -0
- package/modules/options/dist/bachelier.d.ts +68 -0
- package/modules/options/dist/bachelier.d.ts.map +1 -0
- package/modules/options/dist/bachelier.js +348 -0
- package/modules/options/dist/bachelier.js.map +1 -0
- package/modules/options/dist/batch.d.ts +82 -0
- package/modules/options/dist/batch.d.ts.map +1 -0
- package/modules/options/dist/batch.js +346 -0
- package/modules/options/dist/batch.js.map +1 -0
- package/modules/options/dist/black-scholes.d.ts +42 -0
- package/modules/options/dist/black-scholes.d.ts.map +1 -0
- package/modules/options/dist/black-scholes.js +334 -0
- package/modules/options/dist/black-scholes.js.map +1 -0
- package/modules/options/dist/black76.d.ts +77 -0
- package/modules/options/dist/black76.d.ts.map +1 -0
- package/modules/options/dist/black76.js +400 -0
- package/modules/options/dist/black76.js.map +1 -0
- package/modules/options/dist/bsm.d.ts +120 -0
- package/modules/options/dist/bsm.d.ts.map +1 -0
- package/modules/options/dist/bsm.js +414 -0
- package/modules/options/dist/bsm.js.map +1 -0
- package/modules/options/dist/chain-greeks.d.ts +69 -0
- package/modules/options/dist/chain-greeks.d.ts.map +1 -0
- package/modules/options/dist/chain-greeks.js +154 -0
- package/modules/options/dist/chain-greeks.js.map +1 -0
- package/modules/options/dist/chain-health.d.ts +254 -0
- package/modules/options/dist/chain-health.d.ts.map +1 -0
- package/modules/options/dist/chain-health.js +746 -0
- package/modules/options/dist/chain-health.js.map +1 -0
- package/modules/options/dist/contract.d.ts +73 -0
- package/modules/options/dist/contract.d.ts.map +1 -0
- package/modules/options/dist/contract.js +226 -0
- package/modules/options/dist/contract.js.map +1 -0
- package/modules/options/dist/dividend-term-structure.d.ts +76 -0
- package/modules/options/dist/dividend-term-structure.d.ts.map +1 -0
- package/modules/options/dist/dividend-term-structure.js +180 -0
- package/modules/options/dist/dividend-term-structure.js.map +1 -0
- package/modules/options/dist/dividends.d.ts +34 -0
- package/modules/options/dist/dividends.d.ts.map +1 -0
- package/modules/options/dist/dividends.js +51 -0
- package/modules/options/dist/dividends.js.map +1 -0
- package/modules/options/dist/engine-bsm.d.ts +22 -0
- package/modules/options/dist/engine-bsm.d.ts.map +1 -0
- package/modules/options/dist/engine-bsm.js +236 -0
- package/modules/options/dist/engine-bsm.js.map +1 -0
- package/modules/options/dist/engines/american-approx.d.ts +29 -0
- package/modules/options/dist/engines/american-approx.d.ts.map +1 -0
- package/modules/options/dist/engines/american-approx.js +483 -0
- package/modules/options/dist/engines/american-approx.js.map +1 -0
- package/modules/options/dist/engines/bounds.d.ts +49 -0
- package/modules/options/dist/engines/bounds.d.ts.map +1 -0
- package/modules/options/dist/engines/bounds.js +58 -0
- package/modules/options/dist/engines/bounds.js.map +1 -0
- package/modules/options/dist/engines/engine-factory.d.ts +92 -0
- package/modules/options/dist/engines/engine-factory.d.ts.map +1 -0
- package/modules/options/dist/engines/engine-factory.js +372 -0
- package/modules/options/dist/engines/engine-factory.js.map +1 -0
- package/modules/options/dist/engines/fd-greeks.d.ts +84 -0
- package/modules/options/dist/engines/fd-greeks.d.ts.map +1 -0
- package/modules/options/dist/engines/fd-greeks.js +343 -0
- package/modules/options/dist/engines/fd-greeks.js.map +1 -0
- package/modules/options/dist/engines/fdm.d.ts +78 -0
- package/modules/options/dist/engines/fdm.d.ts.map +1 -0
- package/modules/options/dist/engines/fdm.js +218 -0
- package/modules/options/dist/engines/fdm.js.map +1 -0
- package/modules/options/dist/engines/scalar-pricing.d.ts +24 -0
- package/modules/options/dist/engines/scalar-pricing.d.ts.map +1 -0
- package/modules/options/dist/engines/scalar-pricing.js +2 -0
- package/modules/options/dist/engines/scalar-pricing.js.map +1 -0
- package/modules/options/dist/engines/tree.d.ts +78 -0
- package/modules/options/dist/engines/tree.d.ts.map +1 -0
- package/modules/options/dist/engines/tree.js +247 -0
- package/modules/options/dist/engines/tree.js.map +1 -0
- package/modules/options/dist/engines.d.ts +272 -0
- package/modules/options/dist/engines.d.ts.map +1 -0
- package/modules/options/dist/engines.js +1309 -0
- package/modules/options/dist/engines.js.map +1 -0
- package/modules/options/dist/equity-lattice.d.ts +58 -0
- package/modules/options/dist/equity-lattice.d.ts.map +1 -0
- package/modules/options/dist/equity-lattice.js +139 -0
- package/modules/options/dist/equity-lattice.js.map +1 -0
- package/modules/options/dist/exercise.d.ts +80 -0
- package/modules/options/dist/exercise.d.ts.map +1 -0
- package/modules/options/dist/exercise.js +266 -0
- package/modules/options/dist/exercise.js.map +1 -0
- package/modules/options/dist/exotics.d.ts +640 -0
- package/modules/options/dist/exotics.d.ts.map +1 -0
- package/modules/options/dist/exotics.js +2880 -0
- package/modules/options/dist/exotics.js.map +1 -0
- package/modules/options/dist/facade-util.d.ts +51 -0
- package/modules/options/dist/facade-util.d.ts.map +1 -0
- package/modules/options/dist/facade-util.js +93 -0
- package/modules/options/dist/facade-util.js.map +1 -0
- package/modules/options/dist/generated/validation-specs.d.ts +12 -0
- package/modules/options/dist/generated/validation-specs.d.ts.map +1 -0
- package/modules/options/dist/generated/validation-specs.js +2616 -0
- package/modules/options/dist/generated/validation-specs.js.map +1 -0
- package/modules/options/dist/heston.d.ts +160 -0
- package/modules/options/dist/heston.d.ts.map +1 -0
- package/modules/options/dist/heston.js +983 -0
- package/modules/options/dist/heston.js.map +1 -0
- package/modules/options/dist/index.d.ts +65 -0
- package/modules/options/dist/index.d.ts.map +1 -0
- package/modules/options/dist/index.js +58 -0
- package/modules/options/dist/index.js.map +1 -0
- package/modules/options/dist/iv.d.ts +85 -0
- package/modules/options/dist/iv.d.ts.map +1 -0
- package/modules/options/dist/iv.js +424 -0
- package/modules/options/dist/iv.js.map +1 -0
- package/modules/options/dist/lattice.d.ts +7 -0
- package/modules/options/dist/lattice.d.ts.map +1 -0
- package/modules/options/dist/lattice.js +7 -0
- package/modules/options/dist/lattice.js.map +1 -0
- package/modules/options/dist/local-volatility.d.ts +128 -0
- package/modules/options/dist/local-volatility.d.ts.map +1 -0
- package/modules/options/dist/local-volatility.js +333 -0
- package/modules/options/dist/local-volatility.js.map +1 -0
- package/modules/options/dist/market.d.ts +19 -0
- package/modules/options/dist/market.d.ts.map +1 -0
- package/modules/options/dist/market.js +58 -0
- package/modules/options/dist/market.js.map +1 -0
- package/modules/options/dist/mc/complex.d.ts +23 -0
- package/modules/options/dist/mc/complex.d.ts.map +1 -0
- package/modules/options/dist/mc/complex.js +42 -0
- package/modules/options/dist/mc/complex.js.map +1 -0
- package/modules/options/dist/mc/core.d.ts +151 -0
- package/modules/options/dist/mc/core.d.ts.map +1 -0
- package/modules/options/dist/mc/core.js +319 -0
- package/modules/options/dist/mc/core.js.map +1 -0
- package/modules/options/dist/monte-carlo.d.ts +66 -0
- package/modules/options/dist/monte-carlo.d.ts.map +1 -0
- package/modules/options/dist/monte-carlo.js +388 -0
- package/modules/options/dist/monte-carlo.js.map +1 -0
- package/modules/options/dist/parity.d.ts +191 -0
- package/modules/options/dist/parity.d.ts.map +1 -0
- package/modules/options/dist/parity.js +566 -0
- package/modules/options/dist/parity.js.map +1 -0
- package/modules/options/dist/payoff-kernel.d.ts +33 -0
- package/modules/options/dist/payoff-kernel.d.ts.map +1 -0
- package/modules/options/dist/payoff-kernel.js +27 -0
- package/modules/options/dist/payoff-kernel.js.map +1 -0
- package/modules/options/dist/payoff.d.ts +34 -0
- package/modules/options/dist/payoff.d.ts.map +1 -0
- package/modules/options/dist/payoff.js +60 -0
- package/modules/options/dist/payoff.js.map +1 -0
- package/modules/options/dist/pricer.d.ts +44 -0
- package/modules/options/dist/pricer.d.ts.map +1 -0
- package/modules/options/dist/pricer.js +179 -0
- package/modules/options/dist/pricer.js.map +1 -0
- package/modules/options/dist/pro.d.ts +82 -0
- package/modules/options/dist/pro.d.ts.map +1 -0
- package/modules/options/dist/pro.js +177 -0
- package/modules/options/dist/pro.js.map +1 -0
- package/modules/options/dist/quote.d.ts +18 -0
- package/modules/options/dist/quote.d.ts.map +1 -0
- package/modules/options/dist/quote.js +26 -0
- package/modules/options/dist/quote.js.map +1 -0
- package/modules/options/dist/resource-validation-internal.d.ts +8 -0
- package/modules/options/dist/resource-validation-internal.d.ts.map +1 -0
- package/modules/options/dist/resource-validation-internal.js +23 -0
- package/modules/options/dist/resource-validation-internal.js.map +1 -0
- package/modules/options/dist/sabr.d.ts +153 -0
- package/modules/options/dist/sabr.d.ts.map +1 -0
- package/modules/options/dist/sabr.js +515 -0
- package/modules/options/dist/sabr.js.map +1 -0
- package/modules/options/dist/schema.d.ts +120 -0
- package/modules/options/dist/schema.d.ts.map +1 -0
- package/modules/options/dist/schema.js +62 -0
- package/modules/options/dist/schema.js.map +1 -0
- package/modules/options/dist/time.d.ts +44 -0
- package/modules/options/dist/time.d.ts.map +1 -0
- package/modules/options/dist/time.js +76 -0
- package/modules/options/dist/time.js.map +1 -0
- package/modules/options/dist/types.d.ts +115 -0
- package/modules/options/dist/types.d.ts.map +1 -0
- package/modules/options/dist/types.js +3 -0
- package/modules/options/dist/types.js.map +1 -0
- package/modules/options/etc/options.api.md +230 -0
- package/modules/options/src/american-iv.ts +547 -0
- package/modules/options/src/arbitrage.ts +134 -0
- package/modules/options/src/bachelier.ts +515 -0
- package/modules/options/src/batch.ts +496 -0
- package/modules/options/src/black-scholes.ts +501 -0
- package/modules/options/src/black76.ts +573 -0
- package/modules/options/src/bsm.ts +575 -0
- package/modules/options/src/chain-greeks.ts +242 -0
- package/modules/options/src/chain-health.ts +1083 -0
- package/modules/options/src/contract.ts +329 -0
- package/modules/options/src/dividend-term-structure.ts +303 -0
- package/modules/options/src/dividends.ts +75 -0
- package/modules/options/src/engine-bsm.ts +306 -0
- package/modules/options/src/engines/american-approx.ts +669 -0
- package/modules/options/src/engines/bounds.ts +106 -0
- package/modules/options/src/engines/engine-factory.ts +502 -0
- package/modules/options/src/engines/fd-greeks.ts +426 -0
- package/modules/options/src/engines/fdm.ts +302 -0
- package/modules/options/src/engines/scalar-pricing.ts +27 -0
- package/modules/options/src/engines/tree.ts +350 -0
- package/modules/options/src/engines.ts +1845 -0
- package/modules/options/src/equity-lattice.ts +224 -0
- package/modules/options/src/exercise.ts +422 -0
- package/modules/options/src/exotics.ts +3966 -0
- package/modules/options/src/facade-util.ts +137 -0
- package/modules/options/src/generated/validation-specs.ts +2621 -0
- package/modules/options/src/heston.ts +1348 -0
- package/modules/options/src/index.ts +325 -0
- package/modules/options/src/iv.ts +591 -0
- package/modules/options/src/lattice.ts +6 -0
- package/modules/options/src/local-volatility.ts +493 -0
- package/modules/options/src/market.ts +74 -0
- package/modules/options/src/mc/complex.ts +55 -0
- package/modules/options/src/mc/core.ts +538 -0
- package/modules/options/src/monte-carlo.ts +567 -0
- package/modules/options/src/parity.ts +928 -0
- package/modules/options/src/payoff-kernel.ts +39 -0
- package/modules/options/src/payoff.ts +81 -0
- package/modules/options/src/pricer.ts +217 -0
- package/modules/options/src/pro.ts +272 -0
- package/modules/options/src/quote.ts +34 -0
- package/modules/options/src/resource-validation-internal.ts +31 -0
- package/modules/options/src/sabr.ts +716 -0
- package/modules/options/src/schema.ts +73 -0
- package/modules/options/src/time.ts +104 -0
- package/modules/options/src/types.ts +124 -0
- package/modules/performance/dist/activity.d.ts +24 -0
- package/modules/performance/dist/activity.d.ts.map +1 -0
- package/modules/performance/dist/activity.js +137 -0
- package/modules/performance/dist/activity.js.map +1 -0
- package/modules/performance/dist/analyze.d.ts +85 -0
- package/modules/performance/dist/analyze.d.ts.map +1 -0
- package/modules/performance/dist/analyze.js +203 -0
- package/modules/performance/dist/analyze.js.map +1 -0
- package/modules/performance/dist/annualization-internal.d.ts +21 -0
- package/modules/performance/dist/annualization-internal.d.ts.map +1 -0
- package/modules/performance/dist/annualization-internal.js +34 -0
- package/modules/performance/dist/annualization-internal.js.map +1 -0
- package/modules/performance/dist/drawdown.d.ts +34 -0
- package/modules/performance/dist/drawdown.d.ts.map +1 -0
- package/modules/performance/dist/drawdown.js +99 -0
- package/modules/performance/dist/drawdown.js.map +1 -0
- package/modules/performance/dist/flow-aware.d.ts +388 -0
- package/modules/performance/dist/flow-aware.d.ts.map +1 -0
- package/modules/performance/dist/flow-aware.js +888 -0
- package/modules/performance/dist/flow-aware.js.map +1 -0
- package/modules/performance/dist/index.d.ts +26 -0
- package/modules/performance/dist/index.d.ts.map +1 -0
- package/modules/performance/dist/index.js +25 -0
- package/modules/performance/dist/index.js.map +1 -0
- package/modules/performance/dist/metrics.d.ts +13 -0
- package/modules/performance/dist/metrics.d.ts.map +1 -0
- package/modules/performance/dist/metrics.js +87 -0
- package/modules/performance/dist/metrics.js.map +1 -0
- package/modules/performance/dist/ratios.d.ts +55 -0
- package/modules/performance/dist/ratios.d.ts.map +1 -0
- package/modules/performance/dist/ratios.js +168 -0
- package/modules/performance/dist/ratios.js.map +1 -0
- package/modules/performance/dist/relative.d.ts +33 -0
- package/modules/performance/dist/relative.d.ts.map +1 -0
- package/modules/performance/dist/relative.js +150 -0
- package/modules/performance/dist/relative.js.map +1 -0
- package/modules/performance/dist/returns.d.ts +18 -0
- package/modules/performance/dist/returns.d.ts.map +1 -0
- package/modules/performance/dist/returns.js +70 -0
- package/modules/performance/dist/returns.js.map +1 -0
- package/modules/performance/dist/rolling.d.ts +36 -0
- package/modules/performance/dist/rolling.d.ts.map +1 -0
- package/modules/performance/dist/rolling.js +102 -0
- package/modules/performance/dist/rolling.js.map +1 -0
- package/modules/performance/dist/sector-performance-internal.d.ts +61 -0
- package/modules/performance/dist/sector-performance-internal.d.ts.map +1 -0
- package/modules/performance/dist/sector-performance-internal.js +216 -0
- package/modules/performance/dist/sector-performance-internal.js.map +1 -0
- package/modules/performance/dist/sector-performance.d.ts +288 -0
- package/modules/performance/dist/sector-performance.d.ts.map +1 -0
- package/modules/performance/dist/sector-performance.js +690 -0
- package/modules/performance/dist/sector-performance.js.map +1 -0
- package/modules/performance/dist/sharpe.d.ts +74 -0
- package/modules/performance/dist/sharpe.d.ts.map +1 -0
- package/modules/performance/dist/sharpe.js +157 -0
- package/modules/performance/dist/sharpe.js.map +1 -0
- package/modules/performance/etc/performance.api.md +109 -0
- package/modules/performance/src/activity.ts +182 -0
- package/modules/performance/src/analyze.ts +305 -0
- package/modules/performance/src/annualization-internal.ts +43 -0
- package/modules/performance/src/drawdown.ts +132 -0
- package/modules/performance/src/flow-aware.ts +1518 -0
- package/modules/performance/src/index.ts +89 -0
- package/modules/performance/src/metrics.ts +150 -0
- package/modules/performance/src/ratios.ts +243 -0
- package/modules/performance/src/relative.ts +278 -0
- package/modules/performance/src/returns.ts +80 -0
- package/modules/performance/src/rolling.ts +155 -0
- package/modules/performance/src/sector-performance-internal.ts +293 -0
- package/modules/performance/src/sector-performance.ts +1263 -0
- package/modules/performance/src/sharpe.ts +256 -0
- package/modules/portfolio/dist/allocation.d.ts +227 -0
- package/modules/portfolio/dist/allocation.d.ts.map +1 -0
- package/modules/portfolio/dist/allocation.js +545 -0
- package/modules/portfolio/dist/allocation.js.map +1 -0
- package/modules/portfolio/dist/events.d.ts +502 -0
- package/modules/portfolio/dist/events.d.ts.map +1 -0
- package/modules/portfolio/dist/events.js +1061 -0
- package/modules/portfolio/dist/events.js.map +1 -0
- package/modules/portfolio/dist/index.d.ts +47 -0
- package/modules/portfolio/dist/index.d.ts.map +1 -0
- package/modules/portfolio/dist/index.js +34 -0
- package/modules/portfolio/dist/index.js.map +1 -0
- package/modules/portfolio/dist/internal.d.ts +101 -0
- package/modules/portfolio/dist/internal.d.ts.map +1 -0
- package/modules/portfolio/dist/internal.js +356 -0
- package/modules/portfolio/dist/internal.js.map +1 -0
- package/modules/portfolio/dist/ledger.d.ts +129 -0
- package/modules/portfolio/dist/ledger.d.ts.map +1 -0
- package/modules/portfolio/dist/ledger.js +271 -0
- package/modules/portfolio/dist/ledger.js.map +1 -0
- package/modules/portfolio/dist/lifecycle-corporate.d.ts +49 -0
- package/modules/portfolio/dist/lifecycle-corporate.d.ts.map +1 -0
- package/modules/portfolio/dist/lifecycle-corporate.js +462 -0
- package/modules/portfolio/dist/lifecycle-corporate.js.map +1 -0
- package/modules/portfolio/dist/lifecycle-derivatives.d.ts +59 -0
- package/modules/portfolio/dist/lifecycle-derivatives.d.ts.map +1 -0
- package/modules/portfolio/dist/lifecycle-derivatives.js +422 -0
- package/modules/portfolio/dist/lifecycle-derivatives.js.map +1 -0
- package/modules/portfolio/dist/marks.d.ts +44 -0
- package/modules/portfolio/dist/marks.d.ts.map +1 -0
- package/modules/portfolio/dist/marks.js +81 -0
- package/modules/portfolio/dist/marks.js.map +1 -0
- package/modules/portfolio/dist/monitor.d.ts +222 -0
- package/modules/portfolio/dist/monitor.d.ts.map +1 -0
- package/modules/portfolio/dist/monitor.js +1806 -0
- package/modules/portfolio/dist/monitor.js.map +1 -0
- package/modules/portfolio/dist/performance.d.ts +78 -0
- package/modules/portfolio/dist/performance.d.ts.map +1 -0
- package/modules/portfolio/dist/performance.js +146 -0
- package/modules/portfolio/dist/performance.js.map +1 -0
- package/modules/portfolio/dist/pnl.d.ts +154 -0
- package/modules/portfolio/dist/pnl.d.ts.map +1 -0
- package/modules/portfolio/dist/pnl.js +548 -0
- package/modules/portfolio/dist/pnl.js.map +1 -0
- package/modules/portfolio/dist/policy-grammar.d.ts +358 -0
- package/modules/portfolio/dist/policy-grammar.d.ts.map +1 -0
- package/modules/portfolio/dist/policy-grammar.js +1198 -0
- package/modules/portfolio/dist/policy-grammar.js.map +1 -0
- package/modules/portfolio/dist/policy.d.ts +24 -0
- package/modules/portfolio/dist/policy.d.ts.map +1 -0
- package/modules/portfolio/dist/policy.js +20 -0
- package/modules/portfolio/dist/policy.js.map +1 -0
- package/modules/portfolio/dist/rebalance.d.ts +281 -0
- package/modules/portfolio/dist/rebalance.d.ts.map +1 -0
- package/modules/portfolio/dist/rebalance.js +1236 -0
- package/modules/portfolio/dist/rebalance.js.map +1 -0
- package/modules/portfolio/dist/reconciliation.d.ts +150 -0
- package/modules/portfolio/dist/reconciliation.d.ts.map +1 -0
- package/modules/portfolio/dist/reconciliation.js +392 -0
- package/modules/portfolio/dist/reconciliation.js.map +1 -0
- package/modules/portfolio/dist/reducer-kernel.d.ts +92 -0
- package/modules/portfolio/dist/reducer-kernel.d.ts.map +1 -0
- package/modules/portfolio/dist/reducer-kernel.js +320 -0
- package/modules/portfolio/dist/reducer-kernel.js.map +1 -0
- package/modules/portfolio/dist/snapshot.d.ts +128 -0
- package/modules/portfolio/dist/snapshot.d.ts.map +1 -0
- package/modules/portfolio/dist/snapshot.js +205 -0
- package/modules/portfolio/dist/snapshot.js.map +1 -0
- package/modules/portfolio/dist/state.d.ts +196 -0
- package/modules/portfolio/dist/state.d.ts.map +1 -0
- package/modules/portfolio/dist/state.js +1093 -0
- package/modules/portfolio/dist/state.js.map +1 -0
- package/modules/portfolio/dist/timeline.d.ts +107 -0
- package/modules/portfolio/dist/timeline.d.ts.map +1 -0
- package/modules/portfolio/dist/timeline.js +220 -0
- package/modules/portfolio/dist/timeline.js.map +1 -0
- package/modules/portfolio/dist/trade/grant.d.ts +21 -0
- package/modules/portfolio/dist/trade/grant.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/grant.js +411 -0
- package/modules/portfolio/dist/trade/grant.js.map +1 -0
- package/modules/portfolio/dist/trade/index.d.ts +20 -0
- package/modules/portfolio/dist/trade/index.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/index.js +17 -0
- package/modules/portfolio/dist/trade/index.js.map +1 -0
- package/modules/portfolio/dist/trade/journal.d.ts +23 -0
- package/modules/portfolio/dist/trade/journal.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/journal.js +352 -0
- package/modules/portfolio/dist/trade/journal.js.map +1 -0
- package/modules/portfolio/dist/trade/plan.d.ts +25 -0
- package/modules/portfolio/dist/trade/plan.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/plan.js +285 -0
- package/modules/portfolio/dist/trade/plan.js.map +1 -0
- package/modules/portfolio/dist/trade/policy.d.ts +5 -0
- package/modules/portfolio/dist/trade/policy.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/policy.js +133 -0
- package/modules/portfolio/dist/trade/policy.js.map +1 -0
- package/modules/portfolio/dist/trade/preflight.d.ts +3 -0
- package/modules/portfolio/dist/trade/preflight.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/preflight.js +381 -0
- package/modules/portfolio/dist/trade/preflight.js.map +1 -0
- package/modules/portfolio/dist/trade/reconcile.d.ts +8 -0
- package/modules/portfolio/dist/trade/reconcile.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/reconcile.js +240 -0
- package/modules/portfolio/dist/trade/reconcile.js.map +1 -0
- package/modules/portfolio/dist/trade/types.d.ts +559 -0
- package/modules/portfolio/dist/trade/types.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/types.js +36 -0
- package/modules/portfolio/dist/trade/types.js.map +1 -0
- package/modules/portfolio/dist/trade/validate.d.ts +36 -0
- package/modules/portfolio/dist/trade/validate.d.ts.map +1 -0
- package/modules/portfolio/dist/trade/validate.js +776 -0
- package/modules/portfolio/dist/trade/validate.js.map +1 -0
- package/modules/portfolio/etc/portfolio.api.md +236 -0
- package/modules/portfolio/src/allocation.ts +844 -0
- package/modules/portfolio/src/events.ts +1968 -0
- package/modules/portfolio/src/index.ts +295 -0
- package/modules/portfolio/src/internal.ts +523 -0
- package/modules/portfolio/src/ledger.ts +420 -0
- package/modules/portfolio/src/lifecycle-corporate.ts +888 -0
- package/modules/portfolio/src/lifecycle-derivatives.ts +735 -0
- package/modules/portfolio/src/marks.ts +140 -0
- package/modules/portfolio/src/monitor.ts +2421 -0
- package/modules/portfolio/src/performance.ts +237 -0
- package/modules/portfolio/src/pnl.ts +840 -0
- package/modules/portfolio/src/policy-grammar.ts +1891 -0
- package/modules/portfolio/src/policy.ts +119 -0
- package/modules/portfolio/src/rebalance.ts +1742 -0
- package/modules/portfolio/src/reconciliation.ts +621 -0
- package/modules/portfolio/src/reducer-kernel.ts +512 -0
- package/modules/portfolio/src/snapshot.ts +372 -0
- package/modules/portfolio/src/state.ts +1776 -0
- package/modules/portfolio/src/timeline.ts +359 -0
- package/modules/portfolio/src/trade/grant.ts +514 -0
- package/modules/portfolio/src/trade/index.ts +96 -0
- package/modules/portfolio/src/trade/journal.ts +432 -0
- package/modules/portfolio/src/trade/plan.ts +424 -0
- package/modules/portfolio/src/trade/policy.ts +153 -0
- package/modules/portfolio/src/trade/preflight.ts +605 -0
- package/modules/portfolio/src/trade/reconcile.ts +276 -0
- package/modules/portfolio/src/trade/types.ts +637 -0
- package/modules/portfolio/src/trade/validate.ts +1213 -0
- package/modules/research/dist/artifacts.d.ts +25 -0
- package/modules/research/dist/artifacts.d.ts.map +1 -0
- package/modules/research/dist/artifacts.js +22 -0
- package/modules/research/dist/artifacts.js.map +1 -0
- package/modules/research/dist/events.d.ts +238 -0
- package/modules/research/dist/events.d.ts.map +1 -0
- package/modules/research/dist/events.js +844 -0
- package/modules/research/dist/events.js.map +1 -0
- package/modules/research/dist/factors.d.ts +330 -0
- package/modules/research/dist/factors.d.ts.map +1 -0
- package/modules/research/dist/factors.js +891 -0
- package/modules/research/dist/factors.js.map +1 -0
- package/modules/research/dist/index.d.ts +11 -0
- package/modules/research/dist/index.d.ts.map +1 -0
- package/modules/research/dist/index.js +13 -0
- package/modules/research/dist/index.js.map +1 -0
- package/modules/research/dist/observations.d.ts +77 -0
- package/modules/research/dist/observations.d.ts.map +1 -0
- package/modules/research/dist/observations.js +201 -0
- package/modules/research/dist/observations.js.map +1 -0
- package/modules/research/dist/point-in-time.d.ts +17 -0
- package/modules/research/dist/point-in-time.d.ts.map +1 -0
- package/modules/research/dist/point-in-time.js +34 -0
- package/modules/research/dist/point-in-time.js.map +1 -0
- package/modules/research/dist/research-hygiene.d.ts +126 -0
- package/modules/research/dist/research-hygiene.d.ts.map +1 -0
- package/modules/research/dist/research-hygiene.js +290 -0
- package/modules/research/dist/research-hygiene.js.map +1 -0
- package/modules/research/dist/research-run-artifacts.d.ts +315 -0
- package/modules/research/dist/research-run-artifacts.d.ts.map +1 -0
- package/modules/research/dist/research-run-artifacts.js +766 -0
- package/modules/research/dist/research-run-artifacts.js.map +1 -0
- package/modules/research/dist/research-run-kinds.d.ts +135 -0
- package/modules/research/dist/research-run-kinds.d.ts.map +1 -0
- package/modules/research/dist/research-run-kinds.js +470 -0
- package/modules/research/dist/research-run-kinds.js.map +1 -0
- package/modules/research/dist/screening.d.ts +215 -0
- package/modules/research/dist/screening.d.ts.map +1 -0
- package/modules/research/dist/screening.js +616 -0
- package/modules/research/dist/screening.js.map +1 -0
- package/modules/research/dist/universe.d.ts +131 -0
- package/modules/research/dist/universe.d.ts.map +1 -0
- package/modules/research/dist/universe.js +294 -0
- package/modules/research/dist/universe.js.map +1 -0
- package/modules/research/etc/research.api.md +109 -0
- package/modules/research/src/artifacts.ts +68 -0
- package/modules/research/src/events.ts +1358 -0
- package/modules/research/src/factors.ts +1322 -0
- package/modules/research/src/index.ts +28 -0
- package/modules/research/src/observations.ts +360 -0
- package/modules/research/src/point-in-time.ts +44 -0
- package/modules/research/src/research-hygiene.ts +544 -0
- package/modules/research/src/research-run-artifacts.ts +1464 -0
- package/modules/research/src/research-run-kinds.ts +723 -0
- package/modules/research/src/screening.ts +957 -0
- package/modules/research/src/universe.ts +494 -0
- package/modules/risk/dist/attribution.d.ts +166 -0
- package/modules/risk/dist/attribution.d.ts.map +1 -0
- package/modules/risk/dist/attribution.js +278 -0
- package/modules/risk/dist/attribution.js.map +1 -0
- package/modules/risk/dist/book-var.d.ts +113 -0
- package/modules/risk/dist/book-var.d.ts.map +1 -0
- package/modules/risk/dist/book-var.js +487 -0
- package/modules/risk/dist/book-var.js.map +1 -0
- package/modules/risk/dist/book.d.ts +95 -0
- package/modules/risk/dist/book.d.ts.map +1 -0
- package/modules/risk/dist/book.js +201 -0
- package/modules/risk/dist/book.js.map +1 -0
- package/modules/risk/dist/covariance.d.ts +96 -0
- package/modules/risk/dist/covariance.d.ts.map +1 -0
- package/modules/risk/dist/covariance.js +183 -0
- package/modules/risk/dist/covariance.js.map +1 -0
- package/modules/risk/dist/evt.d.ts +188 -0
- package/modules/risk/dist/evt.d.ts.map +1 -0
- package/modules/risk/dist/evt.js +625 -0
- package/modules/risk/dist/evt.js.map +1 -0
- package/modules/risk/dist/expected-returns.d.ts +139 -0
- package/modules/risk/dist/expected-returns.d.ts.map +1 -0
- package/modules/risk/dist/expected-returns.js +350 -0
- package/modules/risk/dist/expected-returns.js.map +1 -0
- package/modules/risk/dist/factor.d.ts +66 -0
- package/modules/risk/dist/factor.d.ts.map +1 -0
- package/modules/risk/dist/factor.js +133 -0
- package/modules/risk/dist/factor.js.map +1 -0
- package/modules/risk/dist/frontier.d.ts +158 -0
- package/modules/risk/dist/frontier.d.ts.map +1 -0
- package/modules/risk/dist/frontier.js +1183 -0
- package/modules/risk/dist/frontier.js.map +1 -0
- package/modules/risk/dist/index.d.ts +47 -0
- package/modules/risk/dist/index.d.ts.map +1 -0
- package/modules/risk/dist/index.js +43 -0
- package/modules/risk/dist/index.js.map +1 -0
- package/modules/risk/dist/input-description.d.ts +3 -0
- package/modules/risk/dist/input-description.d.ts.map +1 -0
- package/modules/risk/dist/input-description.js +24 -0
- package/modules/risk/dist/input-description.js.map +1 -0
- package/modules/risk/dist/kelly.d.ts +217 -0
- package/modules/risk/dist/kelly.d.ts.map +1 -0
- package/modules/risk/dist/kelly.js +731 -0
- package/modules/risk/dist/kelly.js.map +1 -0
- package/modules/risk/dist/linalg.d.ts +27 -0
- package/modules/risk/dist/linalg.d.ts.map +1 -0
- package/modules/risk/dist/linalg.js +89 -0
- package/modules/risk/dist/linalg.js.map +1 -0
- package/modules/risk/dist/numeric-vector.d.ts +9 -0
- package/modules/risk/dist/numeric-vector.d.ts.map +1 -0
- package/modules/risk/dist/numeric-vector.js +112 -0
- package/modules/risk/dist/numeric-vector.js.map +1 -0
- package/modules/risk/dist/optimize.d.ts +231 -0
- package/modules/risk/dist/optimize.d.ts.map +1 -0
- package/modules/risk/dist/optimize.js +1258 -0
- package/modules/risk/dist/optimize.js.map +1 -0
- package/modules/risk/dist/optimizer-validation.d.ts +26 -0
- package/modules/risk/dist/optimizer-validation.d.ts.map +1 -0
- package/modules/risk/dist/optimizer-validation.js +306 -0
- package/modules/risk/dist/optimizer-validation.js.map +1 -0
- package/modules/risk/dist/options-internal.d.ts +18 -0
- package/modules/risk/dist/options-internal.d.ts.map +1 -0
- package/modules/risk/dist/options-internal.js +49 -0
- package/modules/risk/dist/options-internal.js.map +1 -0
- package/modules/risk/dist/pnl-explain.d.ts +169 -0
- package/modules/risk/dist/pnl-explain.d.ts.map +1 -0
- package/modules/risk/dist/pnl-explain.js +327 -0
- package/modules/risk/dist/pnl-explain.js.map +1 -0
- package/modules/risk/dist/portfolio.d.ts +322 -0
- package/modules/risk/dist/portfolio.d.ts.map +1 -0
- package/modules/risk/dist/portfolio.js +547 -0
- package/modules/risk/dist/portfolio.js.map +1 -0
- package/modules/risk/dist/research-protocol.d.ts +74 -0
- package/modules/risk/dist/research-protocol.d.ts.map +1 -0
- package/modules/risk/dist/research-protocol.js +193 -0
- package/modules/risk/dist/research-protocol.js.map +1 -0
- package/modules/risk/dist/research.d.ts +255 -0
- package/modules/risk/dist/research.d.ts.map +1 -0
- package/modules/risk/dist/research.js +752 -0
- package/modules/risk/dist/research.js.map +1 -0
- package/modules/risk/dist/scenario.d.ts +279 -0
- package/modules/risk/dist/scenario.d.ts.map +1 -0
- package/modules/risk/dist/scenario.js +458 -0
- package/modules/risk/dist/scenario.js.map +1 -0
- package/modules/risk/dist/sizing.d.ts +14 -0
- package/modules/risk/dist/sizing.d.ts.map +1 -0
- package/modules/risk/dist/sizing.js +12 -0
- package/modules/risk/dist/sizing.js.map +1 -0
- package/modules/risk/dist/strategy-shape.d.ts +84 -0
- package/modules/risk/dist/strategy-shape.d.ts.map +1 -0
- package/modules/risk/dist/strategy-shape.js +17 -0
- package/modules/risk/dist/strategy-shape.js.map +1 -0
- package/modules/risk/dist/value-at-risk.d.ts +240 -0
- package/modules/risk/dist/value-at-risk.d.ts.map +1 -0
- package/modules/risk/dist/value-at-risk.js +743 -0
- package/modules/risk/dist/value-at-risk.js.map +1 -0
- package/modules/risk/etc/risk.api.md +228 -0
- package/modules/risk/src/attribution.ts +480 -0
- package/modules/risk/src/book-var.ts +717 -0
- package/modules/risk/src/book.ts +327 -0
- package/modules/risk/src/covariance.ts +293 -0
- package/modules/risk/src/evt.ts +899 -0
- package/modules/risk/src/expected-returns.ts +572 -0
- package/modules/risk/src/factor.ts +199 -0
- package/modules/risk/src/frontier.ts +1570 -0
- package/modules/risk/src/index.ts +281 -0
- package/modules/risk/src/input-description.ts +15 -0
- package/modules/risk/src/kelly.ts +1119 -0
- package/modules/risk/src/linalg.ts +100 -0
- package/modules/risk/src/numeric-vector.ts +153 -0
- package/modules/risk/src/optimize.ts +1769 -0
- package/modules/risk/src/optimizer-validation.ts +467 -0
- package/modules/risk/src/options-internal.ts +73 -0
- package/modules/risk/src/pnl-explain.ts +544 -0
- package/modules/risk/src/portfolio.ts +911 -0
- package/modules/risk/src/research-protocol.ts +277 -0
- package/modules/risk/src/research.ts +1076 -0
- package/modules/risk/src/scenario.ts +728 -0
- package/modules/risk/src/sizing.ts +15 -0
- package/modules/risk/src/strategy-shape.ts +90 -0
- package/modules/risk/src/value-at-risk.ts +1102 -0
- package/modules/scenarios/dist/aggregates.d.ts +27 -0
- package/modules/scenarios/dist/aggregates.d.ts.map +1 -0
- package/modules/scenarios/dist/aggregates.js +262 -0
- package/modules/scenarios/dist/aggregates.js.map +1 -0
- package/modules/scenarios/dist/fx.d.ts +69 -0
- package/modules/scenarios/dist/fx.d.ts.map +1 -0
- package/modules/scenarios/dist/fx.js +349 -0
- package/modules/scenarios/dist/fx.js.map +1 -0
- package/modules/scenarios/dist/index.d.ts +6 -0
- package/modules/scenarios/dist/index.d.ts.map +1 -0
- package/modules/scenarios/dist/index.js +6 -0
- package/modules/scenarios/dist/index.js.map +1 -0
- package/modules/scenarios/dist/internal/behaviors.d.ts +28 -0
- package/modules/scenarios/dist/internal/behaviors.d.ts.map +1 -0
- package/modules/scenarios/dist/internal/behaviors.js +169 -0
- package/modules/scenarios/dist/internal/behaviors.js.map +1 -0
- package/modules/scenarios/dist/internal/data.d.ts +35 -0
- package/modules/scenarios/dist/internal/data.d.ts.map +1 -0
- package/modules/scenarios/dist/internal/data.js +194 -0
- package/modules/scenarios/dist/internal/data.js.map +1 -0
- package/modules/scenarios/dist/internal/failures.d.ts +18 -0
- package/modules/scenarios/dist/internal/failures.d.ts.map +1 -0
- package/modules/scenarios/dist/internal/failures.js +184 -0
- package/modules/scenarios/dist/internal/failures.js.map +1 -0
- package/modules/scenarios/dist/internal/results.d.ts +18 -0
- package/modules/scenarios/dist/internal/results.d.ts.map +1 -0
- package/modules/scenarios/dist/internal/results.js +100 -0
- package/modules/scenarios/dist/internal/results.js.map +1 -0
- package/modules/scenarios/dist/market-resolution.d.ts +32 -0
- package/modules/scenarios/dist/market-resolution.d.ts.map +1 -0
- package/modules/scenarios/dist/market-resolution.js +296 -0
- package/modules/scenarios/dist/market-resolution.js.map +1 -0
- package/modules/scenarios/dist/portfolio.d.ts +11 -0
- package/modules/scenarios/dist/portfolio.d.ts.map +1 -0
- package/modules/scenarios/dist/portfolio.js +419 -0
- package/modules/scenarios/dist/portfolio.js.map +1 -0
- package/modules/scenarios/dist/run.d.ts +4 -0
- package/modules/scenarios/dist/run.d.ts.map +1 -0
- package/modules/scenarios/dist/run.js +933 -0
- package/modules/scenarios/dist/run.js.map +1 -0
- package/modules/scenarios/dist/spot-pricer.d.ts +21 -0
- package/modules/scenarios/dist/spot-pricer.d.ts.map +1 -0
- package/modules/scenarios/dist/spot-pricer.js +97 -0
- package/modules/scenarios/dist/spot-pricer.js.map +1 -0
- package/modules/scenarios/dist/targets.d.ts +18 -0
- package/modules/scenarios/dist/targets.d.ts.map +1 -0
- package/modules/scenarios/dist/targets.js +507 -0
- package/modules/scenarios/dist/targets.js.map +1 -0
- package/modules/scenarios/dist/taylor.d.ts +23 -0
- package/modules/scenarios/dist/taylor.d.ts.map +1 -0
- package/modules/scenarios/dist/taylor.js +209 -0
- package/modules/scenarios/dist/taylor.js.map +1 -0
- package/modules/scenarios/dist/transform.d.ts +31 -0
- package/modules/scenarios/dist/transform.d.ts.map +1 -0
- package/modules/scenarios/dist/transform.js +318 -0
- package/modules/scenarios/dist/transform.js.map +1 -0
- package/modules/scenarios/dist/types.d.ts +591 -0
- package/modules/scenarios/dist/types.d.ts.map +1 -0
- package/modules/scenarios/dist/types.js +2 -0
- package/modules/scenarios/dist/types.js.map +1 -0
- package/modules/scenarios/dist/work.d.ts +85 -0
- package/modules/scenarios/dist/work.d.ts.map +1 -0
- package/modules/scenarios/dist/work.js +629 -0
- package/modules/scenarios/dist/work.js.map +1 -0
- package/modules/scenarios/etc/scenarios.api.md +76 -0
- package/modules/scenarios/src/aggregates.ts +429 -0
- package/modules/scenarios/src/fx.ts +563 -0
- package/modules/scenarios/src/index.ts +5 -0
- package/modules/scenarios/src/internal/behaviors.ts +249 -0
- package/modules/scenarios/src/internal/data.ts +258 -0
- package/modules/scenarios/src/internal/failures.ts +219 -0
- package/modules/scenarios/src/internal/results.ts +131 -0
- package/modules/scenarios/src/market-resolution.ts +436 -0
- package/modules/scenarios/src/portfolio.ts +639 -0
- package/modules/scenarios/src/run.ts +1417 -0
- package/modules/scenarios/src/spot-pricer.ts +129 -0
- package/modules/scenarios/src/targets.ts +729 -0
- package/modules/scenarios/src/taylor.ts +287 -0
- package/modules/scenarios/src/transform.ts +468 -0
- package/modules/scenarios/src/types.ts +713 -0
- package/modules/scenarios/src/work.ts +1055 -0
- package/modules/strategy/dist/auto-range.d.ts +14 -0
- package/modules/strategy/dist/auto-range.d.ts.map +1 -0
- package/modules/strategy/dist/auto-range.js +19 -0
- package/modules/strategy/dist/auto-range.js.map +1 -0
- package/modules/strategy/dist/builders.d.ts +75 -0
- package/modules/strategy/dist/builders.d.ts.map +1 -0
- package/modules/strategy/dist/builders.js +112 -0
- package/modules/strategy/dist/builders.js.map +1 -0
- package/modules/strategy/dist/calendars.d.ts +70 -0
- package/modules/strategy/dist/calendars.d.ts.map +1 -0
- package/modules/strategy/dist/calendars.js +149 -0
- package/modules/strategy/dist/calendars.js.map +1 -0
- package/modules/strategy/dist/classify.d.ts +77 -0
- package/modules/strategy/dist/classify.d.ts.map +1 -0
- package/modules/strategy/dist/classify.js +144 -0
- package/modules/strategy/dist/classify.js.map +1 -0
- package/modules/strategy/dist/explain.d.ts +77 -0
- package/modules/strategy/dist/explain.d.ts.map +1 -0
- package/modules/strategy/dist/explain.js +300 -0
- package/modules/strategy/dist/explain.js.map +1 -0
- package/modules/strategy/dist/from-chain.d.ts +88 -0
- package/modules/strategy/dist/from-chain.d.ts.map +1 -0
- package/modules/strategy/dist/from-chain.js +457 -0
- package/modules/strategy/dist/from-chain.js.map +1 -0
- package/modules/strategy/dist/index.d.ts +102 -0
- package/modules/strategy/dist/index.d.ts.map +1 -0
- package/modules/strategy/dist/index.js +41 -0
- package/modules/strategy/dist/index.js.map +1 -0
- package/modules/strategy/dist/legs.d.ts +47 -0
- package/modules/strategy/dist/legs.d.ts.map +1 -0
- package/modules/strategy/dist/legs.js +87 -0
- package/modules/strategy/dist/legs.js.map +1 -0
- package/modules/strategy/dist/manifest.d.ts +116 -0
- package/modules/strategy/dist/manifest.d.ts.map +1 -0
- package/modules/strategy/dist/manifest.js +376 -0
- package/modules/strategy/dist/manifest.js.map +1 -0
- package/modules/strategy/dist/optimizer.d.ts +184 -0
- package/modules/strategy/dist/optimizer.d.ts.map +1 -0
- package/modules/strategy/dist/optimizer.js +404 -0
- package/modules/strategy/dist/optimizer.js.map +1 -0
- package/modules/strategy/dist/position.d.ts +181 -0
- package/modules/strategy/dist/position.d.ts.map +1 -0
- package/modules/strategy/dist/position.js +1693 -0
- package/modules/strategy/dist/position.js.map +1 -0
- package/modules/strategy/dist/probability.d.ts +192 -0
- package/modules/strategy/dist/probability.d.ts.map +1 -0
- package/modules/strategy/dist/probability.js +106 -0
- package/modules/strategy/dist/probability.js.map +1 -0
- package/modules/strategy/dist/scanner.d.ts +147 -0
- package/modules/strategy/dist/scanner.d.ts.map +1 -0
- package/modules/strategy/dist/scanner.js +438 -0
- package/modules/strategy/dist/scanner.js.map +1 -0
- package/modules/strategy/dist/strategies.d.ts +187 -0
- package/modules/strategy/dist/strategies.d.ts.map +1 -0
- package/modules/strategy/dist/strategies.js +541 -0
- package/modules/strategy/dist/strategies.js.map +1 -0
- package/modules/strategy/dist/svg.d.ts +35 -0
- package/modules/strategy/dist/svg.d.ts.map +1 -0
- package/modules/strategy/dist/svg.js +298 -0
- package/modules/strategy/dist/svg.js.map +1 -0
- package/modules/strategy/dist/thesis-distribution.d.ts +79 -0
- package/modules/strategy/dist/thesis-distribution.d.ts.map +1 -0
- package/modules/strategy/dist/thesis-distribution.js +125 -0
- package/modules/strategy/dist/thesis-distribution.js.map +1 -0
- package/modules/strategy/dist/types.d.ts +370 -0
- package/modules/strategy/dist/types.d.ts.map +1 -0
- package/modules/strategy/dist/types.js +8 -0
- package/modules/strategy/dist/types.js.map +1 -0
- package/modules/strategy/dist/validate.d.ts +63 -0
- package/modules/strategy/dist/validate.d.ts.map +1 -0
- package/modules/strategy/dist/validate.js +146 -0
- package/modules/strategy/dist/validate.js.map +1 -0
- package/modules/strategy/etc/strategy.api.md +174 -0
- package/modules/strategy/src/auto-range.ts +21 -0
- package/modules/strategy/src/builders.ts +221 -0
- package/modules/strategy/src/calendars.ts +245 -0
- package/modules/strategy/src/classify.ts +215 -0
- package/modules/strategy/src/explain.ts +471 -0
- package/modules/strategy/src/from-chain.ts +643 -0
- package/modules/strategy/src/index.ts +212 -0
- package/modules/strategy/src/legs.ts +140 -0
- package/modules/strategy/src/manifest.ts +756 -0
- package/modules/strategy/src/optimizer.ts +679 -0
- package/modules/strategy/src/position.ts +2084 -0
- package/modules/strategy/src/probability.ts +301 -0
- package/modules/strategy/src/scanner.ts +711 -0
- package/modules/strategy/src/strategies.ts +1018 -0
- package/modules/strategy/src/svg.ts +415 -0
- package/modules/strategy/src/thesis-distribution.ts +188 -0
- package/modules/strategy/src/types.ts +380 -0
- package/modules/strategy/src/validate.ts +207 -0
- package/modules/structure/OPTION-FLOW-DRIFT.md +126 -0
- package/modules/structure/dist/exposure.d.ts +350 -0
- package/modules/structure/dist/exposure.d.ts.map +1 -0
- package/modules/structure/dist/exposure.js +917 -0
- package/modules/structure/dist/exposure.js.map +1 -0
- package/modules/structure/dist/flow.d.ts +247 -0
- package/modules/structure/dist/flow.d.ts.map +1 -0
- package/modules/structure/dist/flow.js +643 -0
- package/modules/structure/dist/flow.js.map +1 -0
- package/modules/structure/dist/index.d.ts +20 -0
- package/modules/structure/dist/index.d.ts.map +1 -0
- package/modules/structure/dist/index.js +16 -0
- package/modules/structure/dist/index.js.map +1 -0
- package/modules/structure/dist/market-day.d.ts +29 -0
- package/modules/structure/dist/market-day.d.ts.map +1 -0
- package/modules/structure/dist/market-day.js +43 -0
- package/modules/structure/dist/market-day.js.map +1 -0
- package/modules/structure/dist/option-flow-drift.d.ts +184 -0
- package/modules/structure/dist/option-flow-drift.d.ts.map +1 -0
- package/modules/structure/dist/option-flow-drift.js +475 -0
- package/modules/structure/dist/option-flow-drift.js.map +1 -0
- package/modules/structure/dist/supplied-exposure.d.ts +191 -0
- package/modules/structure/dist/supplied-exposure.d.ts.map +1 -0
- package/modules/structure/dist/supplied-exposure.js +421 -0
- package/modules/structure/dist/supplied-exposure.js.map +1 -0
- package/modules/structure/etc/structure.api.md +72 -0
- package/modules/structure/src/exposure.ts +1330 -0
- package/modules/structure/src/flow.ts +955 -0
- package/modules/structure/src/index.ts +83 -0
- package/modules/structure/src/market-day.ts +47 -0
- package/modules/structure/src/option-flow-drift.ts +726 -0
- package/modules/structure/src/supplied-exposure.ts +671 -0
- package/modules/technical-analysis/dist/aliases.d.ts +42 -0
- package/modules/technical-analysis/dist/aliases.d.ts.map +1 -0
- package/modules/technical-analysis/dist/aliases.js +413 -0
- package/modules/technical-analysis/dist/aliases.js.map +1 -0
- package/modules/technical-analysis/dist/bands.d.ts +31 -0
- package/modules/technical-analysis/dist/bands.d.ts.map +1 -0
- package/modules/technical-analysis/dist/bands.js +79 -0
- package/modules/technical-analysis/dist/bands.js.map +1 -0
- package/modules/technical-analysis/dist/bars.d.ts +113 -0
- package/modules/technical-analysis/dist/bars.d.ts.map +1 -0
- package/modules/technical-analysis/dist/bars.js +374 -0
- package/modules/technical-analysis/dist/bars.js.map +1 -0
- package/modules/technical-analysis/dist/builtin-metadata.d.ts +1817 -0
- package/modules/technical-analysis/dist/builtin-metadata.d.ts.map +1 -0
- package/modules/technical-analysis/dist/builtin-metadata.js +1399 -0
- package/modules/technical-analysis/dist/builtin-metadata.js.map +1 -0
- package/modules/technical-analysis/dist/candle-aliases.d.ts +56 -0
- package/modules/technical-analysis/dist/candle-aliases.d.ts.map +1 -0
- package/modules/technical-analysis/dist/candle-aliases.js +246 -0
- package/modules/technical-analysis/dist/candle-aliases.js.map +1 -0
- package/modules/technical-analysis/dist/candle-talib.d.ts +114 -0
- package/modules/technical-analysis/dist/candle-talib.d.ts.map +1 -0
- package/modules/technical-analysis/dist/candle-talib.js +185 -0
- package/modules/technical-analysis/dist/candle-talib.js.map +1 -0
- package/modules/technical-analysis/dist/candlesticks.d.ts +103 -0
- package/modules/technical-analysis/dist/candlesticks.d.ts.map +1 -0
- package/modules/technical-analysis/dist/candlesticks.js +1009 -0
- package/modules/technical-analysis/dist/candlesticks.js.map +1 -0
- package/modules/technical-analysis/dist/chart-types.d.ts +205 -0
- package/modules/technical-analysis/dist/chart-types.d.ts.map +1 -0
- package/modules/technical-analysis/dist/chart-types.js +633 -0
- package/modules/technical-analysis/dist/chart-types.js.map +1 -0
- package/modules/technical-analysis/dist/columns.d.ts +24 -0
- package/modules/technical-analysis/dist/columns.d.ts.map +1 -0
- package/modules/technical-analysis/dist/columns.js +71 -0
- package/modules/technical-analysis/dist/columns.js.map +1 -0
- package/modules/technical-analysis/dist/cycle.d.ts +174 -0
- package/modules/technical-analysis/dist/cycle.d.ts.map +1 -0
- package/modules/technical-analysis/dist/cycle.js +489 -0
- package/modules/technical-analysis/dist/cycle.js.map +1 -0
- package/modules/technical-analysis/dist/discover.d.ts +100 -0
- package/modules/technical-analysis/dist/discover.d.ts.map +1 -0
- package/modules/technical-analysis/dist/discover.js +273 -0
- package/modules/technical-analysis/dist/discover.js.map +1 -0
- package/modules/technical-analysis/dist/divergence.d.ts +82 -0
- package/modules/technical-analysis/dist/divergence.d.ts.map +1 -0
- package/modules/technical-analysis/dist/divergence.js +269 -0
- package/modules/technical-analysis/dist/divergence.js.map +1 -0
- package/modules/technical-analysis/dist/features-ext.d.ts +162 -0
- package/modules/technical-analysis/dist/features-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/features-ext.js +633 -0
- package/modules/technical-analysis/dist/features-ext.js.map +1 -0
- package/modules/technical-analysis/dist/features.d.ts +10 -0
- package/modules/technical-analysis/dist/features.d.ts.map +1 -0
- package/modules/technical-analysis/dist/features.js +10 -0
- package/modules/technical-analysis/dist/features.js.map +1 -0
- package/modules/technical-analysis/dist/framework.d.ts +353 -0
- package/modules/technical-analysis/dist/framework.d.ts.map +1 -0
- package/modules/technical-analysis/dist/framework.js +999 -0
- package/modules/technical-analysis/dist/framework.js.map +1 -0
- package/modules/technical-analysis/dist/fuzzy.d.ts +33 -0
- package/modules/technical-analysis/dist/fuzzy.d.ts.map +1 -0
- package/modules/technical-analysis/dist/fuzzy.js +80 -0
- package/modules/technical-analysis/dist/fuzzy.js.map +1 -0
- package/modules/technical-analysis/dist/generated/validation-specs.d.ts +12 -0
- package/modules/technical-analysis/dist/generated/validation-specs.d.ts.map +1 -0
- package/modules/technical-analysis/dist/generated/validation-specs.js +1052 -0
- package/modules/technical-analysis/dist/generated/validation-specs.js.map +1 -0
- package/modules/technical-analysis/dist/index.d.ts +132 -0
- package/modules/technical-analysis/dist/index.d.ts.map +1 -0
- package/modules/technical-analysis/dist/index.js +100 -0
- package/modules/technical-analysis/dist/index.js.map +1 -0
- package/modules/technical-analysis/dist/indicator-metadata.d.ts +21 -0
- package/modules/technical-analysis/dist/indicator-metadata.d.ts.map +1 -0
- package/modules/technical-analysis/dist/indicator-metadata.js +23 -0
- package/modules/technical-analysis/dist/indicator-metadata.js.map +1 -0
- package/modules/technical-analysis/dist/limits.d.ts +19 -0
- package/modules/technical-analysis/dist/limits.d.ts.map +1 -0
- package/modules/technical-analysis/dist/limits.js +19 -0
- package/modules/technical-analysis/dist/limits.js.map +1 -0
- package/modules/technical-analysis/dist/macd.d.ts +29 -0
- package/modules/technical-analysis/dist/macd.d.ts.map +1 -0
- package/modules/technical-analysis/dist/macd.js +61 -0
- package/modules/technical-analysis/dist/macd.js.map +1 -0
- package/modules/technical-analysis/dist/math.d.ts +69 -0
- package/modules/technical-analysis/dist/math.d.ts.map +1 -0
- package/modules/technical-analysis/dist/math.js +124 -0
- package/modules/technical-analysis/dist/math.js.map +1 -0
- package/modules/technical-analysis/dist/microstructure.d.ts +252 -0
- package/modules/technical-analysis/dist/microstructure.d.ts.map +1 -0
- package/modules/technical-analysis/dist/microstructure.js +552 -0
- package/modules/technical-analysis/dist/microstructure.js.map +1 -0
- package/modules/technical-analysis/dist/momentum-ext.d.ts +619 -0
- package/modules/technical-analysis/dist/momentum-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/momentum-ext.js +1772 -0
- package/modules/technical-analysis/dist/momentum-ext.js.map +1 -0
- package/modules/technical-analysis/dist/momentum.d.ts +15 -0
- package/modules/technical-analysis/dist/momentum.d.ts.map +1 -0
- package/modules/technical-analysis/dist/momentum.js +14 -0
- package/modules/technical-analysis/dist/momentum.js.map +1 -0
- package/modules/technical-analysis/dist/moving-averages.d.ts +344 -0
- package/modules/technical-analysis/dist/moving-averages.d.ts.map +1 -0
- package/modules/technical-analysis/dist/moving-averages.js +1279 -0
- package/modules/technical-analysis/dist/moving-averages.js.map +1 -0
- package/modules/technical-analysis/dist/nan-policy.d.ts +42 -0
- package/modules/technical-analysis/dist/nan-policy.d.ts.map +1 -0
- package/modules/technical-analysis/dist/nan-policy.js +60 -0
- package/modules/technical-analysis/dist/nan-policy.js.map +1 -0
- package/modules/technical-analysis/dist/oscillators.d.ts +377 -0
- package/modules/technical-analysis/dist/oscillators.d.ts.map +1 -0
- package/modules/technical-analysis/dist/oscillators.js +1225 -0
- package/modules/technical-analysis/dist/oscillators.js.map +1 -0
- package/modules/technical-analysis/dist/output-meta.d.ts +71 -0
- package/modules/technical-analysis/dist/output-meta.d.ts.map +1 -0
- package/modules/technical-analysis/dist/output-meta.js +399 -0
- package/modules/technical-analysis/dist/output-meta.js.map +1 -0
- package/modules/technical-analysis/dist/overlap-ext.d.ts +206 -0
- package/modules/technical-analysis/dist/overlap-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/overlap-ext.js +550 -0
- package/modules/technical-analysis/dist/overlap-ext.js.map +1 -0
- package/modules/technical-analysis/dist/overlap.d.ts +11 -0
- package/modules/technical-analysis/dist/overlap.d.ts.map +1 -0
- package/modules/technical-analysis/dist/overlap.js +10 -0
- package/modules/technical-analysis/dist/overlap.js.map +1 -0
- package/modules/technical-analysis/dist/performance-ext.d.ts +21 -0
- package/modules/technical-analysis/dist/performance-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/performance-ext.js +31 -0
- package/modules/technical-analysis/dist/performance-ext.js.map +1 -0
- package/modules/technical-analysis/dist/pipeline.d.ts +105 -0
- package/modules/technical-analysis/dist/pipeline.d.ts.map +1 -0
- package/modules/technical-analysis/dist/pipeline.js +224 -0
- package/modules/technical-analysis/dist/pipeline.js.map +1 -0
- package/modules/technical-analysis/dist/price-action-ext.d.ts +90 -0
- package/modules/technical-analysis/dist/price-action-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/price-action-ext.js +511 -0
- package/modules/technical-analysis/dist/price-action-ext.js.map +1 -0
- package/modules/technical-analysis/dist/price-action.d.ts +348 -0
- package/modules/technical-analysis/dist/price-action.d.ts.map +1 -0
- package/modules/technical-analysis/dist/price-action.js +613 -0
- package/modules/technical-analysis/dist/price-action.js.map +1 -0
- package/modules/technical-analysis/dist/registry.d.ts +84 -0
- package/modules/technical-analysis/dist/registry.d.ts.map +1 -0
- package/modules/technical-analysis/dist/registry.js +625 -0
- package/modules/technical-analysis/dist/registry.js.map +1 -0
- package/modules/technical-analysis/dist/resample.d.ts +77 -0
- package/modules/technical-analysis/dist/resample.d.ts.map +1 -0
- package/modules/technical-analysis/dist/resample.js +239 -0
- package/modules/technical-analysis/dist/resample.js.map +1 -0
- package/modules/technical-analysis/dist/rsi.d.ts +36 -0
- package/modules/technical-analysis/dist/rsi.d.ts.map +1 -0
- package/modules/technical-analysis/dist/rsi.js +95 -0
- package/modules/technical-analysis/dist/rsi.js.map +1 -0
- package/modules/technical-analysis/dist/series.d.ts +40 -0
- package/modules/technical-analysis/dist/series.d.ts.map +1 -0
- package/modules/technical-analysis/dist/series.js +125 -0
- package/modules/technical-analysis/dist/series.js.map +1 -0
- package/modules/technical-analysis/dist/signal.d.ts +140 -0
- package/modules/technical-analysis/dist/signal.d.ts.map +1 -0
- package/modules/technical-analysis/dist/signal.js +353 -0
- package/modules/technical-analysis/dist/signal.js.map +1 -0
- package/modules/technical-analysis/dist/snapshot-cardinality.d.ts +17 -0
- package/modules/technical-analysis/dist/snapshot-cardinality.d.ts.map +1 -0
- package/modules/technical-analysis/dist/snapshot-cardinality.js +53 -0
- package/modules/technical-analysis/dist/snapshot-cardinality.js.map +1 -0
- package/modules/technical-analysis/dist/snapshot-envelope.d.ts +19 -0
- package/modules/technical-analysis/dist/snapshot-envelope.d.ts.map +1 -0
- package/modules/technical-analysis/dist/snapshot-envelope.js +87 -0
- package/modules/technical-analysis/dist/snapshot-envelope.js.map +1 -0
- package/modules/technical-analysis/dist/statistics.d.ts +146 -0
- package/modules/technical-analysis/dist/statistics.d.ts.map +1 -0
- package/modules/technical-analysis/dist/statistics.js +524 -0
- package/modules/technical-analysis/dist/statistics.js.map +1 -0
- package/modules/technical-analysis/dist/stream-validation.d.ts +14 -0
- package/modules/technical-analysis/dist/stream-validation.d.ts.map +1 -0
- package/modules/technical-analysis/dist/stream-validation.js +35 -0
- package/modules/technical-analysis/dist/stream-validation.js.map +1 -0
- package/modules/technical-analysis/dist/transforms.d.ts +77 -0
- package/modules/technical-analysis/dist/transforms.d.ts.map +1 -0
- package/modules/technical-analysis/dist/transforms.js +246 -0
- package/modules/technical-analysis/dist/transforms.js.map +1 -0
- package/modules/technical-analysis/dist/trend-ext.d.ts +121 -0
- package/modules/technical-analysis/dist/trend-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/trend-ext.js +691 -0
- package/modules/technical-analysis/dist/trend-ext.js.map +1 -0
- package/modules/technical-analysis/dist/trend.d.ts +373 -0
- package/modules/technical-analysis/dist/trend.d.ts.map +1 -0
- package/modules/technical-analysis/dist/trend.js +1159 -0
- package/modules/technical-analysis/dist/trend.js.map +1 -0
- package/modules/technical-analysis/dist/validate.d.ts +61 -0
- package/modules/technical-analysis/dist/validate.d.ts.map +1 -0
- package/modules/technical-analysis/dist/validate.js +334 -0
- package/modules/technical-analysis/dist/validate.js.map +1 -0
- package/modules/technical-analysis/dist/volatility-ext.d.ts +98 -0
- package/modules/technical-analysis/dist/volatility-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/volatility-ext.js +535 -0
- package/modules/technical-analysis/dist/volatility-ext.js.map +1 -0
- package/modules/technical-analysis/dist/volatility.d.ts +239 -0
- package/modules/technical-analysis/dist/volatility.d.ts.map +1 -0
- package/modules/technical-analysis/dist/volatility.js +709 -0
- package/modules/technical-analysis/dist/volatility.js.map +1 -0
- package/modules/technical-analysis/dist/volume-core.d.ts +273 -0
- package/modules/technical-analysis/dist/volume-core.d.ts.map +1 -0
- package/modules/technical-analysis/dist/volume-core.js +847 -0
- package/modules/technical-analysis/dist/volume-core.js.map +1 -0
- package/modules/technical-analysis/dist/volume-ext.d.ts +61 -0
- package/modules/technical-analysis/dist/volume-ext.d.ts.map +1 -0
- package/modules/technical-analysis/dist/volume-ext.js +270 -0
- package/modules/technical-analysis/dist/volume-ext.js.map +1 -0
- package/modules/technical-analysis/dist/volume.d.ts +15 -0
- package/modules/technical-analysis/dist/volume.d.ts.map +1 -0
- package/modules/technical-analysis/dist/volume.js +15 -0
- package/modules/technical-analysis/dist/volume.js.map +1 -0
- package/modules/technical-analysis/dist/warmup.d.ts +38 -0
- package/modules/technical-analysis/dist/warmup.d.ts.map +1 -0
- package/modules/technical-analysis/dist/warmup.js +269 -0
- package/modules/technical-analysis/dist/warmup.js.map +1 -0
- package/modules/technical-analysis/etc/technical-analysis.api.md +663 -0
- package/modules/technical-analysis/src/aliases.ts +466 -0
- package/modules/technical-analysis/src/bands.ts +113 -0
- package/modules/technical-analysis/src/bars.ts +456 -0
- package/modules/technical-analysis/src/builtin-metadata.ts +1686 -0
- package/modules/technical-analysis/src/candle-aliases.ts +289 -0
- package/modules/technical-analysis/src/candle-talib.ts +215 -0
- package/modules/technical-analysis/src/candlesticks.ts +1024 -0
- package/modules/technical-analysis/src/chart-types.ts +813 -0
- package/modules/technical-analysis/src/columns.ts +87 -0
- package/modules/technical-analysis/src/cycle.ts +625 -0
- package/modules/technical-analysis/src/discover.ts +390 -0
- package/modules/technical-analysis/src/divergence.ts +388 -0
- package/modules/technical-analysis/src/features-ext.ts +866 -0
- package/modules/technical-analysis/src/features.ts +9 -0
- package/modules/technical-analysis/src/framework.ts +1331 -0
- package/modules/technical-analysis/src/fuzzy.ts +92 -0
- package/modules/technical-analysis/src/generated/validation-specs.ts +1055 -0
- package/modules/technical-analysis/src/index.ts +825 -0
- package/modules/technical-analysis/src/indicator-metadata.ts +43 -0
- package/modules/technical-analysis/src/limits.ts +19 -0
- package/modules/technical-analysis/src/macd.ts +95 -0
- package/modules/technical-analysis/src/math.ts +181 -0
- package/modules/technical-analysis/src/microstructure.ts +870 -0
- package/modules/technical-analysis/src/momentum-ext.ts +2348 -0
- package/modules/technical-analysis/src/momentum.ts +16 -0
- package/modules/technical-analysis/src/moving-averages.ts +1525 -0
- package/modules/technical-analysis/src/nan-policy.ts +58 -0
- package/modules/technical-analysis/src/oscillators.ts +1586 -0
- package/modules/technical-analysis/src/output-meta.ts +466 -0
- package/modules/technical-analysis/src/overlap-ext.ts +792 -0
- package/modules/technical-analysis/src/overlap.ts +12 -0
- package/modules/technical-analysis/src/performance-ext.ts +57 -0
- package/modules/technical-analysis/src/pipeline.ts +270 -0
- package/modules/technical-analysis/src/price-action-ext.ts +675 -0
- package/modules/technical-analysis/src/price-action.ts +955 -0
- package/modules/technical-analysis/src/registry.ts +784 -0
- package/modules/technical-analysis/src/resample.ts +335 -0
- package/modules/technical-analysis/src/rsi.ts +120 -0
- package/modules/technical-analysis/src/series.ts +168 -0
- package/modules/technical-analysis/src/signal.ts +429 -0
- package/modules/technical-analysis/src/snapshot-cardinality.ts +83 -0
- package/modules/technical-analysis/src/snapshot-envelope.ts +131 -0
- package/modules/technical-analysis/src/statistics.ts +720 -0
- package/modules/technical-analysis/src/stream-validation.ts +42 -0
- package/modules/technical-analysis/src/transforms.ts +351 -0
- package/modules/technical-analysis/src/trend-ext.ts +957 -0
- package/modules/technical-analysis/src/trend.ts +1529 -0
- package/modules/technical-analysis/src/validate.ts +555 -0
- package/modules/technical-analysis/src/volatility-ext.ts +781 -0
- package/modules/technical-analysis/src/volatility.ts +963 -0
- package/modules/technical-analysis/src/volume-core.ts +1106 -0
- package/modules/technical-analysis/src/volume-ext.ts +380 -0
- package/modules/technical-analysis/src/volume.ts +14 -0
- package/modules/technical-analysis/src/warmup.ts +322 -0
- package/modules/totalfinance/dist/backtest.d.ts +3 -0
- package/modules/totalfinance/dist/backtest.d.ts.map +1 -0
- package/modules/totalfinance/dist/backtest.js +3 -0
- package/modules/totalfinance/dist/backtest.js.map +1 -0
- package/modules/totalfinance/dist/calendars.d.ts +3 -0
- package/modules/totalfinance/dist/calendars.d.ts.map +1 -0
- package/modules/totalfinance/dist/calendars.js +3 -0
- package/modules/totalfinance/dist/calendars.js.map +1 -0
- package/modules/totalfinance/dist/commodities.d.ts +2 -0
- package/modules/totalfinance/dist/commodities.d.ts.map +1 -0
- package/modules/totalfinance/dist/commodities.js +2 -0
- package/modules/totalfinance/dist/commodities.js.map +1 -0
- package/modules/totalfinance/dist/core.d.ts +3 -0
- package/modules/totalfinance/dist/core.d.ts.map +1 -0
- package/modules/totalfinance/dist/core.js +3 -0
- package/modules/totalfinance/dist/core.js.map +1 -0
- package/modules/totalfinance/dist/crypto.d.ts +3 -0
- package/modules/totalfinance/dist/crypto.d.ts.map +1 -0
- package/modules/totalfinance/dist/crypto.js +3 -0
- package/modules/totalfinance/dist/crypto.js.map +1 -0
- package/modules/totalfinance/dist/fixed-income.d.ts +3 -0
- package/modules/totalfinance/dist/fixed-income.d.ts.map +1 -0
- package/modules/totalfinance/dist/fixed-income.js +3 -0
- package/modules/totalfinance/dist/fixed-income.js.map +1 -0
- package/modules/totalfinance/dist/foreign-exchange.d.ts +2 -0
- package/modules/totalfinance/dist/foreign-exchange.d.ts.map +1 -0
- package/modules/totalfinance/dist/foreign-exchange.js +2 -0
- package/modules/totalfinance/dist/foreign-exchange.js.map +1 -0
- package/modules/totalfinance/dist/fundamentals.d.ts +3 -0
- package/modules/totalfinance/dist/fundamentals.d.ts.map +1 -0
- package/modules/totalfinance/dist/fundamentals.js +3 -0
- package/modules/totalfinance/dist/fundamentals.js.map +1 -0
- package/modules/totalfinance/dist/index.d.ts +90 -0
- package/modules/totalfinance/dist/index.d.ts.map +1 -0
- package/modules/totalfinance/dist/index.js +68 -0
- package/modules/totalfinance/dist/index.js.map +1 -0
- package/modules/totalfinance/dist/math.d.ts +3 -0
- package/modules/totalfinance/dist/math.d.ts.map +1 -0
- package/modules/totalfinance/dist/math.js +3 -0
- package/modules/totalfinance/dist/math.js.map +1 -0
- package/modules/totalfinance/dist/options.d.ts +3 -0
- package/modules/totalfinance/dist/options.d.ts.map +1 -0
- package/modules/totalfinance/dist/options.js +3 -0
- package/modules/totalfinance/dist/options.js.map +1 -0
- package/modules/totalfinance/dist/performance.d.ts +3 -0
- package/modules/totalfinance/dist/performance.d.ts.map +1 -0
- package/modules/totalfinance/dist/performance.js +3 -0
- package/modules/totalfinance/dist/performance.js.map +1 -0
- package/modules/totalfinance/dist/portfolio.d.ts +2 -0
- package/modules/totalfinance/dist/portfolio.d.ts.map +1 -0
- package/modules/totalfinance/dist/portfolio.js +2 -0
- package/modules/totalfinance/dist/portfolio.js.map +1 -0
- package/modules/totalfinance/dist/research.d.ts +2 -0
- package/modules/totalfinance/dist/research.d.ts.map +1 -0
- package/modules/totalfinance/dist/research.js +2 -0
- package/modules/totalfinance/dist/research.js.map +1 -0
- package/modules/totalfinance/dist/risk.d.ts +3 -0
- package/modules/totalfinance/dist/risk.d.ts.map +1 -0
- package/modules/totalfinance/dist/risk.js +3 -0
- package/modules/totalfinance/dist/risk.js.map +1 -0
- package/modules/totalfinance/dist/scenarios.d.ts +2 -0
- package/modules/totalfinance/dist/scenarios.d.ts.map +1 -0
- package/modules/totalfinance/dist/scenarios.js +2 -0
- package/modules/totalfinance/dist/scenarios.js.map +1 -0
- package/modules/totalfinance/dist/strategy.d.ts +3 -0
- package/modules/totalfinance/dist/strategy.d.ts.map +1 -0
- package/modules/totalfinance/dist/strategy.js +3 -0
- package/modules/totalfinance/dist/strategy.js.map +1 -0
- package/modules/totalfinance/dist/structure.d.ts +3 -0
- package/modules/totalfinance/dist/structure.d.ts.map +1 -0
- package/modules/totalfinance/dist/structure.js +3 -0
- package/modules/totalfinance/dist/structure.js.map +1 -0
- package/modules/totalfinance/dist/technical-analysis.d.ts +3 -0
- package/modules/totalfinance/dist/technical-analysis.d.ts.map +1 -0
- package/modules/totalfinance/dist/technical-analysis.js +3 -0
- package/modules/totalfinance/dist/technical-analysis.js.map +1 -0
- package/modules/totalfinance/dist/valuation.d.ts +3 -0
- package/modules/totalfinance/dist/valuation.d.ts.map +1 -0
- package/modules/totalfinance/dist/valuation.js +3 -0
- package/modules/totalfinance/dist/valuation.js.map +1 -0
- package/modules/totalfinance/dist/volatility.d.ts +3 -0
- package/modules/totalfinance/dist/volatility.d.ts.map +1 -0
- package/modules/totalfinance/dist/volatility.js +3 -0
- package/modules/totalfinance/dist/volatility.js.map +1 -0
- package/modules/totalfinance/etc/totalfinance.api.md +73 -0
- package/modules/totalfinance/src/backtest.ts +2 -0
- package/modules/totalfinance/src/calendars.ts +2 -0
- package/modules/totalfinance/src/commodities.ts +1 -0
- package/modules/totalfinance/src/core.ts +2 -0
- package/modules/totalfinance/src/crypto.ts +2 -0
- package/modules/totalfinance/src/fixed-income.ts +2 -0
- package/modules/totalfinance/src/foreign-exchange.ts +1 -0
- package/modules/totalfinance/src/fundamentals.ts +2 -0
- package/modules/totalfinance/src/index.ts +129 -0
- package/modules/totalfinance/src/math.ts +2 -0
- package/modules/totalfinance/src/options.ts +2 -0
- package/modules/totalfinance/src/performance.ts +2 -0
- package/modules/totalfinance/src/portfolio.ts +1 -0
- package/modules/totalfinance/src/research.ts +1 -0
- package/modules/totalfinance/src/risk.ts +2 -0
- package/modules/totalfinance/src/scenarios.ts +1 -0
- package/modules/totalfinance/src/strategy.ts +2 -0
- package/modules/totalfinance/src/structure.ts +2 -0
- package/modules/totalfinance/src/technical-analysis.ts +2 -0
- package/modules/totalfinance/src/valuation.ts +2 -0
- package/modules/totalfinance/src/volatility.ts +2 -0
- package/modules/valuation/dist/adjusted-present-value.d.ts +62 -0
- package/modules/valuation/dist/adjusted-present-value.d.ts.map +1 -0
- package/modules/valuation/dist/adjusted-present-value.js +85 -0
- package/modules/valuation/dist/adjusted-present-value.js.map +1 -0
- package/modules/valuation/dist/capital-budgeting.d.ts +84 -0
- package/modules/valuation/dist/capital-budgeting.d.ts.map +1 -0
- package/modules/valuation/dist/capital-budgeting.js +204 -0
- package/modules/valuation/dist/capital-budgeting.js.map +1 -0
- package/modules/valuation/dist/cash-flows.d.ts +11 -0
- package/modules/valuation/dist/cash-flows.d.ts.map +1 -0
- package/modules/valuation/dist/cash-flows.js +10 -0
- package/modules/valuation/dist/cash-flows.js.map +1 -0
- package/modules/valuation/dist/comparable.d.ts +101 -0
- package/modules/valuation/dist/comparable.d.ts.map +1 -0
- package/modules/valuation/dist/comparable.js +194 -0
- package/modules/valuation/dist/comparable.js.map +1 -0
- package/modules/valuation/dist/corporate-primitives.d.ts +185 -0
- package/modules/valuation/dist/corporate-primitives.d.ts.map +1 -0
- package/modules/valuation/dist/corporate-primitives.js +337 -0
- package/modules/valuation/dist/corporate-primitives.js.map +1 -0
- package/modules/valuation/dist/corporate.d.ts +14 -0
- package/modules/valuation/dist/corporate.d.ts.map +1 -0
- package/modules/valuation/dist/corporate.js +13 -0
- package/modules/valuation/dist/corporate.js.map +1 -0
- package/modules/valuation/dist/discounted-cash-flow.d.ts +269 -0
- package/modules/valuation/dist/discounted-cash-flow.d.ts.map +1 -0
- package/modules/valuation/dist/discounted-cash-flow.js +611 -0
- package/modules/valuation/dist/discounted-cash-flow.js.map +1 -0
- package/modules/valuation/dist/discounting.d.ts +124 -0
- package/modules/valuation/dist/discounting.d.ts.map +1 -0
- package/modules/valuation/dist/discounting.js +235 -0
- package/modules/valuation/dist/discounting.js.map +1 -0
- package/modules/valuation/dist/equity-valuation.d.ts +104 -0
- package/modules/valuation/dist/equity-valuation.d.ts.map +1 -0
- package/modules/valuation/dist/equity-valuation.js +164 -0
- package/modules/valuation/dist/equity-valuation.js.map +1 -0
- package/modules/valuation/dist/flows.d.ts +30 -0
- package/modules/valuation/dist/flows.d.ts.map +1 -0
- package/modules/valuation/dist/flows.js +77 -0
- package/modules/valuation/dist/flows.js.map +1 -0
- package/modules/valuation/dist/forecasting.d.ts +205 -0
- package/modules/valuation/dist/forecasting.d.ts.map +1 -0
- package/modules/valuation/dist/forecasting.js +359 -0
- package/modules/valuation/dist/forecasting.js.map +1 -0
- package/modules/valuation/dist/index.d.ts +9 -0
- package/modules/valuation/dist/index.d.ts.map +1 -0
- package/modules/valuation/dist/index.js +10 -0
- package/modules/valuation/dist/index.js.map +1 -0
- package/modules/valuation/dist/leveraged-buyout.d.ts +160 -0
- package/modules/valuation/dist/leveraged-buyout.d.ts.map +1 -0
- package/modules/valuation/dist/leveraged-buyout.js +326 -0
- package/modules/valuation/dist/leveraged-buyout.js.map +1 -0
- package/modules/valuation/dist/loans.d.ts +148 -0
- package/modules/valuation/dist/loans.d.ts.map +1 -0
- package/modules/valuation/dist/loans.js +518 -0
- package/modules/valuation/dist/loans.js.map +1 -0
- package/modules/valuation/dist/probabilistic.d.ts +88 -0
- package/modules/valuation/dist/probabilistic.d.ts.map +1 -0
- package/modules/valuation/dist/probabilistic.js +239 -0
- package/modules/valuation/dist/probabilistic.js.map +1 -0
- package/modules/valuation/dist/solvers.d.ts +90 -0
- package/modules/valuation/dist/solvers.d.ts.map +1 -0
- package/modules/valuation/dist/solvers.js +238 -0
- package/modules/valuation/dist/solvers.js.map +1 -0
- package/modules/valuation/etc/valuation.api.md +162 -0
- package/modules/valuation/src/adjusted-present-value.ts +181 -0
- package/modules/valuation/src/capital-budgeting.ts +329 -0
- package/modules/valuation/src/cash-flows.ts +11 -0
- package/modules/valuation/src/comparable.ts +340 -0
- package/modules/valuation/src/corporate-primitives.ts +665 -0
- package/modules/valuation/src/corporate.ts +36 -0
- package/modules/valuation/src/discounted-cash-flow.ts +1083 -0
- package/modules/valuation/src/discounting.ts +437 -0
- package/modules/valuation/src/equity-valuation.ts +313 -0
- package/modules/valuation/src/flows.ts +144 -0
- package/modules/valuation/src/forecasting.ts +666 -0
- package/modules/valuation/src/index.ts +10 -0
- package/modules/valuation/src/leveraged-buyout.ts +560 -0
- package/modules/valuation/src/loans.ts +778 -0
- package/modules/valuation/src/probabilistic.ts +438 -0
- package/modules/valuation/src/solvers.ts +397 -0
- package/modules/volatility/dist/analytics.d.ts +133 -0
- package/modules/volatility/dist/analytics.d.ts.map +1 -0
- package/modules/volatility/dist/analytics.js +320 -0
- package/modules/volatility/dist/analytics.js.map +1 -0
- package/modules/volatility/dist/arbitrage.d.ts +118 -0
- package/modules/volatility/dist/arbitrage.d.ts.map +1 -0
- package/modules/volatility/dist/arbitrage.js +397 -0
- package/modules/volatility/dist/arbitrage.js.map +1 -0
- package/modules/volatility/dist/artifacts.d.ts +24 -0
- package/modules/volatility/dist/artifacts.d.ts.map +1 -0
- package/modules/volatility/dist/artifacts.js +22 -0
- package/modules/volatility/dist/artifacts.js.map +1 -0
- package/modules/volatility/dist/calibration-limits.d.ts +13 -0
- package/modules/volatility/dist/calibration-limits.d.ts.map +1 -0
- package/modules/volatility/dist/calibration-limits.js +46 -0
- package/modules/volatility/dist/calibration-limits.js.map +1 -0
- package/modules/volatility/dist/calibration-start.d.ts +13 -0
- package/modules/volatility/dist/calibration-start.d.ts.map +1 -0
- package/modules/volatility/dist/calibration-start.js +55 -0
- package/modules/volatility/dist/calibration-start.js.map +1 -0
- package/modules/volatility/dist/earnings.d.ts +152 -0
- package/modules/volatility/dist/earnings.d.ts.map +1 -0
- package/modules/volatility/dist/earnings.js +340 -0
- package/modules/volatility/dist/earnings.js.map +1 -0
- package/modules/volatility/dist/essvi.d.ts +115 -0
- package/modules/volatility/dist/essvi.d.ts.map +1 -0
- package/modules/volatility/dist/essvi.js +362 -0
- package/modules/volatility/dist/essvi.js.map +1 -0
- package/modules/volatility/dist/estimate.d.ts +14 -0
- package/modules/volatility/dist/estimate.d.ts.map +1 -0
- package/modules/volatility/dist/estimate.js +18 -0
- package/modules/volatility/dist/estimate.js.map +1 -0
- package/modules/volatility/dist/event.d.ts +155 -0
- package/modules/volatility/dist/event.d.ts.map +1 -0
- package/modules/volatility/dist/event.js +319 -0
- package/modules/volatility/dist/event.js.map +1 -0
- package/modules/volatility/dist/fitted-model-artifacts.d.ts +378 -0
- package/modules/volatility/dist/fitted-model-artifacts.d.ts.map +1 -0
- package/modules/volatility/dist/fitted-model-artifacts.js +1139 -0
- package/modules/volatility/dist/fitted-model-artifacts.js.map +1 -0
- package/modules/volatility/dist/fitted-model-families.d.ts +287 -0
- package/modules/volatility/dist/fitted-model-families.d.ts.map +1 -0
- package/modules/volatility/dist/fitted-model-families.js +1251 -0
- package/modules/volatility/dist/fitted-model-families.js.map +1 -0
- package/modules/volatility/dist/forecast.d.ts +195 -0
- package/modules/volatility/dist/forecast.d.ts.map +1 -0
- package/modules/volatility/dist/forecast.js +493 -0
- package/modules/volatility/dist/forecast.js.map +1 -0
- package/modules/volatility/dist/generated/validation-specs.d.ts +12 -0
- package/modules/volatility/dist/generated/validation-specs.d.ts.map +1 -0
- package/modules/volatility/dist/generated/validation-specs.js +2181 -0
- package/modules/volatility/dist/generated/validation-specs.js.map +1 -0
- package/modules/volatility/dist/heston-surface.d.ts +67 -0
- package/modules/volatility/dist/heston-surface.d.ts.map +1 -0
- package/modules/volatility/dist/heston-surface.js +135 -0
- package/modules/volatility/dist/heston-surface.js.map +1 -0
- package/modules/volatility/dist/index.d.ts +64 -0
- package/modules/volatility/dist/index.d.ts.map +1 -0
- package/modules/volatility/dist/index.js +68 -0
- package/modules/volatility/dist/index.js.map +1 -0
- package/modules/volatility/dist/local-volatility.d.ts +34 -0
- package/modules/volatility/dist/local-volatility.d.ts.map +1 -0
- package/modules/volatility/dist/local-volatility.js +59 -0
- package/modules/volatility/dist/local-volatility.js.map +1 -0
- package/modules/volatility/dist/metrics.d.ts +41 -0
- package/modules/volatility/dist/metrics.d.ts.map +1 -0
- package/modules/volatility/dist/metrics.js +117 -0
- package/modules/volatility/dist/metrics.js.map +1 -0
- package/modules/volatility/dist/min-variance-delta.d.ts +61 -0
- package/modules/volatility/dist/min-variance-delta.d.ts.map +1 -0
- package/modules/volatility/dist/min-variance-delta.js +101 -0
- package/modules/volatility/dist/min-variance-delta.js.map +1 -0
- package/modules/volatility/dist/observed-skew.d.ts +137 -0
- package/modules/volatility/dist/observed-skew.d.ts.map +1 -0
- package/modules/volatility/dist/observed-skew.js +461 -0
- package/modules/volatility/dist/observed-skew.js.map +1 -0
- package/modules/volatility/dist/otm-strip.d.ts +39 -0
- package/modules/volatility/dist/otm-strip.d.ts.map +1 -0
- package/modules/volatility/dist/otm-strip.js +181 -0
- package/modules/volatility/dist/otm-strip.js.map +1 -0
- package/modules/volatility/dist/risk-reversal.d.ts +89 -0
- package/modules/volatility/dist/risk-reversal.d.ts.map +1 -0
- package/modules/volatility/dist/risk-reversal.js +176 -0
- package/modules/volatility/dist/risk-reversal.js.map +1 -0
- package/modules/volatility/dist/sabr-delta.d.ts +67 -0
- package/modules/volatility/dist/sabr-delta.d.ts.map +1 -0
- package/modules/volatility/dist/sabr-delta.js +153 -0
- package/modules/volatility/dist/sabr-delta.js.map +1 -0
- package/modules/volatility/dist/sabr.d.ts +62 -0
- package/modules/volatility/dist/sabr.d.ts.map +1 -0
- package/modules/volatility/dist/sabr.js +262 -0
- package/modules/volatility/dist/sabr.js.map +1 -0
- package/modules/volatility/dist/skew.d.ts +63 -0
- package/modules/volatility/dist/skew.d.ts.map +1 -0
- package/modules/volatility/dist/skew.js +147 -0
- package/modules/volatility/dist/skew.js.map +1 -0
- package/modules/volatility/dist/ssvi-kernel.d.ts +90 -0
- package/modules/volatility/dist/ssvi-kernel.d.ts.map +1 -0
- package/modules/volatility/dist/ssvi-kernel.js +103 -0
- package/modules/volatility/dist/ssvi-kernel.js.map +1 -0
- package/modules/volatility/dist/ssvi.d.ts +181 -0
- package/modules/volatility/dist/ssvi.d.ts.map +1 -0
- package/modules/volatility/dist/ssvi.js +490 -0
- package/modules/volatility/dist/ssvi.js.map +1 -0
- package/modules/volatility/dist/sticky-regime.d.ts +47 -0
- package/modules/volatility/dist/sticky-regime.d.ts.map +1 -0
- package/modules/volatility/dist/sticky-regime.js +81 -0
- package/modules/volatility/dist/sticky-regime.js.map +1 -0
- package/modules/volatility/dist/surface-pca.d.ts +111 -0
- package/modules/volatility/dist/surface-pca.d.ts.map +1 -0
- package/modules/volatility/dist/surface-pca.js +297 -0
- package/modules/volatility/dist/surface-pca.js.map +1 -0
- package/modules/volatility/dist/surface.d.ts +286 -0
- package/modules/volatility/dist/surface.d.ts.map +1 -0
- package/modules/volatility/dist/surface.js +1105 -0
- package/modules/volatility/dist/surface.js.map +1 -0
- package/modules/volatility/dist/svi.d.ts +133 -0
- package/modules/volatility/dist/svi.d.ts.map +1 -0
- package/modules/volatility/dist/svi.js +491 -0
- package/modules/volatility/dist/svi.js.map +1 -0
- package/modules/volatility/dist/swaption-cube.d.ts +125 -0
- package/modules/volatility/dist/swaption-cube.d.ts.map +1 -0
- package/modules/volatility/dist/swaption-cube.js +334 -0
- package/modules/volatility/dist/swaption-cube.js.map +1 -0
- package/modules/volatility/dist/tail-risk.d.ts +65 -0
- package/modules/volatility/dist/tail-risk.d.ts.map +1 -0
- package/modules/volatility/dist/tail-risk.js +155 -0
- package/modules/volatility/dist/tail-risk.js.map +1 -0
- package/modules/volatility/dist/term.d.ts +121 -0
- package/modules/volatility/dist/term.d.ts.map +1 -0
- package/modules/volatility/dist/term.js +336 -0
- package/modules/volatility/dist/term.js.map +1 -0
- package/modules/volatility/dist/vanna-volga.d.ts +278 -0
- package/modules/volatility/dist/vanna-volga.d.ts.map +1 -0
- package/modules/volatility/dist/vanna-volga.js +833 -0
- package/modules/volatility/dist/vanna-volga.js.map +1 -0
- package/modules/volatility/dist/variance-index.d.ts +101 -0
- package/modules/volatility/dist/variance-index.d.ts.map +1 -0
- package/modules/volatility/dist/variance-index.js +240 -0
- package/modules/volatility/dist/variance-index.js.map +1 -0
- package/modules/volatility/dist/volatility-spot-beta.d.ts +57 -0
- package/modules/volatility/dist/volatility-spot-beta.d.ts.map +1 -0
- package/modules/volatility/dist/volatility-spot-beta.js +136 -0
- package/modules/volatility/dist/volatility-spot-beta.js.map +1 -0
- package/modules/volatility/etc/volatility.api.md +207 -0
- package/modules/volatility/src/analytics.ts +513 -0
- package/modules/volatility/src/arbitrage.ts +561 -0
- package/modules/volatility/src/artifacts.ts +62 -0
- package/modules/volatility/src/calibration-limits.ts +61 -0
- package/modules/volatility/src/calibration-start.ts +79 -0
- package/modules/volatility/src/earnings.ts +548 -0
- package/modules/volatility/src/essvi.ts +528 -0
- package/modules/volatility/src/estimate.ts +21 -0
- package/modules/volatility/src/event.ts +542 -0
- package/modules/volatility/src/fitted-model-artifacts.ts +1844 -0
- package/modules/volatility/src/fitted-model-families.ts +1681 -0
- package/modules/volatility/src/forecast.ts +757 -0
- package/modules/volatility/src/generated/validation-specs.ts +2184 -0
- package/modules/volatility/src/heston-surface.ts +215 -0
- package/modules/volatility/src/index.ts +285 -0
- package/modules/volatility/src/local-volatility.ts +104 -0
- package/modules/volatility/src/metrics.ts +176 -0
- package/modules/volatility/src/min-variance-delta.ts +167 -0
- package/modules/volatility/src/observed-skew.ts +684 -0
- package/modules/volatility/src/otm-strip.ts +234 -0
- package/modules/volatility/src/risk-reversal.ts +316 -0
- package/modules/volatility/src/sabr-delta.ts +238 -0
- package/modules/volatility/src/sabr.ts +375 -0
- package/modules/volatility/src/skew.ts +244 -0
- package/modules/volatility/src/ssvi-kernel.ts +134 -0
- package/modules/volatility/src/ssvi.ts +707 -0
- package/modules/volatility/src/sticky-regime.ts +150 -0
- package/modules/volatility/src/surface-pca.ts +439 -0
- package/modules/volatility/src/surface.ts +1499 -0
- package/modules/volatility/src/svi.ts +687 -0
- package/modules/volatility/src/swaption-cube.ts +539 -0
- package/modules/volatility/src/tail-risk.ts +254 -0
- package/modules/volatility/src/term.ts +587 -0
- package/modules/volatility/src/vanna-volga.ts +1337 -0
- package/modules/volatility/src/variance-index.ts +396 -0
- package/modules/volatility/src/volatility-spot-beta.ts +252 -0
- package/modules/workflows/dist/capabilities.d.ts +8 -0
- package/modules/workflows/dist/capabilities.d.ts.map +1 -0
- package/modules/workflows/dist/capabilities.js +50 -0
- package/modules/workflows/dist/capabilities.js.map +1 -0
- package/modules/workflows/dist/envelope-schema.d.ts +36 -0
- package/modules/workflows/dist/envelope-schema.d.ts.map +1 -0
- package/modules/workflows/dist/envelope-schema.js +152 -0
- package/modules/workflows/dist/envelope-schema.js.map +1 -0
- package/modules/workflows/dist/index.d.ts +33 -0
- package/modules/workflows/dist/index.d.ts.map +1 -0
- package/modules/workflows/dist/index.js +27 -0
- package/modules/workflows/dist/index.js.map +1 -0
- package/modules/workflows/dist/json-safe.d.ts +7 -0
- package/modules/workflows/dist/json-safe.d.ts.map +1 -0
- package/modules/workflows/dist/json-safe.js +23 -0
- package/modules/workflows/dist/json-safe.js.map +1 -0
- package/modules/workflows/dist/local/file-lock.d.ts +23 -0
- package/modules/workflows/dist/local/file-lock.d.ts.map +1 -0
- package/modules/workflows/dist/local/file-lock.js +198 -0
- package/modules/workflows/dist/local/file-lock.js.map +1 -0
- package/modules/workflows/dist/local/file-stores.d.ts +33 -0
- package/modules/workflows/dist/local/file-stores.d.ts.map +1 -0
- package/modules/workflows/dist/local/file-stores.js +376 -0
- package/modules/workflows/dist/local/file-stores.js.map +1 -0
- package/modules/workflows/dist/local/index.d.ts +15 -0
- package/modules/workflows/dist/local/index.d.ts.map +1 -0
- package/modules/workflows/dist/local/index.js +12 -0
- package/modules/workflows/dist/local/index.js.map +1 -0
- package/modules/workflows/dist/local/job-worker.d.ts +28 -0
- package/modules/workflows/dist/local/job-worker.d.ts.map +1 -0
- package/modules/workflows/dist/local/job-worker.js +56 -0
- package/modules/workflows/dist/local/job-worker.js.map +1 -0
- package/modules/workflows/dist/local/jobs.d.ts +51 -0
- package/modules/workflows/dist/local/jobs.d.ts.map +1 -0
- package/modules/workflows/dist/local/jobs.js +313 -0
- package/modules/workflows/dist/local/jobs.js.map +1 -0
- package/modules/workflows/dist/local/local-runner.d.ts +39 -0
- package/modules/workflows/dist/local/local-runner.d.ts.map +1 -0
- package/modules/workflows/dist/local/local-runner.js +102 -0
- package/modules/workflows/dist/local/local-runner.js.map +1 -0
- package/modules/workflows/dist/local/profiles.d.ts +27 -0
- package/modules/workflows/dist/local/profiles.d.ts.map +1 -0
- package/modules/workflows/dist/local/profiles.js +77 -0
- package/modules/workflows/dist/local/profiles.js.map +1 -0
- package/modules/workflows/dist/operation-kit.d.ts +10 -0
- package/modules/workflows/dist/operation-kit.d.ts.map +1 -0
- package/modules/workflows/dist/operation-kit.js +193 -0
- package/modules/workflows/dist/operation-kit.js.map +1 -0
- package/modules/workflows/dist/operation.d.ts +210 -0
- package/modules/workflows/dist/operation.d.ts.map +1 -0
- package/modules/workflows/dist/operation.js +255 -0
- package/modules/workflows/dist/operation.js.map +1 -0
- package/modules/workflows/dist/operations-analysis.d.ts +188 -0
- package/modules/workflows/dist/operations-analysis.d.ts.map +1 -0
- package/modules/workflows/dist/operations-analysis.js +908 -0
- package/modules/workflows/dist/operations-analysis.js.map +1 -0
- package/modules/workflows/dist/operations-compute.d.ts +21 -0
- package/modules/workflows/dist/operations-compute.d.ts.map +1 -0
- package/modules/workflows/dist/operations-compute.js +1227 -0
- package/modules/workflows/dist/operations-compute.js.map +1 -0
- package/modules/workflows/dist/operations-journey.d.ts +27 -0
- package/modules/workflows/dist/operations-journey.d.ts.map +1 -0
- package/modules/workflows/dist/operations-journey.js +2445 -0
- package/modules/workflows/dist/operations-journey.js.map +1 -0
- package/modules/workflows/dist/operations-trade.d.ts +3 -0
- package/modules/workflows/dist/operations-trade.d.ts.map +1 -0
- package/modules/workflows/dist/operations-trade.js +648 -0
- package/modules/workflows/dist/operations-trade.js.map +1 -0
- package/modules/workflows/dist/preview.d.ts +16 -0
- package/modules/workflows/dist/preview.d.ts.map +1 -0
- package/modules/workflows/dist/preview.js +30 -0
- package/modules/workflows/dist/preview.js.map +1 -0
- package/modules/workflows/dist/registry.d.ts +26 -0
- package/modules/workflows/dist/registry.d.ts.map +1 -0
- package/modules/workflows/dist/registry.js +110 -0
- package/modules/workflows/dist/registry.js.map +1 -0
- package/modules/workflows/dist/runtime.d.ts +76 -0
- package/modules/workflows/dist/runtime.d.ts.map +1 -0
- package/modules/workflows/dist/runtime.js +445 -0
- package/modules/workflows/dist/runtime.js.map +1 -0
- package/modules/workflows/dist/stores-trade.d.ts +101 -0
- package/modules/workflows/dist/stores-trade.d.ts.map +1 -0
- package/modules/workflows/dist/stores-trade.js +275 -0
- package/modules/workflows/dist/stores-trade.js.map +1 -0
- package/modules/workflows/dist/stores.d.ts +109 -0
- package/modules/workflows/dist/stores.d.ts.map +1 -0
- package/modules/workflows/dist/stores.js +393 -0
- package/modules/workflows/dist/stores.js.map +1 -0
- package/modules/workflows/dist/trade-wire-common-schemas.d.ts +57 -0
- package/modules/workflows/dist/trade-wire-common-schemas.d.ts.map +1 -0
- package/modules/workflows/dist/trade-wire-common-schemas.js +286 -0
- package/modules/workflows/dist/trade-wire-common-schemas.js.map +1 -0
- package/modules/workflows/dist/trade-wire-ledger-schemas.d.ts +102 -0
- package/modules/workflows/dist/trade-wire-ledger-schemas.d.ts.map +1 -0
- package/modules/workflows/dist/trade-wire-ledger-schemas.js +321 -0
- package/modules/workflows/dist/trade-wire-ledger-schemas.js.map +1 -0
- package/modules/workflows/dist/trade-wire-market-schemas.d.ts +5 -0
- package/modules/workflows/dist/trade-wire-market-schemas.d.ts.map +1 -0
- package/modules/workflows/dist/trade-wire-market-schemas.js +84 -0
- package/modules/workflows/dist/trade-wire-market-schemas.js.map +1 -0
- package/modules/workflows/dist/trade-wire-schemas.d.ts +1134 -0
- package/modules/workflows/dist/trade-wire-schemas.d.ts.map +1 -0
- package/modules/workflows/dist/trade-wire-schemas.js +755 -0
- package/modules/workflows/dist/trade-wire-schemas.js.map +1 -0
- package/modules/workflows/dist/version.d.ts +3 -0
- package/modules/workflows/dist/version.d.ts.map +1 -0
- package/modules/workflows/dist/version.js +3 -0
- package/modules/workflows/dist/version.js.map +1 -0
- package/modules/workflows/dist/wire-schemas.d.ts +84 -0
- package/modules/workflows/dist/wire-schemas.d.ts.map +1 -0
- package/modules/workflows/dist/wire-schemas.js +88 -0
- package/modules/workflows/dist/wire-schemas.js.map +1 -0
- package/modules/workflows/etc/workflows.api.md +95 -0
- package/modules/workflows/src/capabilities.ts +67 -0
- package/modules/workflows/src/envelope-schema.ts +170 -0
- package/modules/workflows/src/index.ts +118 -0
- package/modules/workflows/src/json-safe.ts +19 -0
- package/modules/workflows/src/local/file-lock.ts +200 -0
- package/modules/workflows/src/local/file-stores.ts +452 -0
- package/modules/workflows/src/local/index.ts +20 -0
- package/modules/workflows/src/local/job-worker.ts +74 -0
- package/modules/workflows/src/local/jobs.ts +458 -0
- package/modules/workflows/src/local/local-runner.ts +170 -0
- package/modules/workflows/src/local/profiles.ts +113 -0
- package/modules/workflows/src/operation-kit.ts +234 -0
- package/modules/workflows/src/operation.ts +607 -0
- package/modules/workflows/src/operations-analysis.ts +1058 -0
- package/modules/workflows/src/operations-compute.ts +1458 -0
- package/modules/workflows/src/operations-journey.ts +2744 -0
- package/modules/workflows/src/operations-trade.ts +946 -0
- package/modules/workflows/src/preview.ts +34 -0
- package/modules/workflows/src/registry.ts +150 -0
- package/modules/workflows/src/runtime.ts +633 -0
- package/modules/workflows/src/stores-trade.ts +463 -0
- package/modules/workflows/src/stores.ts +608 -0
- package/modules/workflows/src/trade-wire-common-schemas.ts +337 -0
- package/modules/workflows/src/trade-wire-ledger-schemas.ts +359 -0
- package/modules/workflows/src/trade-wire-market-schemas.ts +103 -0
- package/modules/workflows/src/trade-wire-schemas.ts +906 -0
- package/modules/workflows/src/version.ts +2 -0
- package/modules/workflows/src/wire-schemas.ts +100 -0
- package/package.json +1008 -0
|
@@ -0,0 +1,1776 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The FC7 pure reducer: `PortfolioState` is a FOLD over immutable economic events (agent-native
|
|
3
|
+
* platform doc, Permanent law 1 — "Portfolio truth is event-derived"; spec D16). Same events →
|
|
4
|
+
* same state, always: the fold reads no clock, no locale, no global registry, and never mutates
|
|
5
|
+
* its inputs. Replaying an identical `(sourceId, eventId)` envelope is a no-op; a same-key
|
|
6
|
+
* envelope with a different body is a typed conflict (`portfolio.duplicate_event_conflict`).
|
|
7
|
+
*
|
|
8
|
+
* The fold derives FACTS ONLY: cash by currency (with each leg's settlement schedule — the
|
|
9
|
+
* settled/unsettled SPLIT is classified at an explicit `asOf` by `portfolioSnapshot`, keeping the
|
|
10
|
+
* fold clock-free), positions with signed fractional tax lots, realized P&L from lot relief, and
|
|
11
|
+
* income/cost/financing accumulators. Unrealized P&L, NAV, and base-currency values need marks
|
|
12
|
+
* and are derived reports (Permanent law 2 — "P&L is a derived result, not a ledger event").
|
|
13
|
+
*/
|
|
14
|
+
|
|
15
|
+
import type { EpochMs } from '@totalfinance/core';
|
|
16
|
+
import {
|
|
17
|
+
requireRepresentableResult,
|
|
18
|
+
DataError,
|
|
19
|
+
ErrorCode,
|
|
20
|
+
InputError,
|
|
21
|
+
ensureKnownKeys,
|
|
22
|
+
requireArgumentArray,
|
|
23
|
+
requireArgumentObject,
|
|
24
|
+
} from '@totalfinance/core';
|
|
25
|
+
import {
|
|
26
|
+
canonicalJsonOf,
|
|
27
|
+
fromCanonicalJson,
|
|
28
|
+
isContentHashString,
|
|
29
|
+
} from '@totalfinance/core/artifacts';
|
|
30
|
+
import type {
|
|
31
|
+
CashConversionEvent,
|
|
32
|
+
CashDepositEvent,
|
|
33
|
+
CashTransferEvent,
|
|
34
|
+
CashWithdrawalEvent,
|
|
35
|
+
CostChargeEvent,
|
|
36
|
+
DerivativeContractTerms,
|
|
37
|
+
FinancingChargeEvent,
|
|
38
|
+
IncomeReceivedEvent,
|
|
39
|
+
PortfolioEventEnvelope,
|
|
40
|
+
SettlementStyle,
|
|
41
|
+
StockSplitEvent,
|
|
42
|
+
TradeFillEvent,
|
|
43
|
+
} from './events.js';
|
|
44
|
+
import { applyCorporateEvent, reverseCorporateEvent } from './lifecycle-corporate.js';
|
|
45
|
+
import { applyDerivativeEvent, reverseDerivativeEvent } from './lifecycle-derivatives.js';
|
|
46
|
+
import type { PositionProfile } from './reducer-kernel.js';
|
|
47
|
+
import {
|
|
48
|
+
accountOf,
|
|
49
|
+
addTo,
|
|
50
|
+
addToInstrument,
|
|
51
|
+
bookCash,
|
|
52
|
+
cashOf,
|
|
53
|
+
ensurePosition,
|
|
54
|
+
finalizePosition,
|
|
55
|
+
foldPositionLeg,
|
|
56
|
+
infeasible,
|
|
57
|
+
recordIncome,
|
|
58
|
+
removeSettlementLeg,
|
|
59
|
+
} from './reducer-kernel.js';
|
|
60
|
+
export { reliefOrder } from './reducer-kernel.js';
|
|
61
|
+
import {
|
|
62
|
+
duplicateBoundaryKey,
|
|
63
|
+
portfolioEventContentHash,
|
|
64
|
+
requirePortfolioEventEnvelope,
|
|
65
|
+
} from './events.js';
|
|
66
|
+
import type { PortfolioLedger } from './ledger.js';
|
|
67
|
+
import {
|
|
68
|
+
describeInputValue,
|
|
69
|
+
requireProvenanceShape,
|
|
70
|
+
QUANTITY_DUST,
|
|
71
|
+
deepFreeze,
|
|
72
|
+
hasOwnKey,
|
|
73
|
+
ownValue,
|
|
74
|
+
requireCurrencyCode,
|
|
75
|
+
requireDenseDataArray,
|
|
76
|
+
requireEpochMsField,
|
|
77
|
+
requireFiniteNumberField,
|
|
78
|
+
requireIdentityString,
|
|
79
|
+
requireNoInheritedFields,
|
|
80
|
+
requirePlainDataObject,
|
|
81
|
+
requirePositiveNumberField,
|
|
82
|
+
setOwnValue,
|
|
83
|
+
} from './internal.js';
|
|
84
|
+
|
|
85
|
+
// ---------------------------------------------------------------------------------------------------
|
|
86
|
+
// State contracts
|
|
87
|
+
// ---------------------------------------------------------------------------------------------------
|
|
88
|
+
|
|
89
|
+
/** The decided lot-relief set (agent-native doc, "Initial accounting scope"). */
|
|
90
|
+
export type LotReliefPolicy = 'fifo' | 'lifo' | 'highest-cost' | 'specific-lot';
|
|
91
|
+
|
|
92
|
+
const LOT_RELIEF_POLICIES: readonly LotReliefPolicy[] = [
|
|
93
|
+
'fifo',
|
|
94
|
+
'lifo',
|
|
95
|
+
'highest-cost',
|
|
96
|
+
'specific-lot',
|
|
97
|
+
];
|
|
98
|
+
|
|
99
|
+
/** One dated cash leg: `amount` (signed) becomes settled once `asOf ≥ settleTimestampMs`. */
|
|
100
|
+
export interface ScheduledSettlement {
|
|
101
|
+
/** The envelope `eventId` that booked this leg. */
|
|
102
|
+
eventId: string;
|
|
103
|
+
/** Signed cash effect: positive = incoming (receivable until settled), negative = payable. */
|
|
104
|
+
amount: number;
|
|
105
|
+
settleTimestampMs: EpochMs;
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/** One currency's cash: the booked total plus the settlement schedule of its dated legs. */
|
|
109
|
+
export interface CashBalance {
|
|
110
|
+
/** The booked balance including not-yet-settled legs. May be negative (margin/overdraft). */
|
|
111
|
+
totalAmount: number;
|
|
112
|
+
settlementSchedule: ScheduledSettlement[];
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** One tax lot. Long lots have `quantity > 0`; short lots `quantity < 0`. */
|
|
116
|
+
export interface TaxLot {
|
|
117
|
+
/** Deterministic fold identity (`lot-<n>`), stable across replays — addressable by
|
|
118
|
+
* `specific-lot` relief. */
|
|
119
|
+
lotId: string;
|
|
120
|
+
openedByEventId: string;
|
|
121
|
+
openedTimestampMs: EpochMs;
|
|
122
|
+
/** Signed remaining quantity; fractional supported. */
|
|
123
|
+
quantity: number;
|
|
124
|
+
/** For long lots: acquisition price per unit. For short lots: opening proceeds per unit. */
|
|
125
|
+
costBasisPerUnit: number;
|
|
126
|
+
}
|
|
127
|
+
|
|
128
|
+
/** One instrument's open position in one account. */
|
|
129
|
+
export interface PositionState {
|
|
130
|
+
instrumentId: string;
|
|
131
|
+
/** The ONE trading currency of this position's fills (mixed currencies refuse). */
|
|
132
|
+
currency: string;
|
|
133
|
+
/** Units of the underlying per unit of `quantity` (slice 5): 1 for shares, an option's 100, a futures contract size. */
|
|
134
|
+
contractMultiplier: number;
|
|
135
|
+
/** `'cash-on-trade'` (equities, options, spot) or `'variation-margin'` (futures, perpetuals). */
|
|
136
|
+
settlementStyle: SettlementStyle;
|
|
137
|
+
/** The derivative's terms, carried from the opening fill. */
|
|
138
|
+
contract?: DerivativeContractTerms;
|
|
139
|
+
/** Signed net quantity — always the sum of `lots[].quantity`. */
|
|
140
|
+
quantity: number;
|
|
141
|
+
lots: TaxLot[];
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
/** One account's derived facts. Accumulators are keyed by uppercase currency code. */
|
|
145
|
+
export interface AccountState {
|
|
146
|
+
cashBalances: Record<string, CashBalance>;
|
|
147
|
+
positions: Record<string, PositionState>;
|
|
148
|
+
/** Realized P&L from lot relief under the state's `lotRelief` policy, by currency. */
|
|
149
|
+
realizedPnl: Record<string, number>;
|
|
150
|
+
/** Income received (dividends, coupons, interest, staking, funding receipts), by currency. */
|
|
151
|
+
incomeReceived: Record<string, number>;
|
|
152
|
+
/** Transaction costs charged (commissions, fees, slippage adjustments), by currency. */
|
|
153
|
+
transactionCosts: Record<string, number>;
|
|
154
|
+
/** Financing charged (margin interest, borrow, funding payments), by currency. */
|
|
155
|
+
financingCosts: Record<string, number>;
|
|
156
|
+
/**
|
|
157
|
+
* Per-instrument attribution of the realized, income, and cost accumulators (slice 2,
|
|
158
|
+
* 2026-08-28): `instrumentId → currency → amount`. Realized P&L always carries the instrument;
|
|
159
|
+
* income and costs carry it only when the event named one (unattributed amounts stay in the
|
|
160
|
+
* account-level totals above and are reported as such by `portfolioPnl`). These survive a
|
|
161
|
+
* position closing — `positions` drops a flat instrument, its history does not disappear.
|
|
162
|
+
*/
|
|
163
|
+
realizedPnlByInstrument: Record<string, Record<string, number>>;
|
|
164
|
+
incomeByInstrument: Record<string, Record<string, number>>;
|
|
165
|
+
transactionCostsByInstrument: Record<string, Record<string, number>>;
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
/**
|
|
169
|
+
* 2 (2026-08-28, FC7 slice 2): accounts gained the per-instrument attribution maps.
|
|
170
|
+
* 3 (2026-08-28, FC7 slice 3): the fold records per-fill effects (for exact reversal), the
|
|
171
|
+
* reversal links, and account-migration markers.
|
|
172
|
+
* 4 (2026-08-29, FC7 slice 5): positions carry their instrument profile (contract multiplier,
|
|
173
|
+
* settlement style, derivative terms) and fill effects record the cash they booked.
|
|
174
|
+
*/
|
|
175
|
+
export const PORTFOLIO_STATE_SCHEMA_VERSION = 4;
|
|
176
|
+
|
|
177
|
+
/** What one applied fill did — the facts an exact reversal needs (slice 3). */
|
|
178
|
+
export interface FillEffect {
|
|
179
|
+
accountId: string;
|
|
180
|
+
instrumentId: string;
|
|
181
|
+
currency: string;
|
|
182
|
+
/** Lot ids this fill OPENED (in order). Empty when the fill only relieved. */
|
|
183
|
+
openedLotIds: string[];
|
|
184
|
+
/** Quantity this fill relieved from prior lots — non-zero means the fill is not exactly reversible. */
|
|
185
|
+
relievedQuantity: number;
|
|
186
|
+
realizedPnl: number;
|
|
187
|
+
/** The signed cash the fill booked (price × quantity × multiplier, or the realized variation-margin P&L), incl. accrued interest. */
|
|
188
|
+
cashDelta: number;
|
|
189
|
+
/** Signed accrued interest exchanged (negative = paid on a buy), booked as income. */
|
|
190
|
+
accruedInterest: number;
|
|
191
|
+
}
|
|
192
|
+
|
|
193
|
+
/** An account-migration marker as folded (slice 3): the fact IS the marker; no economic effect. */
|
|
194
|
+
export interface AccountMigrationMarker {
|
|
195
|
+
eventId: string;
|
|
196
|
+
fromAccountId: string;
|
|
197
|
+
toAccountId: string;
|
|
198
|
+
effectiveTimestampMs: EpochMs;
|
|
199
|
+
}
|
|
200
|
+
|
|
201
|
+
/**
|
|
202
|
+
* The derived portfolio state: a JSON-safe, deeply frozen fold result. The economic policy that
|
|
203
|
+
* shaped it (`baseCurrency`, `lotRelief`) is echoed ON the state, and the applied-event registry
|
|
204
|
+
* makes replay idempotent and conflict-detecting.
|
|
205
|
+
*/
|
|
206
|
+
export interface PortfolioState {
|
|
207
|
+
schemaVersion: number;
|
|
208
|
+
portfolioId?: string;
|
|
209
|
+
baseCurrency: string;
|
|
210
|
+
/** The lot-relief policy every realized figure in this state was computed under. */
|
|
211
|
+
lotRelief: LotReliefPolicy;
|
|
212
|
+
accounts: Record<string, AccountState>;
|
|
213
|
+
/** `(sourceId, eventId)` → event content hash — the duplicate/conflict boundary. */
|
|
214
|
+
appliedEvents: Record<string, string>;
|
|
215
|
+
eventCount: number;
|
|
216
|
+
lastEffectiveTimestampMs: EpochMs | null;
|
|
217
|
+
/** Fold-deterministic lot-id counter (`lot-<n>`). */
|
|
218
|
+
lotSequence: number;
|
|
219
|
+
/** Registry key of every applied `trade.fill` → what it did (slice 3; exact reversal needs it). */
|
|
220
|
+
fillEffects: Record<string, FillEffect>;
|
|
221
|
+
/** Registry key of every reversed fact → registry key of the admin event that reversed it. */
|
|
222
|
+
reversals: Record<string, string>;
|
|
223
|
+
/** Account-migration markers in fold order. */
|
|
224
|
+
accountMigrations: AccountMigrationMarker[];
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
/** The fresh-ledger definition accepted by {@link applyPortfolioEvents} and the ledger artifact. */
|
|
228
|
+
export interface PortfolioDefinition {
|
|
229
|
+
portfolioId?: string;
|
|
230
|
+
baseCurrency: string;
|
|
231
|
+
/** Defaults to `'fifo'` (documented; echoed on the state and every ledger envelope). */
|
|
232
|
+
lotRelief?: LotReliefPolicy;
|
|
233
|
+
}
|
|
234
|
+
|
|
235
|
+
/** Input for {@link applyPortfolioEvents}: exactly ONE of `portfolio` (fresh) or `previousState`. */
|
|
236
|
+
export interface ApplyPortfolioEventsInput {
|
|
237
|
+
portfolio?: PortfolioDefinition;
|
|
238
|
+
previousState?: PortfolioState;
|
|
239
|
+
events: readonly PortfolioEventEnvelope[];
|
|
240
|
+
}
|
|
241
|
+
|
|
242
|
+
// ---------------------------------------------------------------------------------------------------
|
|
243
|
+
// Input validation
|
|
244
|
+
// ---------------------------------------------------------------------------------------------------
|
|
245
|
+
|
|
246
|
+
const APPLY_KEYS = ['portfolio', 'previousState', 'events'] as const;
|
|
247
|
+
const DEFINITION_KEYS = ['portfolioId', 'baseCurrency', 'lotRelief'] as const;
|
|
248
|
+
const STATE_KEYS = [
|
|
249
|
+
'schemaVersion',
|
|
250
|
+
'portfolioId',
|
|
251
|
+
'baseCurrency',
|
|
252
|
+
'lotRelief',
|
|
253
|
+
'accounts',
|
|
254
|
+
'appliedEvents',
|
|
255
|
+
'eventCount',
|
|
256
|
+
'lastEffectiveTimestampMs',
|
|
257
|
+
'lotSequence',
|
|
258
|
+
'fillEffects',
|
|
259
|
+
'reversals',
|
|
260
|
+
'accountMigrations',
|
|
261
|
+
] as const;
|
|
262
|
+
const REQUIRED_STATE_KEYS = STATE_KEYS.filter((key) => key !== 'portfolioId');
|
|
263
|
+
const ACCOUNT_KEYS = [
|
|
264
|
+
'cashBalances',
|
|
265
|
+
'positions',
|
|
266
|
+
'realizedPnl',
|
|
267
|
+
'incomeReceived',
|
|
268
|
+
'transactionCosts',
|
|
269
|
+
'financingCosts',
|
|
270
|
+
'realizedPnlByInstrument',
|
|
271
|
+
'incomeByInstrument',
|
|
272
|
+
'transactionCostsByInstrument',
|
|
273
|
+
] as const;
|
|
274
|
+
const CASH_BALANCE_KEYS = ['totalAmount', 'settlementSchedule'] as const;
|
|
275
|
+
const SETTLEMENT_KEYS = ['eventId', 'amount', 'settleTimestampMs'] as const;
|
|
276
|
+
const POSITION_KEYS = [
|
|
277
|
+
'instrumentId',
|
|
278
|
+
'currency',
|
|
279
|
+
'contractMultiplier',
|
|
280
|
+
'settlementStyle',
|
|
281
|
+
'contract',
|
|
282
|
+
'quantity',
|
|
283
|
+
'lots',
|
|
284
|
+
] as const;
|
|
285
|
+
const REQUIRED_POSITION_KEYS = POSITION_KEYS.filter((key) => key !== 'contract');
|
|
286
|
+
const LOT_KEYS = [
|
|
287
|
+
'lotId',
|
|
288
|
+
'openedByEventId',
|
|
289
|
+
'openedTimestampMs',
|
|
290
|
+
'quantity',
|
|
291
|
+
'costBasisPerUnit',
|
|
292
|
+
] as const;
|
|
293
|
+
const FILL_EFFECT_KEYS = [
|
|
294
|
+
'accountId',
|
|
295
|
+
'instrumentId',
|
|
296
|
+
'currency',
|
|
297
|
+
'openedLotIds',
|
|
298
|
+
'relievedQuantity',
|
|
299
|
+
'realizedPnl',
|
|
300
|
+
'cashDelta',
|
|
301
|
+
'accruedInterest',
|
|
302
|
+
] as const;
|
|
303
|
+
const ACCOUNT_MIGRATION_KEYS = [
|
|
304
|
+
'eventId',
|
|
305
|
+
'fromAccountId',
|
|
306
|
+
'toAccountId',
|
|
307
|
+
'effectiveTimestampMs',
|
|
308
|
+
] as const;
|
|
309
|
+
|
|
310
|
+
const EXAMPLE_APPLY =
|
|
311
|
+
"applyPortfolioEvents({ portfolio: { baseCurrency: 'USD' }, events }) — or continue a fold with " +
|
|
312
|
+
'applyPortfolioEvents({ previousState, events })';
|
|
313
|
+
|
|
314
|
+
function validateDefinition(functionName: string, definition: PortfolioDefinition): void {
|
|
315
|
+
requirePlainDataObject(functionName, 'portfolio', definition);
|
|
316
|
+
requireNoInheritedFields(functionName, 'portfolio', definition, DEFINITION_KEYS);
|
|
317
|
+
ensureKnownKeys(functionName, 'portfolio', definition, DEFINITION_KEYS);
|
|
318
|
+
if (definition.portfolioId !== undefined) {
|
|
319
|
+
requireIdentityString(functionName, 'portfolio.portfolioId', definition.portfolioId);
|
|
320
|
+
}
|
|
321
|
+
requireCurrencyCode(functionName, 'portfolio.baseCurrency', definition.baseCurrency);
|
|
322
|
+
if (
|
|
323
|
+
definition.lotRelief !== undefined &&
|
|
324
|
+
!(LOT_RELIEF_POLICIES as readonly string[]).includes(definition.lotRelief)
|
|
325
|
+
) {
|
|
326
|
+
throw new InputError(
|
|
327
|
+
`${functionName}: portfolio.lotRelief must be one of ${LOT_RELIEF_POLICIES.map((p) => `'${p}'`).join(' | ')} (omitted = 'fifo', echoed on the state). Received ${describeInputValue(definition.lotRelief)}.`,
|
|
328
|
+
{
|
|
329
|
+
code: ErrorCode.InputInvalidEnum,
|
|
330
|
+
context: { function: functionName, field: 'portfolio.lotRelief' },
|
|
331
|
+
},
|
|
332
|
+
);
|
|
333
|
+
}
|
|
334
|
+
}
|
|
335
|
+
|
|
336
|
+
function requireJsonRecord(
|
|
337
|
+
functionName: string,
|
|
338
|
+
label: string,
|
|
339
|
+
value: unknown,
|
|
340
|
+
): asserts value is Record<string, unknown> {
|
|
341
|
+
requireArgumentObject(functionName, label, value);
|
|
342
|
+
const record = value as object;
|
|
343
|
+
const prototype = Object.getPrototypeOf(record);
|
|
344
|
+
if (prototype !== Object.prototype && prototype !== null) {
|
|
345
|
+
throw new InputError(
|
|
346
|
+
`${functionName}: ${label} must be a plain JSON object, not a class instance or an object with a custom prototype. Serialize and parse the state before restoring it.`,
|
|
347
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field: label } },
|
|
348
|
+
);
|
|
349
|
+
}
|
|
350
|
+
for (const key of Reflect.ownKeys(record)) {
|
|
351
|
+
if (typeof key !== 'string') {
|
|
352
|
+
throw new InputError(
|
|
353
|
+
`${functionName}: ${label} must contain only string-keyed JSON data; symbol key ${String(key)} cannot survive serialization.`,
|
|
354
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field: label } },
|
|
355
|
+
);
|
|
356
|
+
}
|
|
357
|
+
const descriptor = Object.getOwnPropertyDescriptor(record, key);
|
|
358
|
+
if (descriptor !== undefined && (!descriptor.enumerable || !('value' in descriptor))) {
|
|
359
|
+
throw new InputError(
|
|
360
|
+
`${functionName}: ${label}[${JSON.stringify(key)}] must be enumerable stored JSON data, not an accessor or hidden property. Restore the serialized state rather than a live object with getters, setters, or non-JSON metadata.`,
|
|
361
|
+
{
|
|
362
|
+
code: ErrorCode.InputWrongType,
|
|
363
|
+
context: { function: functionName, field: `${label}[${JSON.stringify(key)}]` },
|
|
364
|
+
},
|
|
365
|
+
);
|
|
366
|
+
}
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
|
|
370
|
+
function requireOwnFields(
|
|
371
|
+
functionName: string,
|
|
372
|
+
label: string,
|
|
373
|
+
record: object,
|
|
374
|
+
fields: readonly string[],
|
|
375
|
+
): void {
|
|
376
|
+
for (const field of fields) {
|
|
377
|
+
if (hasOwnKey(record, field)) continue;
|
|
378
|
+
throw new InputError(
|
|
379
|
+
`${functionName}: ${label}.${field} is required in a restored portfolio state — the state must be the complete JSON value returned by TotalFinance, not a partial projection.`,
|
|
380
|
+
{
|
|
381
|
+
code: ErrorCode.InputMissingField,
|
|
382
|
+
context: { function: functionName, field: `${label}.${field}` },
|
|
383
|
+
},
|
|
384
|
+
);
|
|
385
|
+
}
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
function requireDenseArray(functionName: string, label: string, value: unknown): unknown[] {
|
|
389
|
+
requireArgumentArray(functionName, label, value);
|
|
390
|
+
const array = value as unknown[];
|
|
391
|
+
if (Object.getPrototypeOf(array) !== Array.prototype) {
|
|
392
|
+
throw new InputError(
|
|
393
|
+
`${functionName}: ${label} must be a plain JSON array, not an Array subclass or an array with a custom prototype. Serialize and parse the state before restoring it.`,
|
|
394
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field: label } },
|
|
395
|
+
);
|
|
396
|
+
}
|
|
397
|
+
for (const key of Reflect.ownKeys(array)) {
|
|
398
|
+
if (key === 'length') continue;
|
|
399
|
+
const index = typeof key === 'string' && /^(0|[1-9][0-9]*)$/.test(key) ? Number(key) : -1;
|
|
400
|
+
const descriptor = Object.getOwnPropertyDescriptor(array, key);
|
|
401
|
+
if (
|
|
402
|
+
typeof key !== 'string' ||
|
|
403
|
+
!Number.isSafeInteger(index) ||
|
|
404
|
+
index < 0 ||
|
|
405
|
+
index >= array.length ||
|
|
406
|
+
descriptor === undefined ||
|
|
407
|
+
!descriptor.enumerable ||
|
|
408
|
+
!('value' in descriptor)
|
|
409
|
+
) {
|
|
410
|
+
throw new InputError(
|
|
411
|
+
`${functionName}: ${label} must contain only dense enumerable JSON array elements; ${String(key)} is an accessor, hidden member, symbol, or non-index property.`,
|
|
412
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field: label } },
|
|
413
|
+
);
|
|
414
|
+
}
|
|
415
|
+
}
|
|
416
|
+
for (let index = 0; index < array.length; index += 1) {
|
|
417
|
+
if (hasOwnKey(array, index)) continue;
|
|
418
|
+
throw new InputError(
|
|
419
|
+
`${functionName}: ${label} must be a dense JSON array; index ${index} is missing.`,
|
|
420
|
+
{
|
|
421
|
+
code: ErrorCode.InputWrongType,
|
|
422
|
+
context: { function: functionName, field: `${label}[${index}]` },
|
|
423
|
+
},
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
return array;
|
|
427
|
+
}
|
|
428
|
+
|
|
429
|
+
function requireNonNegativeSafeInteger(
|
|
430
|
+
functionName: string,
|
|
431
|
+
field: string,
|
|
432
|
+
value: unknown,
|
|
433
|
+
): asserts value is number {
|
|
434
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 0) {
|
|
435
|
+
throw new InputError(
|
|
436
|
+
`${functionName}: ${field} must be a non-negative safe integer (at most 2^53 − 1). Received ${describeInputValue(value)}.`,
|
|
437
|
+
{ code: ErrorCode.InputOutOfRange, context: { function: functionName, field } },
|
|
438
|
+
);
|
|
439
|
+
}
|
|
440
|
+
}
|
|
441
|
+
|
|
442
|
+
function dictionaryMember(label: string, key: string): string {
|
|
443
|
+
return `${label}[${JSON.stringify(key)}]`;
|
|
444
|
+
}
|
|
445
|
+
|
|
446
|
+
function requireRegistryKey(functionName: string, field: string, value: string): void {
|
|
447
|
+
let parsed: unknown;
|
|
448
|
+
try {
|
|
449
|
+
parsed = JSON.parse(value) as unknown;
|
|
450
|
+
} catch {
|
|
451
|
+
throw new InputError(
|
|
452
|
+
`${functionName}: ${field} must be the canonical [sourceId, eventId] registry key produced by duplicateBoundaryKey. Received ${JSON.stringify(value)}.`,
|
|
453
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field } },
|
|
454
|
+
);
|
|
455
|
+
}
|
|
456
|
+
if (
|
|
457
|
+
!Array.isArray(parsed) ||
|
|
458
|
+
parsed.length !== 2 ||
|
|
459
|
+
typeof parsed[0] !== 'string' ||
|
|
460
|
+
parsed[0].length === 0 ||
|
|
461
|
+
typeof parsed[1] !== 'string' ||
|
|
462
|
+
parsed[1].length === 0 ||
|
|
463
|
+
canonicalJsonOf(parsed) !== value
|
|
464
|
+
) {
|
|
465
|
+
throw new InputError(
|
|
466
|
+
`${functionName}: ${field} must be the canonical [sourceId, eventId] registry key produced by duplicateBoundaryKey. Received ${JSON.stringify(value)}.`,
|
|
467
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field } },
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
|
|
472
|
+
function requireCurrencyAmounts(functionName: string, label: string, value: unknown): void {
|
|
473
|
+
requireJsonRecord(functionName, label, value);
|
|
474
|
+
for (const [currency, amount] of Object.entries(value)) {
|
|
475
|
+
const field = dictionaryMember(label, currency);
|
|
476
|
+
requireCurrencyCode(functionName, `${field} (currency key)`, currency);
|
|
477
|
+
requireFiniteNumberField(functionName, field, amount);
|
|
478
|
+
}
|
|
479
|
+
}
|
|
480
|
+
|
|
481
|
+
function requireInstrumentAmounts(functionName: string, label: string, value: unknown): void {
|
|
482
|
+
requireJsonRecord(functionName, label, value);
|
|
483
|
+
for (const [instrumentId, amounts] of Object.entries(value)) {
|
|
484
|
+
const field = dictionaryMember(label, instrumentId);
|
|
485
|
+
requireIdentityString(functionName, `${field} (instrument key)`, instrumentId);
|
|
486
|
+
requireCurrencyAmounts(functionName, field, amounts);
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
|
|
490
|
+
function requireContractTermsShape(functionName: string, label: string, value: unknown): string {
|
|
491
|
+
requireJsonRecord(functionName, label, value);
|
|
492
|
+
const kind = ownValue(value, 'kind');
|
|
493
|
+
if (kind !== 'option' && kind !== 'future' && kind !== 'perpetual') {
|
|
494
|
+
throw new InputError(
|
|
495
|
+
`${functionName}: ${label}.kind must be 'option' | 'future' | 'perpetual'. Received ${describeInputValue(kind)}.`,
|
|
496
|
+
{
|
|
497
|
+
code: ErrorCode.InputInvalidEnum,
|
|
498
|
+
context: { function: functionName, field: `${label}.kind` },
|
|
499
|
+
},
|
|
500
|
+
);
|
|
501
|
+
}
|
|
502
|
+
const commonKeys = ['kind', 'underlyingInstrumentId'] as const;
|
|
503
|
+
const keys =
|
|
504
|
+
kind === 'option'
|
|
505
|
+
? [...commonKeys, 'type', 'strikePricePerUnit', 'expiryTimestampMs']
|
|
506
|
+
: kind === 'future'
|
|
507
|
+
? [...commonKeys, 'expiryTimestampMs']
|
|
508
|
+
: commonKeys;
|
|
509
|
+
ensureKnownKeys(functionName, label, value, keys);
|
|
510
|
+
requireOwnFields(functionName, label, value, keys);
|
|
511
|
+
requireIdentityString(
|
|
512
|
+
functionName,
|
|
513
|
+
`${label}.underlyingInstrumentId`,
|
|
514
|
+
ownValue(value, 'underlyingInstrumentId'),
|
|
515
|
+
);
|
|
516
|
+
if (kind === 'option') {
|
|
517
|
+
const optionType = ownValue(value, 'type');
|
|
518
|
+
if (optionType !== 'call' && optionType !== 'put') {
|
|
519
|
+
throw new InputError(
|
|
520
|
+
`${functionName}: ${label}.type must be 'call' | 'put'. Received ${describeInputValue(optionType)}.`,
|
|
521
|
+
{
|
|
522
|
+
code: ErrorCode.InputInvalidEnum,
|
|
523
|
+
context: { function: functionName, field: `${label}.type` },
|
|
524
|
+
},
|
|
525
|
+
);
|
|
526
|
+
}
|
|
527
|
+
requireFiniteNumberField(
|
|
528
|
+
functionName,
|
|
529
|
+
`${label}.strikePricePerUnit`,
|
|
530
|
+
ownValue(value, 'strikePricePerUnit'),
|
|
531
|
+
);
|
|
532
|
+
requireEpochMsField(
|
|
533
|
+
functionName,
|
|
534
|
+
`${label}.expiryTimestampMs`,
|
|
535
|
+
ownValue(value, 'expiryTimestampMs'),
|
|
536
|
+
);
|
|
537
|
+
} else if (kind === 'future') {
|
|
538
|
+
requireEpochMsField(
|
|
539
|
+
functionName,
|
|
540
|
+
`${label}.expiryTimestampMs`,
|
|
541
|
+
ownValue(value, 'expiryTimestampMs'),
|
|
542
|
+
);
|
|
543
|
+
}
|
|
544
|
+
return kind;
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
interface StateAudit {
|
|
548
|
+
readonly lotIds: Set<string>;
|
|
549
|
+
readonly effectLotIds: Set<string>;
|
|
550
|
+
readonly lastEffectiveTimestampMs: EpochMs | null;
|
|
551
|
+
maximumLotSequence: number;
|
|
552
|
+
}
|
|
553
|
+
|
|
554
|
+
function requireLotIdentity(
|
|
555
|
+
functionName: string,
|
|
556
|
+
field: string,
|
|
557
|
+
value: unknown,
|
|
558
|
+
): { lotId: string; sequence: number } {
|
|
559
|
+
requireIdentityString(functionName, field, value);
|
|
560
|
+
const match = /^lot-([1-9][0-9]*)$/.exec(value);
|
|
561
|
+
const sequence = match === null ? Number.NaN : Number(match[1]);
|
|
562
|
+
if (match === null || !Number.isSafeInteger(sequence)) {
|
|
563
|
+
throw new InputError(
|
|
564
|
+
`${functionName}: ${field} must be the deterministic 'lot-<positive safe integer>' identity produced by the fold. Received ${JSON.stringify(value)}.`,
|
|
565
|
+
{ code: ErrorCode.InputOutOfRange, context: { function: functionName, field } },
|
|
566
|
+
);
|
|
567
|
+
}
|
|
568
|
+
return { lotId: value, sequence };
|
|
569
|
+
}
|
|
570
|
+
|
|
571
|
+
function requirePositionShape(
|
|
572
|
+
functionName: string,
|
|
573
|
+
label: string,
|
|
574
|
+
mapInstrumentId: string,
|
|
575
|
+
value: unknown,
|
|
576
|
+
audit: StateAudit,
|
|
577
|
+
): void {
|
|
578
|
+
requireJsonRecord(functionName, label, value);
|
|
579
|
+
ensureKnownKeys(functionName, label, value, POSITION_KEYS);
|
|
580
|
+
requireOwnFields(functionName, label, value, REQUIRED_POSITION_KEYS);
|
|
581
|
+
const instrumentId = ownValue(value, 'instrumentId');
|
|
582
|
+
requireIdentityString(functionName, `${label}.instrumentId`, instrumentId);
|
|
583
|
+
if (instrumentId !== mapInstrumentId) {
|
|
584
|
+
throw new InputError(
|
|
585
|
+
`${functionName}: ${label}.instrumentId (${JSON.stringify(instrumentId)}) must equal its positions dictionary key (${JSON.stringify(mapInstrumentId)}) — a restored position cannot disagree with its own identity.`,
|
|
586
|
+
{
|
|
587
|
+
code: ErrorCode.InputOutOfRange,
|
|
588
|
+
context: { function: functionName, field: `${label}.instrumentId` },
|
|
589
|
+
},
|
|
590
|
+
);
|
|
591
|
+
}
|
|
592
|
+
requireCurrencyCode(functionName, `${label}.currency`, ownValue(value, 'currency'));
|
|
593
|
+
requirePositiveNumberField(
|
|
594
|
+
functionName,
|
|
595
|
+
`${label}.contractMultiplier`,
|
|
596
|
+
ownValue(value, 'contractMultiplier'),
|
|
597
|
+
'units of the underlying per unit of position quantity',
|
|
598
|
+
);
|
|
599
|
+
const settlementStyle = ownValue(value, 'settlementStyle');
|
|
600
|
+
if (settlementStyle !== 'cash-on-trade' && settlementStyle !== 'variation-margin') {
|
|
601
|
+
throw new InputError(
|
|
602
|
+
`${functionName}: ${label}.settlementStyle must be 'cash-on-trade' | 'variation-margin'. Received ${describeInputValue(settlementStyle)}.`,
|
|
603
|
+
{
|
|
604
|
+
code: ErrorCode.InputInvalidEnum,
|
|
605
|
+
context: { function: functionName, field: `${label}.settlementStyle` },
|
|
606
|
+
},
|
|
607
|
+
);
|
|
608
|
+
}
|
|
609
|
+
const contract = ownValue(value, 'contract');
|
|
610
|
+
if (contract === undefined) {
|
|
611
|
+
if (settlementStyle === 'variation-margin') {
|
|
612
|
+
throw new InputError(
|
|
613
|
+
`${functionName}: ${label}.contract is required for settlementStyle 'variation-margin' — only explicit future or perpetual terms receive variation-margin treatment.`,
|
|
614
|
+
{
|
|
615
|
+
code: ErrorCode.InputMissingField,
|
|
616
|
+
context: { function: functionName, field: `${label}.contract` },
|
|
617
|
+
},
|
|
618
|
+
);
|
|
619
|
+
}
|
|
620
|
+
} else {
|
|
621
|
+
const kind = requireContractTermsShape(functionName, `${label}.contract`, contract);
|
|
622
|
+
const expectedStyle = kind === 'option' ? 'cash-on-trade' : 'variation-margin';
|
|
623
|
+
if (settlementStyle !== expectedStyle) {
|
|
624
|
+
throw new InputError(
|
|
625
|
+
`${functionName}: ${label}.settlementStyle must be '${expectedStyle}' for contract kind '${kind}'. Received ${describeInputValue(settlementStyle)}.`,
|
|
626
|
+
{
|
|
627
|
+
code: ErrorCode.InputOutOfRange,
|
|
628
|
+
context: { function: functionName, field: `${label}.settlementStyle` },
|
|
629
|
+
},
|
|
630
|
+
);
|
|
631
|
+
}
|
|
632
|
+
}
|
|
633
|
+
const quantity = ownValue(value, 'quantity');
|
|
634
|
+
requireFiniteNumberField(functionName, `${label}.quantity`, quantity);
|
|
635
|
+
if (quantity === 0) {
|
|
636
|
+
throw new InputError(
|
|
637
|
+
`${functionName}: ${label}.quantity must be non-zero — flat positions are removed from the state rather than retained as empty dictionary entries.`,
|
|
638
|
+
{
|
|
639
|
+
code: ErrorCode.InputOutOfRange,
|
|
640
|
+
context: { function: functionName, field: `${label}.quantity` },
|
|
641
|
+
},
|
|
642
|
+
);
|
|
643
|
+
}
|
|
644
|
+
const lots = requireDenseArray(functionName, `${label}.lots`, ownValue(value, 'lots'));
|
|
645
|
+
if (lots.length === 0) {
|
|
646
|
+
throw new InputError(
|
|
647
|
+
`${functionName}: ${label}.lots must contain the tax lots whose signed sum is the open position quantity.`,
|
|
648
|
+
{
|
|
649
|
+
code: ErrorCode.InputMissingField,
|
|
650
|
+
context: { function: functionName, field: `${label}.lots` },
|
|
651
|
+
},
|
|
652
|
+
);
|
|
653
|
+
}
|
|
654
|
+
let lotQuantity = 0;
|
|
655
|
+
lots.forEach((candidate, index) => {
|
|
656
|
+
const lotLabel = `${label}.lots[${index}]`;
|
|
657
|
+
requireJsonRecord(functionName, lotLabel, candidate);
|
|
658
|
+
ensureKnownKeys(functionName, lotLabel, candidate, LOT_KEYS);
|
|
659
|
+
requireOwnFields(functionName, lotLabel, candidate, LOT_KEYS);
|
|
660
|
+
const { lotId, sequence } = requireLotIdentity(
|
|
661
|
+
functionName,
|
|
662
|
+
`${lotLabel}.lotId`,
|
|
663
|
+
ownValue(candidate, 'lotId'),
|
|
664
|
+
);
|
|
665
|
+
if (audit.lotIds.has(lotId)) {
|
|
666
|
+
throw new InputError(
|
|
667
|
+
`${functionName}: ${lotLabel}.lotId '${lotId}' is duplicated — an open lot identity belongs to exactly one account/instrument position.`,
|
|
668
|
+
{
|
|
669
|
+
code: ErrorCode.InputOutOfRange,
|
|
670
|
+
context: { function: functionName, field: `${lotLabel}.lotId` },
|
|
671
|
+
},
|
|
672
|
+
);
|
|
673
|
+
}
|
|
674
|
+
audit.lotIds.add(lotId);
|
|
675
|
+
audit.maximumLotSequence = Math.max(audit.maximumLotSequence, sequence);
|
|
676
|
+
requireIdentityString(
|
|
677
|
+
functionName,
|
|
678
|
+
`${lotLabel}.openedByEventId`,
|
|
679
|
+
ownValue(candidate, 'openedByEventId'),
|
|
680
|
+
);
|
|
681
|
+
const openedTimestampMs = ownValue(candidate, 'openedTimestampMs');
|
|
682
|
+
requireEpochMsField(functionName, `${lotLabel}.openedTimestampMs`, openedTimestampMs);
|
|
683
|
+
if (
|
|
684
|
+
audit.lastEffectiveTimestampMs === null ||
|
|
685
|
+
openedTimestampMs > audit.lastEffectiveTimestampMs
|
|
686
|
+
) {
|
|
687
|
+
throw new InputError(
|
|
688
|
+
`${functionName}: ${lotLabel}.openedTimestampMs (${openedTimestampMs}) must be no later than the state's lastEffectiveTimestampMs (${String(audit.lastEffectiveTimestampMs)}) — a restored fold cannot hold a lot opened by a future event.`,
|
|
689
|
+
{
|
|
690
|
+
code: ErrorCode.InputOutOfRange,
|
|
691
|
+
context: { function: functionName, field: `${lotLabel}.openedTimestampMs` },
|
|
692
|
+
},
|
|
693
|
+
);
|
|
694
|
+
}
|
|
695
|
+
const quantityOfLot = ownValue(candidate, 'quantity');
|
|
696
|
+
requireFiniteNumberField(functionName, `${lotLabel}.quantity`, quantityOfLot);
|
|
697
|
+
if (quantityOfLot === 0 || Math.sign(quantityOfLot) !== Math.sign(quantity)) {
|
|
698
|
+
throw new InputError(
|
|
699
|
+
`${functionName}: ${lotLabel}.quantity must be non-zero and have the same sign as ${label}.quantity (${String(quantity)}). Received ${String(quantityOfLot)}.`,
|
|
700
|
+
{
|
|
701
|
+
code: ErrorCode.InputOutOfRange,
|
|
702
|
+
context: { function: functionName, field: `${lotLabel}.quantity` },
|
|
703
|
+
},
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
requireFiniteNumberField(
|
|
707
|
+
functionName,
|
|
708
|
+
`${lotLabel}.costBasisPerUnit`,
|
|
709
|
+
ownValue(candidate, 'costBasisPerUnit'),
|
|
710
|
+
);
|
|
711
|
+
lotQuantity += quantityOfLot;
|
|
712
|
+
});
|
|
713
|
+
const tolerance = QUANTITY_DUST * Math.max(1, Math.abs(quantity), Math.abs(lotQuantity));
|
|
714
|
+
if (!Number.isFinite(lotQuantity) || Math.abs(lotQuantity - quantity) > tolerance) {
|
|
715
|
+
throw new InputError(
|
|
716
|
+
`${functionName}: ${label}.quantity (${String(quantity)}) must equal the signed sum of ${label}.lots (${String(lotQuantity)}).`,
|
|
717
|
+
{
|
|
718
|
+
code: ErrorCode.InputOutOfRange,
|
|
719
|
+
context: { function: functionName, field: `${label}.quantity` },
|
|
720
|
+
},
|
|
721
|
+
);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
|
|
725
|
+
function requireAccountShape(
|
|
726
|
+
functionName: string,
|
|
727
|
+
label: string,
|
|
728
|
+
value: unknown,
|
|
729
|
+
audit: StateAudit,
|
|
730
|
+
): void {
|
|
731
|
+
requireJsonRecord(functionName, label, value);
|
|
732
|
+
ensureKnownKeys(functionName, label, value, ACCOUNT_KEYS);
|
|
733
|
+
requireOwnFields(functionName, label, value, ACCOUNT_KEYS);
|
|
734
|
+
|
|
735
|
+
const cashBalances = ownValue(value, 'cashBalances');
|
|
736
|
+
requireJsonRecord(functionName, `${label}.cashBalances`, cashBalances);
|
|
737
|
+
for (const [currency, candidate] of Object.entries(cashBalances)) {
|
|
738
|
+
const balanceLabel = dictionaryMember(`${label}.cashBalances`, currency);
|
|
739
|
+
requireCurrencyCode(functionName, `${balanceLabel} (currency key)`, currency);
|
|
740
|
+
requireJsonRecord(functionName, balanceLabel, candidate);
|
|
741
|
+
ensureKnownKeys(functionName, balanceLabel, candidate, CASH_BALANCE_KEYS);
|
|
742
|
+
requireOwnFields(functionName, balanceLabel, candidate, CASH_BALANCE_KEYS);
|
|
743
|
+
requireFiniteNumberField(
|
|
744
|
+
functionName,
|
|
745
|
+
`${balanceLabel}.totalAmount`,
|
|
746
|
+
ownValue(candidate, 'totalAmount'),
|
|
747
|
+
);
|
|
748
|
+
const schedule = requireDenseArray(
|
|
749
|
+
functionName,
|
|
750
|
+
`${balanceLabel}.settlementSchedule`,
|
|
751
|
+
ownValue(candidate, 'settlementSchedule'),
|
|
752
|
+
);
|
|
753
|
+
schedule.forEach((leg, index) => {
|
|
754
|
+
const legLabel = `${balanceLabel}.settlementSchedule[${index}]`;
|
|
755
|
+
requireJsonRecord(functionName, legLabel, leg);
|
|
756
|
+
ensureKnownKeys(functionName, legLabel, leg, SETTLEMENT_KEYS);
|
|
757
|
+
requireOwnFields(functionName, legLabel, leg, SETTLEMENT_KEYS);
|
|
758
|
+
requireIdentityString(functionName, `${legLabel}.eventId`, ownValue(leg, 'eventId'));
|
|
759
|
+
const amount = ownValue(leg, 'amount');
|
|
760
|
+
requireFiniteNumberField(functionName, `${legLabel}.amount`, amount);
|
|
761
|
+
if (amount === 0) {
|
|
762
|
+
throw new InputError(
|
|
763
|
+
`${functionName}: ${legLabel}.amount must be non-zero — zero-dollar legs are not economic settlements and are never stored.`,
|
|
764
|
+
{
|
|
765
|
+
code: ErrorCode.InputOutOfRange,
|
|
766
|
+
context: { function: functionName, field: `${legLabel}.amount` },
|
|
767
|
+
},
|
|
768
|
+
);
|
|
769
|
+
}
|
|
770
|
+
requireEpochMsField(
|
|
771
|
+
functionName,
|
|
772
|
+
`${legLabel}.settleTimestampMs`,
|
|
773
|
+
ownValue(leg, 'settleTimestampMs'),
|
|
774
|
+
);
|
|
775
|
+
});
|
|
776
|
+
}
|
|
777
|
+
|
|
778
|
+
const positions = ownValue(value, 'positions');
|
|
779
|
+
requireJsonRecord(functionName, `${label}.positions`, positions);
|
|
780
|
+
for (const [instrumentId, candidate] of Object.entries(positions)) {
|
|
781
|
+
const positionLabel = dictionaryMember(`${label}.positions`, instrumentId);
|
|
782
|
+
requireIdentityString(functionName, `${positionLabel} (instrument key)`, instrumentId);
|
|
783
|
+
requirePositionShape(functionName, positionLabel, instrumentId, candidate, audit);
|
|
784
|
+
}
|
|
785
|
+
requireCurrencyAmounts(functionName, `${label}.realizedPnl`, ownValue(value, 'realizedPnl'));
|
|
786
|
+
requireCurrencyAmounts(
|
|
787
|
+
functionName,
|
|
788
|
+
`${label}.incomeReceived`,
|
|
789
|
+
ownValue(value, 'incomeReceived'),
|
|
790
|
+
);
|
|
791
|
+
requireCurrencyAmounts(
|
|
792
|
+
functionName,
|
|
793
|
+
`${label}.transactionCosts`,
|
|
794
|
+
ownValue(value, 'transactionCosts'),
|
|
795
|
+
);
|
|
796
|
+
requireCurrencyAmounts(
|
|
797
|
+
functionName,
|
|
798
|
+
`${label}.financingCosts`,
|
|
799
|
+
ownValue(value, 'financingCosts'),
|
|
800
|
+
);
|
|
801
|
+
requireInstrumentAmounts(
|
|
802
|
+
functionName,
|
|
803
|
+
`${label}.realizedPnlByInstrument`,
|
|
804
|
+
ownValue(value, 'realizedPnlByInstrument'),
|
|
805
|
+
);
|
|
806
|
+
requireInstrumentAmounts(
|
|
807
|
+
functionName,
|
|
808
|
+
`${label}.incomeByInstrument`,
|
|
809
|
+
ownValue(value, 'incomeByInstrument'),
|
|
810
|
+
);
|
|
811
|
+
requireInstrumentAmounts(
|
|
812
|
+
functionName,
|
|
813
|
+
`${label}.transactionCostsByInstrument`,
|
|
814
|
+
ownValue(value, 'transactionCostsByInstrument'),
|
|
815
|
+
);
|
|
816
|
+
}
|
|
817
|
+
|
|
818
|
+
/**
|
|
819
|
+
* Deep validation of a {@link PortfolioState} handed back across a public boundary
|
|
820
|
+
* (`applyPortfolioEvents`' `previousState`, `portfolioSnapshot`'s `portfolio`). A TypeScript type
|
|
821
|
+
* does not survive storage or network transit, so every nested account, cash leg, position, lot,
|
|
822
|
+
* attribution, effect, reversal, migration, and registry link is re-audited before use.
|
|
823
|
+
* Package-internal (imported by the snapshot module); not part of the curated public surface.
|
|
824
|
+
*/
|
|
825
|
+
export function requirePortfolioStateShape(
|
|
826
|
+
functionName: string,
|
|
827
|
+
label: string,
|
|
828
|
+
state: PortfolioState,
|
|
829
|
+
): void {
|
|
830
|
+
requireJsonRecord(functionName, label, state);
|
|
831
|
+
ensureKnownKeys(functionName, label, state, STATE_KEYS);
|
|
832
|
+
requireOwnFields(functionName, label, state, REQUIRED_STATE_KEYS);
|
|
833
|
+
if (state.schemaVersion !== PORTFOLIO_STATE_SCHEMA_VERSION) {
|
|
834
|
+
const received = describeInputValue(state.schemaVersion);
|
|
835
|
+
throw new InputError(
|
|
836
|
+
`${functionName}: ${label}.schemaVersion must be ${PORTFOLIO_STATE_SCHEMA_VERSION} — a state from another build restores through readPortfolioLedgerSnapshot (which re-folds the events), not by handing an old state back in. Received ${received}.`,
|
|
837
|
+
{
|
|
838
|
+
code: ErrorCode.SnapshotUnsupportedVersion,
|
|
839
|
+
context: { function: functionName, field: `${label}.schemaVersion`, received },
|
|
840
|
+
},
|
|
841
|
+
);
|
|
842
|
+
}
|
|
843
|
+
if (hasOwnKey(state, 'portfolioId')) {
|
|
844
|
+
requireIdentityString(functionName, `${label}.portfolioId`, state.portfolioId);
|
|
845
|
+
}
|
|
846
|
+
requireCurrencyCode(functionName, `${label}.baseCurrency`, state.baseCurrency);
|
|
847
|
+
if (!(LOT_RELIEF_POLICIES as readonly string[]).includes(state.lotRelief)) {
|
|
848
|
+
throw new InputError(
|
|
849
|
+
`${functionName}: ${label}.lotRelief must be one of ${LOT_RELIEF_POLICIES.map((p) => `'${p}'`).join(' | ')}. Received ${describeInputValue(state.lotRelief)}.`,
|
|
850
|
+
{
|
|
851
|
+
code: ErrorCode.InputInvalidEnum,
|
|
852
|
+
context: { function: functionName, field: `${label}.lotRelief` },
|
|
853
|
+
},
|
|
854
|
+
);
|
|
855
|
+
}
|
|
856
|
+
requireNonNegativeSafeInteger(functionName, `${label}.eventCount`, state.eventCount);
|
|
857
|
+
if (
|
|
858
|
+
(state.eventCount === 0 && state.lastEffectiveTimestampMs !== null) ||
|
|
859
|
+
(state.eventCount > 0 && state.lastEffectiveTimestampMs === null)
|
|
860
|
+
) {
|
|
861
|
+
throw new InputError(
|
|
862
|
+
`${functionName}: ${label}.lastEffectiveTimestampMs must be null exactly when eventCount is 0, and an epoch-millisecond timestamp once events exist. Received eventCount ${state.eventCount} and ${describeInputValue(state.lastEffectiveTimestampMs)}.`,
|
|
863
|
+
{
|
|
864
|
+
code: ErrorCode.InputOutOfRange,
|
|
865
|
+
context: { function: functionName, field: `${label}.lastEffectiveTimestampMs` },
|
|
866
|
+
},
|
|
867
|
+
);
|
|
868
|
+
}
|
|
869
|
+
if (state.lastEffectiveTimestampMs !== null) {
|
|
870
|
+
requireEpochMsField(
|
|
871
|
+
functionName,
|
|
872
|
+
`${label}.lastEffectiveTimestampMs`,
|
|
873
|
+
state.lastEffectiveTimestampMs,
|
|
874
|
+
);
|
|
875
|
+
}
|
|
876
|
+
const audit: StateAudit = {
|
|
877
|
+
lotIds: new Set<string>(),
|
|
878
|
+
effectLotIds: new Set<string>(),
|
|
879
|
+
lastEffectiveTimestampMs: state.lastEffectiveTimestampMs,
|
|
880
|
+
maximumLotSequence: 0,
|
|
881
|
+
};
|
|
882
|
+
requireJsonRecord(functionName, `${label}.accounts`, state.accounts);
|
|
883
|
+
for (const [accountId, account] of Object.entries(state.accounts)) {
|
|
884
|
+
const accountLabel = dictionaryMember(`${label}.accounts`, accountId);
|
|
885
|
+
requireIdentityString(functionName, `${accountLabel} (account key)`, accountId);
|
|
886
|
+
requireAccountShape(functionName, accountLabel, account, audit);
|
|
887
|
+
}
|
|
888
|
+
|
|
889
|
+
requireJsonRecord(functionName, `${label}.appliedEvents`, state.appliedEvents);
|
|
890
|
+
const appliedKeys = new Set<string>();
|
|
891
|
+
for (const [key, hash] of Object.entries(state.appliedEvents)) {
|
|
892
|
+
const field = dictionaryMember(`${label}.appliedEvents`, key);
|
|
893
|
+
requireRegistryKey(functionName, `${field} (registry key)`, key);
|
|
894
|
+
if (!isContentHashString(hash)) {
|
|
895
|
+
throw new InputError(
|
|
896
|
+
`${functionName}: ${field} must be a 'sha256:<64 lowercase hex>' event content hash. Received ${describeInputValue(hash)}.`,
|
|
897
|
+
{ code: ErrorCode.InputWrongType, context: { function: functionName, field } },
|
|
898
|
+
);
|
|
899
|
+
}
|
|
900
|
+
appliedKeys.add(key);
|
|
901
|
+
}
|
|
902
|
+
|
|
903
|
+
// Internal consistency (2026-08-28): the count is an ECHO of the applied-event registry, not an
|
|
904
|
+
// independent fact — a restored state whose counter disagrees with its registry was edited by
|
|
905
|
+
// hand or corrupted in transit, and no fold continues from it.
|
|
906
|
+
const registered = Object.keys(state.appliedEvents).length;
|
|
907
|
+
if (state.eventCount !== registered) {
|
|
908
|
+
throw new InputError(
|
|
909
|
+
`${functionName}: ${label}.eventCount (${String(state.eventCount)}) must equal the number of applied events in ${label}.appliedEvents (${registered}) — the count echoes the registry; a state that disagrees with itself is corrupt, not a bigger ledger.`,
|
|
910
|
+
{
|
|
911
|
+
code: ErrorCode.InputOutOfRange,
|
|
912
|
+
context: { function: functionName, field: `${label}.eventCount`, registered },
|
|
913
|
+
},
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
requireNonNegativeSafeInteger(functionName, `${label}.lotSequence`, state.lotSequence);
|
|
917
|
+
|
|
918
|
+
requireJsonRecord(functionName, `${label}.fillEffects`, state.fillEffects);
|
|
919
|
+
for (const [key, candidate] of Object.entries(state.fillEffects)) {
|
|
920
|
+
const effectLabel = dictionaryMember(`${label}.fillEffects`, key);
|
|
921
|
+
requireRegistryKey(functionName, `${effectLabel} (registry key)`, key);
|
|
922
|
+
if (!appliedKeys.has(key)) {
|
|
923
|
+
throw new InputError(
|
|
924
|
+
`${functionName}: ${effectLabel} has no matching appliedEvents entry — an effect cannot outlive the event identity that produced it.`,
|
|
925
|
+
{
|
|
926
|
+
code: ErrorCode.InputOutOfRange,
|
|
927
|
+
context: { function: functionName, field: effectLabel },
|
|
928
|
+
},
|
|
929
|
+
);
|
|
930
|
+
}
|
|
931
|
+
requireJsonRecord(functionName, effectLabel, candidate);
|
|
932
|
+
ensureKnownKeys(functionName, effectLabel, candidate, FILL_EFFECT_KEYS);
|
|
933
|
+
requireOwnFields(functionName, effectLabel, candidate, FILL_EFFECT_KEYS);
|
|
934
|
+
const accountId = ownValue(candidate, 'accountId');
|
|
935
|
+
requireIdentityString(functionName, `${effectLabel}.accountId`, accountId);
|
|
936
|
+
if (ownValue(state.accounts, accountId) === undefined) {
|
|
937
|
+
throw new InputError(
|
|
938
|
+
`${functionName}: ${effectLabel}.accountId names ${JSON.stringify(accountId)}, which is absent from ${label}.accounts.`,
|
|
939
|
+
{
|
|
940
|
+
code: ErrorCode.InputOutOfRange,
|
|
941
|
+
context: { function: functionName, field: `${effectLabel}.accountId` },
|
|
942
|
+
},
|
|
943
|
+
);
|
|
944
|
+
}
|
|
945
|
+
requireIdentityString(
|
|
946
|
+
functionName,
|
|
947
|
+
`${effectLabel}.instrumentId`,
|
|
948
|
+
ownValue(candidate, 'instrumentId'),
|
|
949
|
+
);
|
|
950
|
+
requireCurrencyCode(functionName, `${effectLabel}.currency`, ownValue(candidate, 'currency'));
|
|
951
|
+
const openedLotIds = requireDenseArray(
|
|
952
|
+
functionName,
|
|
953
|
+
`${effectLabel}.openedLotIds`,
|
|
954
|
+
ownValue(candidate, 'openedLotIds'),
|
|
955
|
+
);
|
|
956
|
+
const openedSeen = new Set<string>();
|
|
957
|
+
openedLotIds.forEach((candidateLotId, index) => {
|
|
958
|
+
const openedField = `${effectLabel}.openedLotIds[${index}]`;
|
|
959
|
+
const { lotId, sequence } = requireLotIdentity(functionName, openedField, candidateLotId);
|
|
960
|
+
if (openedSeen.has(lotId)) {
|
|
961
|
+
throw new InputError(
|
|
962
|
+
`${functionName}: ${effectLabel}.openedLotIds repeats '${lotId}' — each opened lot is named once.`,
|
|
963
|
+
{
|
|
964
|
+
code: ErrorCode.InputOutOfRange,
|
|
965
|
+
context: { function: functionName, field: `${effectLabel}.openedLotIds[${index}]` },
|
|
966
|
+
},
|
|
967
|
+
);
|
|
968
|
+
}
|
|
969
|
+
openedSeen.add(lotId);
|
|
970
|
+
if (audit.effectLotIds.has(lotId)) {
|
|
971
|
+
throw new InputError(
|
|
972
|
+
`${functionName}: ${openedField} repeats lot identity '${lotId}' from another fill effect — one deterministic lot is opened by exactly one event.`,
|
|
973
|
+
{
|
|
974
|
+
code: ErrorCode.InputOutOfRange,
|
|
975
|
+
context: { function: functionName, field: openedField },
|
|
976
|
+
},
|
|
977
|
+
);
|
|
978
|
+
}
|
|
979
|
+
audit.effectLotIds.add(lotId);
|
|
980
|
+
audit.maximumLotSequence = Math.max(audit.maximumLotSequence, sequence);
|
|
981
|
+
});
|
|
982
|
+
const relievedQuantity = ownValue(candidate, 'relievedQuantity');
|
|
983
|
+
requireFiniteNumberField(functionName, `${effectLabel}.relievedQuantity`, relievedQuantity);
|
|
984
|
+
if (relievedQuantity < 0) {
|
|
985
|
+
throw new InputError(
|
|
986
|
+
`${functionName}: ${effectLabel}.relievedQuantity is unsigned and must be >= 0. Received ${relievedQuantity}.`,
|
|
987
|
+
{
|
|
988
|
+
code: ErrorCode.InputOutOfRange,
|
|
989
|
+
context: { function: functionName, field: `${effectLabel}.relievedQuantity` },
|
|
990
|
+
},
|
|
991
|
+
);
|
|
992
|
+
}
|
|
993
|
+
for (const field of ['realizedPnl', 'cashDelta', 'accruedInterest'] as const) {
|
|
994
|
+
requireFiniteNumberField(functionName, `${effectLabel}.${field}`, ownValue(candidate, field));
|
|
995
|
+
}
|
|
996
|
+
}
|
|
997
|
+
if (audit.maximumLotSequence > state.lotSequence) {
|
|
998
|
+
throw new InputError(
|
|
999
|
+
`${functionName}: ${label}.lotSequence (${state.lotSequence}) must be at least the largest open or historically recorded lot suffix (${audit.maximumLotSequence}) — the counter never moves backward or reuses a lot identity.`,
|
|
1000
|
+
{
|
|
1001
|
+
code: ErrorCode.InputOutOfRange,
|
|
1002
|
+
context: { function: functionName, field: `${label}.lotSequence` },
|
|
1003
|
+
},
|
|
1004
|
+
);
|
|
1005
|
+
}
|
|
1006
|
+
|
|
1007
|
+
requireJsonRecord(functionName, `${label}.reversals`, state.reversals);
|
|
1008
|
+
const reversalEvents = new Set<string>();
|
|
1009
|
+
for (const [targetKey, reversalKey] of Object.entries(state.reversals)) {
|
|
1010
|
+
const field = dictionaryMember(`${label}.reversals`, targetKey);
|
|
1011
|
+
requireRegistryKey(functionName, `${field} (target registry key)`, targetKey);
|
|
1012
|
+
requireRegistryKey(functionName, field, reversalKey);
|
|
1013
|
+
if (!appliedKeys.has(targetKey) || !appliedKeys.has(reversalKey) || targetKey === reversalKey) {
|
|
1014
|
+
throw new InputError(
|
|
1015
|
+
`${functionName}: ${field} must link two distinct identities that both exist in ${label}.appliedEvents.`,
|
|
1016
|
+
{ code: ErrorCode.InputOutOfRange, context: { function: functionName, field } },
|
|
1017
|
+
);
|
|
1018
|
+
}
|
|
1019
|
+
if (reversalEvents.has(reversalKey)) {
|
|
1020
|
+
throw new InputError(
|
|
1021
|
+
`${functionName}: ${field} reuses reversal identity ${reversalKey} — one admin event reverses exactly one applied fact.`,
|
|
1022
|
+
{ code: ErrorCode.InputOutOfRange, context: { function: functionName, field } },
|
|
1023
|
+
);
|
|
1024
|
+
}
|
|
1025
|
+
reversalEvents.add(reversalKey);
|
|
1026
|
+
}
|
|
1027
|
+
|
|
1028
|
+
const migrations = requireDenseArray(
|
|
1029
|
+
functionName,
|
|
1030
|
+
`${label}.accountMigrations`,
|
|
1031
|
+
state.accountMigrations,
|
|
1032
|
+
);
|
|
1033
|
+
let previousMigrationTimestampMs = Number.NEGATIVE_INFINITY;
|
|
1034
|
+
migrations.forEach((candidate, index) => {
|
|
1035
|
+
const migrationLabel = `${label}.accountMigrations[${index}]`;
|
|
1036
|
+
requireJsonRecord(functionName, migrationLabel, candidate);
|
|
1037
|
+
ensureKnownKeys(functionName, migrationLabel, candidate, ACCOUNT_MIGRATION_KEYS);
|
|
1038
|
+
requireOwnFields(functionName, migrationLabel, candidate, ACCOUNT_MIGRATION_KEYS);
|
|
1039
|
+
requireIdentityString(
|
|
1040
|
+
functionName,
|
|
1041
|
+
`${migrationLabel}.eventId`,
|
|
1042
|
+
ownValue(candidate, 'eventId'),
|
|
1043
|
+
);
|
|
1044
|
+
const fromAccountId = ownValue(candidate, 'fromAccountId');
|
|
1045
|
+
const toAccountId = ownValue(candidate, 'toAccountId');
|
|
1046
|
+
requireIdentityString(functionName, `${migrationLabel}.fromAccountId`, fromAccountId);
|
|
1047
|
+
requireIdentityString(functionName, `${migrationLabel}.toAccountId`, toAccountId);
|
|
1048
|
+
if (fromAccountId === toAccountId) {
|
|
1049
|
+
throw new InputError(
|
|
1050
|
+
`${functionName}: ${migrationLabel} must name two different account identities.`,
|
|
1051
|
+
{
|
|
1052
|
+
code: ErrorCode.InputOutOfRange,
|
|
1053
|
+
context: { function: functionName, field: `${migrationLabel}.toAccountId` },
|
|
1054
|
+
},
|
|
1055
|
+
);
|
|
1056
|
+
}
|
|
1057
|
+
const effectiveTimestampMs = ownValue(candidate, 'effectiveTimestampMs');
|
|
1058
|
+
requireEpochMsField(
|
|
1059
|
+
functionName,
|
|
1060
|
+
`${migrationLabel}.effectiveTimestampMs`,
|
|
1061
|
+
effectiveTimestampMs,
|
|
1062
|
+
);
|
|
1063
|
+
if (
|
|
1064
|
+
state.lastEffectiveTimestampMs === null ||
|
|
1065
|
+
effectiveTimestampMs > state.lastEffectiveTimestampMs ||
|
|
1066
|
+
effectiveTimestampMs < previousMigrationTimestampMs
|
|
1067
|
+
) {
|
|
1068
|
+
throw new InputError(
|
|
1069
|
+
`${functionName}: ${migrationLabel}.effectiveTimestampMs (${effectiveTimestampMs}) must preserve fold order and be no later than the state's lastEffectiveTimestampMs (${String(state.lastEffectiveTimestampMs)}).`,
|
|
1070
|
+
{
|
|
1071
|
+
code: ErrorCode.InputOutOfRange,
|
|
1072
|
+
context: { function: functionName, field: `${migrationLabel}.effectiveTimestampMs` },
|
|
1073
|
+
},
|
|
1074
|
+
);
|
|
1075
|
+
}
|
|
1076
|
+
previousMigrationTimestampMs = effectiveTimestampMs;
|
|
1077
|
+
});
|
|
1078
|
+
}
|
|
1079
|
+
|
|
1080
|
+
// ---------------------------------------------------------------------------------------------------
|
|
1081
|
+
// Fold helpers (operate on the working copy — never on caller data)
|
|
1082
|
+
// ---------------------------------------------------------------------------------------------------
|
|
1083
|
+
|
|
1084
|
+
function applyFill(
|
|
1085
|
+
functionName: string,
|
|
1086
|
+
state: PortfolioState,
|
|
1087
|
+
account: AccountState,
|
|
1088
|
+
envelope: PortfolioEventEnvelope,
|
|
1089
|
+
event: TradeFillEvent,
|
|
1090
|
+
): void {
|
|
1091
|
+
const multiplier = event.contractMultiplier ?? 1;
|
|
1092
|
+
const style: SettlementStyle = event.settlementStyle ?? 'cash-on-trade';
|
|
1093
|
+
const profile: PositionProfile = {
|
|
1094
|
+
currency: event.currency,
|
|
1095
|
+
contractMultiplier: multiplier,
|
|
1096
|
+
settlementStyle: style,
|
|
1097
|
+
};
|
|
1098
|
+
if (event.contract !== undefined) profile.contract = event.contract;
|
|
1099
|
+
const position = ensurePosition(
|
|
1100
|
+
functionName,
|
|
1101
|
+
account,
|
|
1102
|
+
envelope,
|
|
1103
|
+
event.instrumentId,
|
|
1104
|
+
profile,
|
|
1105
|
+
'event',
|
|
1106
|
+
);
|
|
1107
|
+
|
|
1108
|
+
const opposing =
|
|
1109
|
+
(event.side === 'buy' && position.quantity < 0) ||
|
|
1110
|
+
(event.side === 'sell' && position.quantity > 0);
|
|
1111
|
+
const closingQuantity = opposing ? Math.min(event.quantity, Math.abs(position.quantity)) : 0;
|
|
1112
|
+
|
|
1113
|
+
if (event.lotSelections !== undefined && state.lotRelief !== 'specific-lot') {
|
|
1114
|
+
throw new InputError(
|
|
1115
|
+
`${functionName}: trade.fill event '${envelope.eventId}' carries lotSelections, but this ledger's lotRelief is '${state.lotRelief}' — the selections would be silently ignored. Remove them, or fold under lotRelief: 'specific-lot'.`,
|
|
1116
|
+
{
|
|
1117
|
+
code: ErrorCode.InputOutOfRange,
|
|
1118
|
+
context: {
|
|
1119
|
+
function: functionName,
|
|
1120
|
+
field: 'event.lotSelections',
|
|
1121
|
+
eventId: envelope.eventId,
|
|
1122
|
+
},
|
|
1123
|
+
},
|
|
1124
|
+
);
|
|
1125
|
+
}
|
|
1126
|
+
|
|
1127
|
+
if (closingQuantity <= QUANTITY_DUST && event.lotSelections !== undefined) {
|
|
1128
|
+
throw new InputError(
|
|
1129
|
+
`${functionName}: trade.fill event '${envelope.eventId}' opens a new ${event.side === 'buy' ? 'long' : 'short'} position in ${event.instrumentId} — nothing is relieved, so lotSelections has no meaning here and would be silently ignored. Remove it.`,
|
|
1130
|
+
{
|
|
1131
|
+
code: ErrorCode.InputOutOfRange,
|
|
1132
|
+
context: {
|
|
1133
|
+
function: functionName,
|
|
1134
|
+
field: 'event.lotSelections',
|
|
1135
|
+
eventId: envelope.eventId,
|
|
1136
|
+
},
|
|
1137
|
+
},
|
|
1138
|
+
);
|
|
1139
|
+
}
|
|
1140
|
+
const leg = foldPositionLeg(
|
|
1141
|
+
functionName,
|
|
1142
|
+
state,
|
|
1143
|
+
account,
|
|
1144
|
+
envelope,
|
|
1145
|
+
position,
|
|
1146
|
+
event.side,
|
|
1147
|
+
event.quantity,
|
|
1148
|
+
event.pricePerUnit,
|
|
1149
|
+
event.lotSelections,
|
|
1150
|
+
'event.lotSelections',
|
|
1151
|
+
undefined,
|
|
1152
|
+
);
|
|
1153
|
+
const realized = leg.realizedPnl;
|
|
1154
|
+
const openedLotIds = leg.openedLotIds;
|
|
1155
|
+
|
|
1156
|
+
// Cash: price × quantity × multiplier at the fill for cash-on-trade positions; for
|
|
1157
|
+
// variation-margin positions nothing at the open and the realized difference on a close.
|
|
1158
|
+
// Accrued interest travels with the fill as an income adjustment, never into the lot basis.
|
|
1159
|
+
const signedQuantity = event.side === 'buy' ? event.quantity : -event.quantity;
|
|
1160
|
+
const accruedSigned =
|
|
1161
|
+
event.side === 'buy' ? -(event.accruedInterest ?? 0) : (event.accruedInterest ?? 0);
|
|
1162
|
+
const cashDelta =
|
|
1163
|
+
(style === 'cash-on-trade' ? -signedQuantity * event.pricePerUnit * multiplier : realized) +
|
|
1164
|
+
accruedSigned;
|
|
1165
|
+
// A variation-margin opening fill has no cash leg. In particular, a supplied settlement date
|
|
1166
|
+
// must not manufacture a zero-dollar schedule entry or an otherwise empty cash balance.
|
|
1167
|
+
if (cashDelta !== 0) {
|
|
1168
|
+
bookCash(account, event.currency, cashDelta, envelope.eventId, event.settleTimestampMs);
|
|
1169
|
+
}
|
|
1170
|
+
recordIncome(account, event.instrumentId, event.currency, accruedSigned);
|
|
1171
|
+
|
|
1172
|
+
// What this fill did, keyed by its registry identity — the facts an exact reversal needs.
|
|
1173
|
+
setOwnValue(state.fillEffects, duplicateBoundaryKey(envelope), {
|
|
1174
|
+
accountId: envelope.accountId,
|
|
1175
|
+
instrumentId: event.instrumentId,
|
|
1176
|
+
currency: event.currency,
|
|
1177
|
+
openedLotIds,
|
|
1178
|
+
relievedQuantity: closingQuantity,
|
|
1179
|
+
realizedPnl: realized,
|
|
1180
|
+
cashDelta,
|
|
1181
|
+
accruedInterest: accruedSigned,
|
|
1182
|
+
});
|
|
1183
|
+
}
|
|
1184
|
+
|
|
1185
|
+
function applySplit(
|
|
1186
|
+
functionName: string,
|
|
1187
|
+
account: AccountState,
|
|
1188
|
+
envelope: PortfolioEventEnvelope,
|
|
1189
|
+
event: StockSplitEvent,
|
|
1190
|
+
): void {
|
|
1191
|
+
const position = ownValue(account.positions, event.instrumentId);
|
|
1192
|
+
if (position === undefined) {
|
|
1193
|
+
throw new InputError(
|
|
1194
|
+
`${functionName}: corporate.split event '${envelope.eventId}' names ${event.instrumentId}, but account '${envelope.accountId}' holds no open position in it — a split transforms held lots, so record the position's fills first or drop the event for this account.`,
|
|
1195
|
+
{
|
|
1196
|
+
code: ErrorCode.InputOutOfRange,
|
|
1197
|
+
context: { function: functionName, field: 'event.instrumentId', eventId: envelope.eventId },
|
|
1198
|
+
},
|
|
1199
|
+
);
|
|
1200
|
+
}
|
|
1201
|
+
const ratio = event.sharesAfterSplit / event.sharesBeforeSplit;
|
|
1202
|
+
for (const lot of position.lots) {
|
|
1203
|
+
lot.quantity *= ratio;
|
|
1204
|
+
lot.costBasisPerUnit /= ratio;
|
|
1205
|
+
}
|
|
1206
|
+
position.quantity = position.lots.reduce((sum, lot) => sum + lot.quantity, 0);
|
|
1207
|
+
}
|
|
1208
|
+
|
|
1209
|
+
/**
|
|
1210
|
+
* Reverse an applied fact EXACTLY (slice 3). The registry proves the `original` is what was
|
|
1211
|
+
* applied (content hash), the reversal link is recorded, and each family's inverse is applied —
|
|
1212
|
+
* or refused with the reason when no exact inverse exists (a fill whose lots were relieved, a
|
|
1213
|
+
* split, an already-reversed fact).
|
|
1214
|
+
*/
|
|
1215
|
+
/**
|
|
1216
|
+
* Undo the economic effect of one applied envelope (`applied`) whose facts were recorded under
|
|
1217
|
+
* registry `key` — the per-family exact inverse, or a refusal naming why none exists.
|
|
1218
|
+
*/
|
|
1219
|
+
function reverseEffect(
|
|
1220
|
+
functionName: string,
|
|
1221
|
+
state: PortfolioState,
|
|
1222
|
+
envelope: PortfolioEventEnvelope,
|
|
1223
|
+
applied: PortfolioEventEnvelope,
|
|
1224
|
+
key: string,
|
|
1225
|
+
): void {
|
|
1226
|
+
const account = ownValue(state.accounts, applied.accountId);
|
|
1227
|
+
if (account === undefined) {
|
|
1228
|
+
infeasible(functionName, envelope, `account '${applied.accountId}' holds no state.`);
|
|
1229
|
+
}
|
|
1230
|
+
const target = applied.event;
|
|
1231
|
+
switch (target.eventType) {
|
|
1232
|
+
case 'cash.deposit': {
|
|
1233
|
+
if (
|
|
1234
|
+
!removeSettlementLeg(
|
|
1235
|
+
account,
|
|
1236
|
+
target.currency,
|
|
1237
|
+
applied.eventId,
|
|
1238
|
+
target.amount,
|
|
1239
|
+
target.settleTimestampMs,
|
|
1240
|
+
)
|
|
1241
|
+
) {
|
|
1242
|
+
infeasible(
|
|
1243
|
+
functionName,
|
|
1244
|
+
envelope,
|
|
1245
|
+
`its dated cash leg is absent or differs from the applied deposit; the carried state is not an exact continuation of that fact.`,
|
|
1246
|
+
);
|
|
1247
|
+
}
|
|
1248
|
+
cashOf(account, target.currency).totalAmount -= target.amount;
|
|
1249
|
+
break;
|
|
1250
|
+
}
|
|
1251
|
+
case 'cash.withdrawal': {
|
|
1252
|
+
if (
|
|
1253
|
+
!removeSettlementLeg(
|
|
1254
|
+
account,
|
|
1255
|
+
target.currency,
|
|
1256
|
+
applied.eventId,
|
|
1257
|
+
-target.amount,
|
|
1258
|
+
target.settleTimestampMs,
|
|
1259
|
+
)
|
|
1260
|
+
) {
|
|
1261
|
+
infeasible(
|
|
1262
|
+
functionName,
|
|
1263
|
+
envelope,
|
|
1264
|
+
`its dated cash leg is absent or differs from the applied withdrawal; the carried state is not an exact continuation of that fact.`,
|
|
1265
|
+
);
|
|
1266
|
+
}
|
|
1267
|
+
cashOf(account, target.currency).totalAmount += target.amount;
|
|
1268
|
+
break;
|
|
1269
|
+
}
|
|
1270
|
+
case 'cash.transfer': {
|
|
1271
|
+
cashOf(account, target.currency).totalAmount += target.amount;
|
|
1272
|
+
cashOf(accountOf(state, target.toAccountId), target.currency).totalAmount -= target.amount;
|
|
1273
|
+
break;
|
|
1274
|
+
}
|
|
1275
|
+
case 'cash.conversion': {
|
|
1276
|
+
cashOf(account, target.fromCurrency).totalAmount += target.fromAmount;
|
|
1277
|
+
cashOf(account, target.toCurrency).totalAmount -= target.toAmount;
|
|
1278
|
+
break;
|
|
1279
|
+
}
|
|
1280
|
+
case 'cost.charge': {
|
|
1281
|
+
cashOf(account, target.currency).totalAmount += target.amount;
|
|
1282
|
+
addTo(account.transactionCosts, target.currency, -target.amount);
|
|
1283
|
+
if (target.instrumentId !== undefined) {
|
|
1284
|
+
addToInstrument(
|
|
1285
|
+
account.transactionCostsByInstrument,
|
|
1286
|
+
target.instrumentId,
|
|
1287
|
+
target.currency,
|
|
1288
|
+
-target.amount,
|
|
1289
|
+
);
|
|
1290
|
+
}
|
|
1291
|
+
break;
|
|
1292
|
+
}
|
|
1293
|
+
case 'income.received': {
|
|
1294
|
+
if (
|
|
1295
|
+
!removeSettlementLeg(
|
|
1296
|
+
account,
|
|
1297
|
+
target.currency,
|
|
1298
|
+
applied.eventId,
|
|
1299
|
+
target.amount,
|
|
1300
|
+
target.settleTimestampMs,
|
|
1301
|
+
)
|
|
1302
|
+
) {
|
|
1303
|
+
infeasible(
|
|
1304
|
+
functionName,
|
|
1305
|
+
envelope,
|
|
1306
|
+
`its dated cash leg is absent or differs from the applied income; the carried state is not an exact continuation of that fact.`,
|
|
1307
|
+
);
|
|
1308
|
+
}
|
|
1309
|
+
cashOf(account, target.currency).totalAmount -= target.amount;
|
|
1310
|
+
addTo(account.incomeReceived, target.currency, -target.amount);
|
|
1311
|
+
if (target.instrumentId !== undefined) {
|
|
1312
|
+
addToInstrument(
|
|
1313
|
+
account.incomeByInstrument,
|
|
1314
|
+
target.instrumentId,
|
|
1315
|
+
target.currency,
|
|
1316
|
+
-target.amount,
|
|
1317
|
+
);
|
|
1318
|
+
}
|
|
1319
|
+
break;
|
|
1320
|
+
}
|
|
1321
|
+
case 'financing.charge': {
|
|
1322
|
+
cashOf(account, target.currency).totalAmount += target.amount;
|
|
1323
|
+
addTo(account.financingCosts, target.currency, -target.amount);
|
|
1324
|
+
break;
|
|
1325
|
+
}
|
|
1326
|
+
case 'trade.fill': {
|
|
1327
|
+
const effect = ownValue(state.fillEffects, key);
|
|
1328
|
+
if (effect === undefined) {
|
|
1329
|
+
infeasible(functionName, envelope, `the fold holds no effect record for that fill.`);
|
|
1330
|
+
}
|
|
1331
|
+
if (effect.relievedQuantity > QUANTITY_DUST) {
|
|
1332
|
+
infeasible(
|
|
1333
|
+
functionName,
|
|
1334
|
+
envelope,
|
|
1335
|
+
`the fill relieved ${effect.relievedQuantity} ${target.instrumentId} from prior lots and realized ${effect.realizedPnl} ${target.currency}; relieved lots cannot be restored exactly.`,
|
|
1336
|
+
);
|
|
1337
|
+
}
|
|
1338
|
+
const position = ownValue(account.positions, target.instrumentId);
|
|
1339
|
+
const opened = position?.lots.filter((lot) => effect.openedLotIds.includes(lot.lotId)) ?? [];
|
|
1340
|
+
const intact =
|
|
1341
|
+
opened.length === effect.openedLotIds.length &&
|
|
1342
|
+
Math.abs(opened.reduce((sum, lot) => sum + Math.abs(lot.quantity), 0) - target.quantity) <=
|
|
1343
|
+
QUANTITY_DUST;
|
|
1344
|
+
if (!intact) {
|
|
1345
|
+
infeasible(
|
|
1346
|
+
functionName,
|
|
1347
|
+
envelope,
|
|
1348
|
+
`the lots it opened (${effect.openedLotIds.join(', ') || 'none'}) were relieved or rescaled by later events.`,
|
|
1349
|
+
);
|
|
1350
|
+
}
|
|
1351
|
+
position!.lots = position!.lots.filter((lot) => !effect.openedLotIds.includes(lot.lotId));
|
|
1352
|
+
finalizePosition(account, position!);
|
|
1353
|
+
if (effect.cashDelta !== 0) {
|
|
1354
|
+
if (
|
|
1355
|
+
!removeSettlementLeg(
|
|
1356
|
+
account,
|
|
1357
|
+
target.currency,
|
|
1358
|
+
applied.eventId,
|
|
1359
|
+
effect.cashDelta,
|
|
1360
|
+
target.settleTimestampMs,
|
|
1361
|
+
)
|
|
1362
|
+
) {
|
|
1363
|
+
infeasible(
|
|
1364
|
+
functionName,
|
|
1365
|
+
envelope,
|
|
1366
|
+
`its dated cash leg is absent or differs from the applied fill; the carried state is not an exact continuation of that fact.`,
|
|
1367
|
+
);
|
|
1368
|
+
}
|
|
1369
|
+
cashOf(account, target.currency).totalAmount -= effect.cashDelta;
|
|
1370
|
+
}
|
|
1371
|
+
recordIncome(account, target.instrumentId, target.currency, -effect.accruedInterest);
|
|
1372
|
+
delete state.fillEffects[key];
|
|
1373
|
+
break;
|
|
1374
|
+
}
|
|
1375
|
+
default: {
|
|
1376
|
+
const eventType = (target as { eventType: string }).eventType;
|
|
1377
|
+
if (eventType.startsWith('derivative.')) {
|
|
1378
|
+
reverseDerivativeEvent(functionName, state, envelope, applied, key);
|
|
1379
|
+
break;
|
|
1380
|
+
}
|
|
1381
|
+
if (
|
|
1382
|
+
(eventType.startsWith('corporate.') && eventType !== 'corporate.split') ||
|
|
1383
|
+
eventType === 'fixed-income.redemption' ||
|
|
1384
|
+
eventType === 'position.transfer'
|
|
1385
|
+
) {
|
|
1386
|
+
reverseCorporateEvent(functionName, state, envelope, applied, key);
|
|
1387
|
+
break;
|
|
1388
|
+
}
|
|
1389
|
+
infeasible(
|
|
1390
|
+
functionName,
|
|
1391
|
+
envelope,
|
|
1392
|
+
eventType === 'corporate.split'
|
|
1393
|
+
? `a split rescales every open lot; reversing one after later activity has no exact inverse in this build (record a counter-split instead).`
|
|
1394
|
+
: `'${eventType}' has no inverse.`,
|
|
1395
|
+
);
|
|
1396
|
+
}
|
|
1397
|
+
}
|
|
1398
|
+
}
|
|
1399
|
+
|
|
1400
|
+
/**
|
|
1401
|
+
* Reverse an applied fact EXACTLY (slice 3). The registry proves the `original` is what was
|
|
1402
|
+
* applied (content hash), the reversal link is recorded, and each family's inverse is applied —
|
|
1403
|
+
* or refused with the reason when no exact inverse exists (a fill whose lots were relieved, a
|
|
1404
|
+
* split, an already-reversed fact). Reversing a repair is what makes a wrong repair recoverable:
|
|
1405
|
+
* a reversal of a reversal re-applies the fact; a reversal of a correction undoes the replacement
|
|
1406
|
+
* and re-applies the fact.
|
|
1407
|
+
*/
|
|
1408
|
+
function reverseApplied(
|
|
1409
|
+
functionName: string,
|
|
1410
|
+
state: PortfolioState,
|
|
1411
|
+
envelope: PortfolioEventEnvelope,
|
|
1412
|
+
original: PortfolioEventEnvelope,
|
|
1413
|
+
): void {
|
|
1414
|
+
const key = duplicateBoundaryKey(original);
|
|
1415
|
+
const appliedHash = ownValue(state.appliedEvents, key);
|
|
1416
|
+
if (appliedHash === undefined) {
|
|
1417
|
+
throw new DataError(
|
|
1418
|
+
`${functionName}: ${envelope.event.eventType} '${envelope.eventId}' names (sourceId '${original.sourceId}', eventId '${original.eventId}'), which this fold never applied — a reversal repairs an applied fact. Check the sourceId/eventId, or fold the original first.`,
|
|
1419
|
+
{
|
|
1420
|
+
code: ErrorCode.PortfolioReversalTargetMissing,
|
|
1421
|
+
context: {
|
|
1422
|
+
function: functionName,
|
|
1423
|
+
eventId: envelope.eventId,
|
|
1424
|
+
reversesEventId: original.eventId,
|
|
1425
|
+
},
|
|
1426
|
+
},
|
|
1427
|
+
);
|
|
1428
|
+
}
|
|
1429
|
+
if (appliedHash !== portfolioEventContentHash(original)) {
|
|
1430
|
+
infeasible(
|
|
1431
|
+
functionName,
|
|
1432
|
+
envelope,
|
|
1433
|
+
`the carried original hashes differently from what was applied (${appliedHash} applied) — the reversal must carry the applied envelope verbatim.`,
|
|
1434
|
+
);
|
|
1435
|
+
}
|
|
1436
|
+
const reversedBy = ownValue(state.reversals, key);
|
|
1437
|
+
if (reversedBy !== undefined) {
|
|
1438
|
+
infeasible(functionName, envelope, `it was already reversed by ${reversedBy}.`);
|
|
1439
|
+
}
|
|
1440
|
+
const target = original.event;
|
|
1441
|
+
if (target.eventType === 'admin.reversal' || target.eventType === 'admin.correction') {
|
|
1442
|
+
// The repair's own subject: live again once the repair is undone.
|
|
1443
|
+
const inner = target.original;
|
|
1444
|
+
const innerKey = duplicateBoundaryKey(inner);
|
|
1445
|
+
if (ownValue(state.reversals, innerKey) !== key) {
|
|
1446
|
+
infeasible(
|
|
1447
|
+
functionName,
|
|
1448
|
+
envelope,
|
|
1449
|
+
`'${inner.eventId}' is not currently reversed by '${original.eventId}' (it was re-applied or repaired again since).`,
|
|
1450
|
+
);
|
|
1451
|
+
}
|
|
1452
|
+
if (target.eventType === 'admin.correction') {
|
|
1453
|
+
reverseEffect(
|
|
1454
|
+
functionName,
|
|
1455
|
+
state,
|
|
1456
|
+
envelope,
|
|
1457
|
+
{
|
|
1458
|
+
...inner,
|
|
1459
|
+
eventId: original.eventId,
|
|
1460
|
+
sourceId: original.sourceId,
|
|
1461
|
+
event: target.replacement,
|
|
1462
|
+
},
|
|
1463
|
+
key,
|
|
1464
|
+
);
|
|
1465
|
+
}
|
|
1466
|
+
delete state.reversals[innerKey];
|
|
1467
|
+
applyOne(functionName, state, inner);
|
|
1468
|
+
} else {
|
|
1469
|
+
reverseEffect(functionName, state, envelope, original, key);
|
|
1470
|
+
}
|
|
1471
|
+
setOwnValue(state.reversals, key, duplicateBoundaryKey(envelope));
|
|
1472
|
+
}
|
|
1473
|
+
|
|
1474
|
+
function applyOne(
|
|
1475
|
+
functionName: string,
|
|
1476
|
+
state: PortfolioState,
|
|
1477
|
+
envelope: PortfolioEventEnvelope,
|
|
1478
|
+
): void {
|
|
1479
|
+
const account = accountOf(state, envelope.accountId);
|
|
1480
|
+
switch (envelope.event.eventType) {
|
|
1481
|
+
case 'admin.reversal': {
|
|
1482
|
+
reverseApplied(functionName, state, envelope, envelope.event.original);
|
|
1483
|
+
break;
|
|
1484
|
+
}
|
|
1485
|
+
case 'admin.correction': {
|
|
1486
|
+
const correction = envelope.event;
|
|
1487
|
+
reverseApplied(functionName, state, envelope, correction.original);
|
|
1488
|
+
// The replacement folds at the ORIGINAL's instant under the correction's identity: lots it
|
|
1489
|
+
// opens are `openedByEventId: <correction>` and its effect record sits under the
|
|
1490
|
+
// correction's registry key, so the correction is itself exactly reversible.
|
|
1491
|
+
applyOne(functionName, state, {
|
|
1492
|
+
...correction.original,
|
|
1493
|
+
eventId: envelope.eventId,
|
|
1494
|
+
sourceId: envelope.sourceId,
|
|
1495
|
+
event: correction.replacement,
|
|
1496
|
+
});
|
|
1497
|
+
break;
|
|
1498
|
+
}
|
|
1499
|
+
case 'admin.account-migration': {
|
|
1500
|
+
const marker = envelope.event;
|
|
1501
|
+
state.accountMigrations.push({
|
|
1502
|
+
eventId: envelope.eventId,
|
|
1503
|
+
fromAccountId: marker.fromAccountId,
|
|
1504
|
+
toAccountId: marker.toAccountId,
|
|
1505
|
+
effectiveTimestampMs: envelope.effectiveTimestampMs,
|
|
1506
|
+
});
|
|
1507
|
+
break;
|
|
1508
|
+
}
|
|
1509
|
+
case 'cash.deposit': {
|
|
1510
|
+
const event = envelope.event as CashDepositEvent;
|
|
1511
|
+
bookCash(account, event.currency, event.amount, envelope.eventId, event.settleTimestampMs);
|
|
1512
|
+
break;
|
|
1513
|
+
}
|
|
1514
|
+
case 'cash.withdrawal': {
|
|
1515
|
+
const event = envelope.event as CashWithdrawalEvent;
|
|
1516
|
+
bookCash(account, event.currency, -event.amount, envelope.eventId, event.settleTimestampMs);
|
|
1517
|
+
break;
|
|
1518
|
+
}
|
|
1519
|
+
case 'cash.transfer': {
|
|
1520
|
+
const event = envelope.event as CashTransferEvent;
|
|
1521
|
+
cashOf(account, event.currency).totalAmount -= event.amount;
|
|
1522
|
+
cashOf(accountOf(state, event.toAccountId), event.currency).totalAmount += event.amount;
|
|
1523
|
+
break;
|
|
1524
|
+
}
|
|
1525
|
+
case 'cash.conversion': {
|
|
1526
|
+
const event = envelope.event as CashConversionEvent;
|
|
1527
|
+
cashOf(account, event.fromCurrency).totalAmount -= event.fromAmount;
|
|
1528
|
+
cashOf(account, event.toCurrency).totalAmount += event.toAmount;
|
|
1529
|
+
break;
|
|
1530
|
+
}
|
|
1531
|
+
case 'trade.fill': {
|
|
1532
|
+
applyFill(functionName, state, account, envelope, envelope.event as TradeFillEvent);
|
|
1533
|
+
break;
|
|
1534
|
+
}
|
|
1535
|
+
case 'cost.charge': {
|
|
1536
|
+
const event = envelope.event as CostChargeEvent;
|
|
1537
|
+
cashOf(account, event.currency).totalAmount -= event.amount;
|
|
1538
|
+
addTo(account.transactionCosts, event.currency, event.amount);
|
|
1539
|
+
if (event.instrumentId !== undefined) {
|
|
1540
|
+
addToInstrument(
|
|
1541
|
+
account.transactionCostsByInstrument,
|
|
1542
|
+
event.instrumentId,
|
|
1543
|
+
event.currency,
|
|
1544
|
+
event.amount,
|
|
1545
|
+
);
|
|
1546
|
+
}
|
|
1547
|
+
break;
|
|
1548
|
+
}
|
|
1549
|
+
case 'income.received': {
|
|
1550
|
+
const event = envelope.event as IncomeReceivedEvent;
|
|
1551
|
+
bookCash(account, event.currency, event.amount, envelope.eventId, event.settleTimestampMs);
|
|
1552
|
+
addTo(account.incomeReceived, event.currency, event.amount);
|
|
1553
|
+
if (event.instrumentId !== undefined) {
|
|
1554
|
+
addToInstrument(
|
|
1555
|
+
account.incomeByInstrument,
|
|
1556
|
+
event.instrumentId,
|
|
1557
|
+
event.currency,
|
|
1558
|
+
event.amount,
|
|
1559
|
+
);
|
|
1560
|
+
}
|
|
1561
|
+
break;
|
|
1562
|
+
}
|
|
1563
|
+
case 'financing.charge': {
|
|
1564
|
+
const event = envelope.event as FinancingChargeEvent;
|
|
1565
|
+
cashOf(account, event.currency).totalAmount -= event.amount;
|
|
1566
|
+
addTo(account.financingCosts, event.currency, event.amount);
|
|
1567
|
+
break;
|
|
1568
|
+
}
|
|
1569
|
+
case 'corporate.split': {
|
|
1570
|
+
applySplit(functionName, account, envelope, envelope.event as StockSplitEvent);
|
|
1571
|
+
break;
|
|
1572
|
+
}
|
|
1573
|
+
case 'derivative.exercise':
|
|
1574
|
+
case 'derivative.assignment':
|
|
1575
|
+
case 'derivative.expiration':
|
|
1576
|
+
case 'derivative.multiplier-change':
|
|
1577
|
+
case 'derivative.variation-margin':
|
|
1578
|
+
case 'derivative.roll': {
|
|
1579
|
+
applyDerivativeEvent(functionName, state, envelope);
|
|
1580
|
+
break;
|
|
1581
|
+
}
|
|
1582
|
+
case 'fixed-income.redemption':
|
|
1583
|
+
case 'corporate.symbol-change':
|
|
1584
|
+
case 'corporate.merger':
|
|
1585
|
+
case 'corporate.spin-off':
|
|
1586
|
+
case 'corporate.return-of-capital':
|
|
1587
|
+
case 'corporate.cash-in-lieu':
|
|
1588
|
+
case 'position.transfer': {
|
|
1589
|
+
applyCorporateEvent(functionName, state, envelope);
|
|
1590
|
+
break;
|
|
1591
|
+
}
|
|
1592
|
+
}
|
|
1593
|
+
}
|
|
1594
|
+
|
|
1595
|
+
// ---------------------------------------------------------------------------------------------------
|
|
1596
|
+
// The public reducer
|
|
1597
|
+
// ---------------------------------------------------------------------------------------------------
|
|
1598
|
+
|
|
1599
|
+
/**
|
|
1600
|
+
* The direct pure reducer (FC7 required API; the agent-native doc's decided API ladder): fold
|
|
1601
|
+
* `events` over a fresh `portfolio` definition or a `previousState`, returning a new deeply
|
|
1602
|
+
* frozen {@link PortfolioState}.
|
|
1603
|
+
*
|
|
1604
|
+
* Laws (tested in `test/apply.test.ts`):
|
|
1605
|
+
*
|
|
1606
|
+
* - **replay determinism** — same events, same order → deep-equal state;
|
|
1607
|
+
* - **duplicate idempotence** — an already-applied `(sourceId, eventId)` with an identical body
|
|
1608
|
+
* (content hash, provenance excluded) is a no-op;
|
|
1609
|
+
* - **conflict detection** — a same-key body change throws `portfolio.duplicate_event_conflict`;
|
|
1610
|
+
* - **ordering** — events fold in array order and must be non-decreasing in
|
|
1611
|
+
* `effectiveTimestampMs` (ties keep array order);
|
|
1612
|
+
* - **immutability** — neither `previousState` nor any envelope is mutated; the result owns its
|
|
1613
|
+
* own frozen tree.
|
|
1614
|
+
*
|
|
1615
|
+
* @example
|
|
1616
|
+
* ```ts
|
|
1617
|
+
* import { applyPortfolioEvents } from '@insiderfinance/totalfinance/portfolio';
|
|
1618
|
+
*
|
|
1619
|
+
* const state = applyPortfolioEvents({ portfolio: { baseCurrency: 'USD' }, events });
|
|
1620
|
+
* const next = applyPortfolioEvents({ previousState: state, events: moreEvents });
|
|
1621
|
+
* ```
|
|
1622
|
+
*/
|
|
1623
|
+
export function applyPortfolioEvents(input: ApplyPortfolioEventsInput): PortfolioState {
|
|
1624
|
+
const functionName = 'applyPortfolioEvents';
|
|
1625
|
+
requirePlainDataObject(functionName, 'input', input);
|
|
1626
|
+
requireNoInheritedFields(functionName, 'input', input, APPLY_KEYS);
|
|
1627
|
+
ensureKnownKeys(functionName, 'input', input, APPLY_KEYS);
|
|
1628
|
+
if ((input.portfolio === undefined) === (input.previousState === undefined)) {
|
|
1629
|
+
throw new InputError(
|
|
1630
|
+
`${functionName}: supply EXACTLY ONE of portfolio (start a fresh fold) or previousState (continue one) — ${input.portfolio === undefined ? 'neither was supplied' : 'both were supplied, and the reducer will not silently pick'}.\n e.g. ${EXAMPLE_APPLY}`,
|
|
1631
|
+
{
|
|
1632
|
+
code:
|
|
1633
|
+
input.portfolio === undefined ? ErrorCode.InputMissingField : ErrorCode.InputOutOfRange,
|
|
1634
|
+
context: { function: functionName, field: 'portfolio' },
|
|
1635
|
+
},
|
|
1636
|
+
);
|
|
1637
|
+
}
|
|
1638
|
+
requireDenseDataArray(functionName, 'events', input.events);
|
|
1639
|
+
input.events.forEach((envelope, index) => {
|
|
1640
|
+
requirePortfolioEventEnvelope(functionName, `events[${index}]`, envelope);
|
|
1641
|
+
});
|
|
1642
|
+
// Fold the exact plain tree canonical JSON hashes and persistence store. Validation happens
|
|
1643
|
+
// before this copy; the safe canonicalizer rejects any nested behavior that was not data.
|
|
1644
|
+
const events = fromCanonicalJson(canonicalJsonOf(input.events)) as PortfolioEventEnvelope[];
|
|
1645
|
+
|
|
1646
|
+
let working: PortfolioState;
|
|
1647
|
+
if (input.previousState !== undefined) {
|
|
1648
|
+
requirePortfolioStateShape(functionName, 'previousState', input.previousState);
|
|
1649
|
+
working = fromCanonicalJson(canonicalJsonOf(input.previousState)) as PortfolioState;
|
|
1650
|
+
} else {
|
|
1651
|
+
const definition = input.portfolio!;
|
|
1652
|
+
validateDefinition(functionName, definition);
|
|
1653
|
+
working = {
|
|
1654
|
+
schemaVersion: PORTFOLIO_STATE_SCHEMA_VERSION,
|
|
1655
|
+
...(definition.portfolioId !== undefined ? { portfolioId: definition.portfolioId } : {}),
|
|
1656
|
+
baseCurrency: definition.baseCurrency,
|
|
1657
|
+
lotRelief: definition.lotRelief ?? 'fifo',
|
|
1658
|
+
accounts: {},
|
|
1659
|
+
appliedEvents: {},
|
|
1660
|
+
eventCount: 0,
|
|
1661
|
+
lastEffectiveTimestampMs: null,
|
|
1662
|
+
lotSequence: 0,
|
|
1663
|
+
fillEffects: {},
|
|
1664
|
+
reversals: {},
|
|
1665
|
+
accountMigrations: [],
|
|
1666
|
+
};
|
|
1667
|
+
}
|
|
1668
|
+
|
|
1669
|
+
events.forEach((envelope, index) => {
|
|
1670
|
+
const key = duplicateBoundaryKey(envelope);
|
|
1671
|
+
const bodyHash = portfolioEventContentHash(envelope);
|
|
1672
|
+
const appliedHash = ownValue(working.appliedEvents, key);
|
|
1673
|
+
if (appliedHash !== undefined) {
|
|
1674
|
+
if (appliedHash === bodyHash) return; // decided law: an identical replay is a no-op
|
|
1675
|
+
throw new DataError(
|
|
1676
|
+
`${functionName}: events[${index}] replays (sourceId '${envelope.sourceId}', eventId '${envelope.eventId}') with a DIFFERENT body — the previously applied event hashed ${appliedHash}, this one ${bodyHash}. A changed payload under the same identity is a conflict; record a correction as a NEW event instead of rewriting history.`,
|
|
1677
|
+
{
|
|
1678
|
+
code: ErrorCode.PortfolioDuplicateEventConflict,
|
|
1679
|
+
context: {
|
|
1680
|
+
function: functionName,
|
|
1681
|
+
sourceId: envelope.sourceId,
|
|
1682
|
+
eventId: envelope.eventId,
|
|
1683
|
+
},
|
|
1684
|
+
},
|
|
1685
|
+
);
|
|
1686
|
+
}
|
|
1687
|
+
if (
|
|
1688
|
+
working.lastEffectiveTimestampMs !== null &&
|
|
1689
|
+
envelope.effectiveTimestampMs < working.lastEffectiveTimestampMs
|
|
1690
|
+
) {
|
|
1691
|
+
throw new InputError(
|
|
1692
|
+
`${functionName}: events[${index}] (eventId '${envelope.eventId}') is effective at ${envelope.effectiveTimestampMs}, before the fold's last applied instant ${working.lastEffectiveTimestampMs} — events fold in non-decreasing effectiveTimestampMs (ties keep array order). Sort the batch by effectiveTimestampMs before applying.`,
|
|
1693
|
+
{
|
|
1694
|
+
code: ErrorCode.InputOutOfRange,
|
|
1695
|
+
context: { function: functionName, field: `events[${index}].effectiveTimestampMs` },
|
|
1696
|
+
},
|
|
1697
|
+
);
|
|
1698
|
+
}
|
|
1699
|
+
applyOne(functionName, working, envelope);
|
|
1700
|
+
setOwnValue(working.appliedEvents, key, bodyHash);
|
|
1701
|
+
working.eventCount += 1;
|
|
1702
|
+
working.lastEffectiveTimestampMs = envelope.effectiveTimestampMs;
|
|
1703
|
+
});
|
|
1704
|
+
|
|
1705
|
+
// Law 7 (finite results): a fold whose balances or bases left IEEE-754 range (a near-MAX fill
|
|
1706
|
+
// or two near-MAX deposits) refuses with the input-driven teaching instead of returning a state
|
|
1707
|
+
// that carries Infinity — the magnitude mutant holds this law for the package.
|
|
1708
|
+
requireRepresentableResult(functionName, working);
|
|
1709
|
+
// Audit our own output through the same restoration door. This turns a violated reducer
|
|
1710
|
+
// invariant into a typed boundary failure in the call that created it, rather than persisting a
|
|
1711
|
+
// corrupt state that only fails (or throws a raw engine error) on the next call.
|
|
1712
|
+
requirePortfolioStateShape(functionName, 'result', working);
|
|
1713
|
+
return deepFreeze(fromCanonicalJson(canonicalJsonOf(working)) as PortfolioState);
|
|
1714
|
+
}
|
|
1715
|
+
|
|
1716
|
+
const LEDGER_KEYS = [
|
|
1717
|
+
'portfolioId',
|
|
1718
|
+
'baseCurrency',
|
|
1719
|
+
'lotRelief',
|
|
1720
|
+
'events',
|
|
1721
|
+
'state',
|
|
1722
|
+
'provenance',
|
|
1723
|
+
'apply',
|
|
1724
|
+
'toJSON',
|
|
1725
|
+
'pnl',
|
|
1726
|
+
'timeline',
|
|
1727
|
+
] as const;
|
|
1728
|
+
|
|
1729
|
+
/**
|
|
1730
|
+
* Structural validation of a {@link PortfolioLedger} handed back across a public boundary (the
|
|
1731
|
+
* performance seam). A ledger is a VALUE object: it can be spread, cloned, or hand-assembled after
|
|
1732
|
+
* creation, so every door re-validates it — closed keys, both methods present, every event through
|
|
1733
|
+
* the closed envelope validator, the state through its own validator, and the top-level echoes
|
|
1734
|
+
* (`baseCurrency`, `lotRelief`, `portfolioId`) equal to the state they summarize. The enforcement
|
|
1735
|
+
* harness (2026-08-28) reached the seam with `apply` missing and `baseCurrency: null` and was
|
|
1736
|
+
* answered with a series. Package-internal (state.ts is not an entrypoint); not part of the curated public surface — a
|
|
1737
|
+
* public `require*` leak is exactly what the review waves evicted elsewhere.
|
|
1738
|
+
*/
|
|
1739
|
+
export function requirePortfolioLedger(
|
|
1740
|
+
functionName: string,
|
|
1741
|
+
label: string,
|
|
1742
|
+
ledger: PortfolioLedger,
|
|
1743
|
+
): void {
|
|
1744
|
+
requireArgumentObject(functionName, label, ledger);
|
|
1745
|
+
ensureKnownKeys(functionName, label, ledger, LEDGER_KEYS);
|
|
1746
|
+
for (const method of ['apply', 'toJSON', 'pnl', 'timeline'] as const) {
|
|
1747
|
+
if (typeof ledger[method] !== 'function') {
|
|
1748
|
+
throw new InputError(
|
|
1749
|
+
`${functionName}: ${label}.${method} must be the ledger's own method — pass the object returned by createPortfolioLedger or readPortfolioLedgerSnapshot, not a copy of its fields. Received ${ledger[method] === null ? 'null' : typeof ledger[method]}.`,
|
|
1750
|
+
{
|
|
1751
|
+
code: ErrorCode.InputWrongType,
|
|
1752
|
+
context: { function: functionName, field: `${label}.${method}` },
|
|
1753
|
+
},
|
|
1754
|
+
);
|
|
1755
|
+
}
|
|
1756
|
+
}
|
|
1757
|
+
requireArgumentArray(functionName, `${label}.events`, ledger.events);
|
|
1758
|
+
ledger.events.forEach((event, index) =>
|
|
1759
|
+
requirePortfolioEventEnvelope(functionName, `${label}.events[${index}]`, event),
|
|
1760
|
+
);
|
|
1761
|
+
requirePortfolioStateShape(functionName, `${label}.state`, ledger.state);
|
|
1762
|
+
if (ledger.provenance !== undefined) {
|
|
1763
|
+
requireProvenanceShape(functionName, `${label}.provenance`, ledger.provenance);
|
|
1764
|
+
}
|
|
1765
|
+
for (const field of ['baseCurrency', 'lotRelief', 'portfolioId'] as const) {
|
|
1766
|
+
if (ledger[field] !== ledger.state[field]) {
|
|
1767
|
+
throw new InputError(
|
|
1768
|
+
`${functionName}: ${label}.${field} (${JSON.stringify(ledger[field])}) must equal ${label}.state.${field} (${JSON.stringify(ledger.state[field])}) — the ledger's top-level fields echo the state they summarize; a ledger that disagrees with its own state is corrupt.`,
|
|
1769
|
+
{
|
|
1770
|
+
code: ErrorCode.InputOutOfRange,
|
|
1771
|
+
context: { function: functionName, field: `${label}.${field}` },
|
|
1772
|
+
},
|
|
1773
|
+
);
|
|
1774
|
+
}
|
|
1775
|
+
}
|
|
1776
|
+
}
|