@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,1968 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@insiderfinance/totalfinance/portfolio/events` — the FC7 economic-event grammar (Stage 4.4).
|
|
3
|
+
*
|
|
4
|
+
* Portfolio truth is EVENT-DERIVED (agent-native platform doc, Permanent law 1; spec decision
|
|
5
|
+
* D16): positions, cash, cost basis, and realized P&L are a pure fold over immutable economic
|
|
6
|
+
* events — never mutable fields, never conversation memory. This module owns the closed
|
|
7
|
+
* discriminated union of first-slice event payloads, the decided `PortfolioEventEnvelope`, the
|
|
8
|
+
* Law-12 teaching validator, and the event content identity that defines the duplicate boundary.
|
|
9
|
+
*
|
|
10
|
+
* The families and their event lists are the agent-native doc's decided table ("Economic event
|
|
11
|
+
* model"): cash (deposit, withdrawal, transfer, FX conversion), trading (fill), costs
|
|
12
|
+
* (commission, exchange/regulatory fee, slippage adjustment), income (dividend, coupon, interest,
|
|
13
|
+
* staking/funding receipt), financing (margin interest, borrow charge, funding payment), and
|
|
14
|
+
* corporate actions (split, in this slice). Derivative lifecycle, further corporate actions, and
|
|
15
|
+
* correction/reversal folding are later FC7 slices — see `docs/specs/fc7-first-slice.md`.
|
|
16
|
+
*
|
|
17
|
+
* Order submission/acknowledgement/rejection belongs to the EXECUTION JOURNAL, not this ledger
|
|
18
|
+
* (Permanent law 3): an order does not change holdings; a fill does.
|
|
19
|
+
*/
|
|
20
|
+
|
|
21
|
+
import type { EpochMs, Provenance } from '@totalfinance/core';
|
|
22
|
+
import { ErrorCode, InputError, ensureKnownKeys } from '@totalfinance/core';
|
|
23
|
+
import { canonicalJsonOf, contentHash } from '@totalfinance/core/artifacts';
|
|
24
|
+
import {
|
|
25
|
+
describeInputValue,
|
|
26
|
+
hasOwnKey,
|
|
27
|
+
ownValue,
|
|
28
|
+
requireCurrencyCode,
|
|
29
|
+
requireDenseDataArray,
|
|
30
|
+
requireEpochMsField,
|
|
31
|
+
requireFiniteNumberField,
|
|
32
|
+
requireIdentityString,
|
|
33
|
+
requireNoInheritedFields,
|
|
34
|
+
requirePlainDataObject,
|
|
35
|
+
requirePositiveNumberField,
|
|
36
|
+
requireProvenanceShape,
|
|
37
|
+
} from './internal.js';
|
|
38
|
+
|
|
39
|
+
/**
|
|
40
|
+
* Version of the event grammar carried by EVERY envelope. Bump only with a payload shape change,
|
|
41
|
+
* landed together with a registered ledger migration.
|
|
42
|
+
*/
|
|
43
|
+
export const PORTFOLIO_EVENT_SCHEMA_VERSION = 1;
|
|
44
|
+
|
|
45
|
+
/** A deep copy of plain JSON data (the only kind these boundaries accept); typed, lib-free. */
|
|
46
|
+
function cloneJson<T>(value: T): T {
|
|
47
|
+
return JSON.parse(JSON.stringify(value)) as T;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
// ---------------------------------------------------------------------------------------------------
|
|
51
|
+
// Event payloads (closed discriminated union)
|
|
52
|
+
// ---------------------------------------------------------------------------------------------------
|
|
53
|
+
|
|
54
|
+
/** External money INTO the portfolio — an external flow, never investment profit (FC4's law). */
|
|
55
|
+
export interface CashDepositEvent {
|
|
56
|
+
eventType: 'cash.deposit';
|
|
57
|
+
/** Magnitude deposited, > 0, in `currency`. */
|
|
58
|
+
amount: number;
|
|
59
|
+
currency: string;
|
|
60
|
+
/** When the cash leg settles; omitted = settled at `effectiveTimestampMs`. */
|
|
61
|
+
settleTimestampMs?: EpochMs;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
/** External money OUT of the portfolio — an external flow, never investment loss. */
|
|
65
|
+
export interface CashWithdrawalEvent {
|
|
66
|
+
eventType: 'cash.withdrawal';
|
|
67
|
+
/** Magnitude withdrawn, > 0, in `currency`. */
|
|
68
|
+
amount: number;
|
|
69
|
+
currency: string;
|
|
70
|
+
settleTimestampMs?: EpochMs;
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** Cash moved between two accounts of the SAME portfolio — internal, never an external flow. */
|
|
74
|
+
export interface CashTransferEvent {
|
|
75
|
+
eventType: 'cash.transfer';
|
|
76
|
+
/** Magnitude transferred, > 0, in `currency`. */
|
|
77
|
+
amount: number;
|
|
78
|
+
currency: string;
|
|
79
|
+
/** Must equal the envelope's `accountId` — the account the transfer leaves. */
|
|
80
|
+
fromAccountId: string;
|
|
81
|
+
toAccountId: string;
|
|
82
|
+
}
|
|
83
|
+
|
|
84
|
+
/**
|
|
85
|
+
* A realized FX conversion between two cash balances of one account. Both legs are explicit
|
|
86
|
+
* amounts — the realized rate is `toAmount / fromAmount`; no rate arithmetic is guessed here.
|
|
87
|
+
*/
|
|
88
|
+
export interface CashConversionEvent {
|
|
89
|
+
eventType: 'cash.conversion';
|
|
90
|
+
fromCurrency: string;
|
|
91
|
+
toCurrency: string;
|
|
92
|
+
/** Magnitude of `fromCurrency` sold, > 0. */
|
|
93
|
+
fromAmount: number;
|
|
94
|
+
/** Magnitude of `toCurrency` received, > 0. */
|
|
95
|
+
toAmount: number;
|
|
96
|
+
}
|
|
97
|
+
|
|
98
|
+
/** One `specific-lot` relief instruction: which lot, and how much of it, this fill closes. */
|
|
99
|
+
export interface TradeFillLotSelection {
|
|
100
|
+
lotId: string;
|
|
101
|
+
/** Quantity relieved from the named lot, > 0 (an unsigned magnitude). */
|
|
102
|
+
quantity: number;
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/**
|
|
106
|
+
* An executed fill — the audited bridge from the execution journal into economic holdings
|
|
107
|
+
* (Permanent law 3). Buys open/extend long lots or cover short lots; sells relieve long lots or
|
|
108
|
+
* open short lots. This slice prices cash as `quantity × pricePerUnit` (contract multipliers
|
|
109
|
+
* arrive with the derivative-lifecycle slice).
|
|
110
|
+
*/
|
|
111
|
+
export interface TradeFillEvent {
|
|
112
|
+
eventType: 'trade.fill';
|
|
113
|
+
instrumentId: string;
|
|
114
|
+
side: 'buy' | 'sell';
|
|
115
|
+
/** Filled quantity, > 0 (fractional supported); `side` carries the direction. */
|
|
116
|
+
quantity: number;
|
|
117
|
+
/** Execution price per unit in `currency`. Finite; sign-unconstrained (negative prints are real). */
|
|
118
|
+
pricePerUnit: number;
|
|
119
|
+
currency: string;
|
|
120
|
+
/** When the cash leg settles (trade date vs settlement date); omitted = settles immediately. */
|
|
121
|
+
settleTimestampMs?: EpochMs;
|
|
122
|
+
/** Required exactly when the ledger's `lotRelief` is `'specific-lot'` AND this fill closes. */
|
|
123
|
+
lotSelections?: TradeFillLotSelection[];
|
|
124
|
+
/**
|
|
125
|
+
* Units of the underlying per unit of `quantity` (an equity option's 100, a futures contract
|
|
126
|
+
* size). Omitted = 1 (one unit per unit). REQUIRED when `contract` is given — a derivative fill
|
|
127
|
+
* states its multiplier. Cash and lot values scale by it; the lot basis stays per unit.
|
|
128
|
+
*/
|
|
129
|
+
contractMultiplier?: number;
|
|
130
|
+
/**
|
|
131
|
+
* `'cash-on-trade'` (equities, options, spot; the default) books `quantity × pricePerUnit ×
|
|
132
|
+
* contractMultiplier` at the fill. `'variation-margin'` (futures, perpetuals) books NO cash at
|
|
133
|
+
* the fill: P&L is realized by `derivative.variation-margin` settlements and on close. REQUIRED
|
|
134
|
+
* as `'variation-margin'` when `contract.kind` is `'future'` or `'perpetual'`.
|
|
135
|
+
*/
|
|
136
|
+
settlementStyle?: SettlementStyle;
|
|
137
|
+
/** The derivative's terms (option type/strike/expiry, future expiry, perpetual) — stored on the position. */
|
|
138
|
+
contract?: DerivativeContractTerms;
|
|
139
|
+
/**
|
|
140
|
+
* Accrued interest paid with a bond purchase (or received on a sale), in `currency` — booked as
|
|
141
|
+
* an income adjustment (negative on a buy), NEVER into the lot basis; the next coupon recovers it.
|
|
142
|
+
*/
|
|
143
|
+
accruedInterest?: number;
|
|
144
|
+
}
|
|
145
|
+
|
|
146
|
+
export type CostType = 'commission' | 'exchange-fee' | 'regulatory-fee' | 'slippage-adjustment';
|
|
147
|
+
|
|
148
|
+
/**
|
|
149
|
+
* An explicit transaction cost — a SEPARATE event, never folded into lot cost basis (FC7
|
|
150
|
+
* mandatory state: costs are separate components), attributed via `instrumentId`/`relatesToEventId`.
|
|
151
|
+
*/
|
|
152
|
+
export interface CostChargeEvent {
|
|
153
|
+
eventType: 'cost.charge';
|
|
154
|
+
costType: CostType;
|
|
155
|
+
/** Finite and non-zero: > 0 charges cash, < 0 is a rebate/credit. */
|
|
156
|
+
amount: number;
|
|
157
|
+
currency: string;
|
|
158
|
+
instrumentId?: string;
|
|
159
|
+
/** The `eventId` of the fill (or other event) this cost belongs to, when known. */
|
|
160
|
+
relatesToEventId?: string;
|
|
161
|
+
}
|
|
162
|
+
|
|
163
|
+
export type IncomeType = 'dividend' | 'coupon' | 'interest' | 'staking-reward' | 'funding-receipt';
|
|
164
|
+
|
|
165
|
+
/**
|
|
166
|
+
* Income cash effect — dividend, coupon, interest, staking reward, or funding receipt.
|
|
167
|
+
* Despite the historical `income.received` event name, dividends and coupons are signed:
|
|
168
|
+
* positive receives income; negative pays the corresponding short-position obligation.
|
|
169
|
+
* Either sign belongs to income attribution, not external flows or financing costs.
|
|
170
|
+
*/
|
|
171
|
+
export interface IncomeReceivedEvent {
|
|
172
|
+
eventType: 'income.received';
|
|
173
|
+
incomeType: IncomeType;
|
|
174
|
+
/**
|
|
175
|
+
* Finite and non-zero, in `currency`. Dividends/coupons may be negative (income owed on a
|
|
176
|
+
* short); other income types must be positive (funding payments use `financing.charge`).
|
|
177
|
+
*/
|
|
178
|
+
amount: number;
|
|
179
|
+
currency: string;
|
|
180
|
+
instrumentId?: string;
|
|
181
|
+
settleTimestampMs?: EpochMs;
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
export type FinancingType = 'margin-interest' | 'borrow-charge' | 'funding-payment';
|
|
185
|
+
|
|
186
|
+
/** A financing charge paid in cash — margin interest, borrow fee, or perpetual funding paid. */
|
|
187
|
+
export interface FinancingChargeEvent {
|
|
188
|
+
eventType: 'financing.charge';
|
|
189
|
+
financingType: FinancingType;
|
|
190
|
+
/** Magnitude charged, > 0, in `currency` (a funding RECEIPT is `income.received`). */
|
|
191
|
+
amount: number;
|
|
192
|
+
currency: string;
|
|
193
|
+
instrumentId?: string;
|
|
194
|
+
}
|
|
195
|
+
|
|
196
|
+
/**
|
|
197
|
+
* A forward or reverse stock split: every lot's quantity scales by
|
|
198
|
+
* `sharesAfterSplit / sharesBeforeSplit` and its per-unit basis by the inverse, so total cost
|
|
199
|
+
* basis is preserved exactly. Cash-in-lieu of fractional shares is a separate (later) event.
|
|
200
|
+
*/
|
|
201
|
+
export interface StockSplitEvent {
|
|
202
|
+
eventType: 'corporate.split';
|
|
203
|
+
instrumentId: string;
|
|
204
|
+
/** Shares held after the split per `sharesBeforeSplit` held before; positive integer. */
|
|
205
|
+
sharesAfterSplit: number;
|
|
206
|
+
/** Positive integer; a 2-for-1 split is `{ sharesAfterSplit: 2, sharesBeforeSplit: 1 }`. */
|
|
207
|
+
sharesBeforeSplit: number;
|
|
208
|
+
}
|
|
209
|
+
|
|
210
|
+
// ---------------------------------------------------------------------------------------------------
|
|
211
|
+
// Instrument profile and lifecycle families (slice 5, 2026-08-29; agent-native "Derivative
|
|
212
|
+
// lifecycle" and "Corporate actions" families; FC7 mandatory state)
|
|
213
|
+
// ---------------------------------------------------------------------------------------------------
|
|
214
|
+
|
|
215
|
+
/** How a position's cash settles: at the fill, or through variation margin. */
|
|
216
|
+
export type SettlementStyle = 'cash-on-trade' | 'variation-margin';
|
|
217
|
+
|
|
218
|
+
export interface OptionContractTerms {
|
|
219
|
+
kind: 'option';
|
|
220
|
+
underlyingInstrumentId: string;
|
|
221
|
+
/** `'call' | 'put'` — the same word the option contract and every chain row use (B6). */
|
|
222
|
+
type: 'call' | 'put';
|
|
223
|
+
strikePricePerUnit: number;
|
|
224
|
+
expiryTimestampMs: EpochMs;
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
export interface FutureContractTerms {
|
|
228
|
+
kind: 'future';
|
|
229
|
+
underlyingInstrumentId: string;
|
|
230
|
+
expiryTimestampMs: EpochMs;
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
export interface PerpetualContractTerms {
|
|
234
|
+
kind: 'perpetual';
|
|
235
|
+
underlyingInstrumentId: string;
|
|
236
|
+
}
|
|
237
|
+
|
|
238
|
+
/** The terms a derivative position carries from its opening fill. */
|
|
239
|
+
export type DerivativeContractTerms =
|
|
240
|
+
| OptionContractTerms
|
|
241
|
+
| FutureContractTerms
|
|
242
|
+
| PerpetualContractTerms;
|
|
243
|
+
|
|
244
|
+
/** Physical delivery of the underlying at the strike, or cash at an explicit settlement price. */
|
|
245
|
+
export type DerivativeSettlement =
|
|
246
|
+
| { kind: 'physical' }
|
|
247
|
+
| { kind: 'cash'; settlementPricePerUnit: number };
|
|
248
|
+
|
|
249
|
+
/**
|
|
250
|
+
* What happens to the option premium on physical exercise/assignment: folded into the delivered
|
|
251
|
+
* underlying's basis or proceeds (the common tax-lot convention), or realized on the option lots.
|
|
252
|
+
* REQUIRED — a convention is a goal, not a default.
|
|
253
|
+
*/
|
|
254
|
+
export type PremiumTreatment = 'fold-into-underlying-basis' | 'realize';
|
|
255
|
+
|
|
256
|
+
/** A holder exercises long option contracts. */
|
|
257
|
+
export interface OptionExerciseEvent {
|
|
258
|
+
eventType: 'derivative.exercise';
|
|
259
|
+
instrumentId: string;
|
|
260
|
+
/** Contracts exercised, > 0. */
|
|
261
|
+
quantity: number;
|
|
262
|
+
settlement: DerivativeSettlement;
|
|
263
|
+
premiumTreatment: PremiumTreatment;
|
|
264
|
+
settleTimestampMs?: EpochMs;
|
|
265
|
+
lotSelections?: TradeFillLotSelection[];
|
|
266
|
+
}
|
|
267
|
+
|
|
268
|
+
/** A writer is assigned on short option contracts. */
|
|
269
|
+
export interface OptionAssignmentEvent {
|
|
270
|
+
eventType: 'derivative.assignment';
|
|
271
|
+
instrumentId: string;
|
|
272
|
+
/** Contracts assigned, > 0. */
|
|
273
|
+
quantity: number;
|
|
274
|
+
settlement: DerivativeSettlement;
|
|
275
|
+
premiumTreatment: PremiumTreatment;
|
|
276
|
+
settleTimestampMs?: EpochMs;
|
|
277
|
+
lotSelections?: TradeFillLotSelection[];
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
/** Option contracts expire worthless: lots are relieved at zero, no cash moves. */
|
|
281
|
+
export interface OptionExpirationEvent {
|
|
282
|
+
eventType: 'derivative.expiration';
|
|
283
|
+
instrumentId: string;
|
|
284
|
+
/** Contracts expiring, > 0. */
|
|
285
|
+
quantity: number;
|
|
286
|
+
lotSelections?: TradeFillLotSelection[];
|
|
287
|
+
}
|
|
288
|
+
|
|
289
|
+
/** A contract adjustment rescales the multiplier; total basis is preserved exactly. */
|
|
290
|
+
export interface ContractMultiplierChangeEvent {
|
|
291
|
+
eventType: 'derivative.multiplier-change';
|
|
292
|
+
instrumentId: string;
|
|
293
|
+
contractMultiplierAfter: number;
|
|
294
|
+
/** An adjusted strike (OCC-style adjustments change both); only for a position with option terms. */
|
|
295
|
+
strikePricePerUnitAfter?: number;
|
|
296
|
+
reason?: string;
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
/**
|
|
300
|
+
* A variation-margin settlement: every open lot of a `'variation-margin'` position re-bases to
|
|
301
|
+
* the settlement price and the difference is realized in cash — the fold computes the amount
|
|
302
|
+
* from the lots, so a statement's figure reconciles rather than being trusted.
|
|
303
|
+
*/
|
|
304
|
+
export interface VariationMarginEvent {
|
|
305
|
+
eventType: 'derivative.variation-margin';
|
|
306
|
+
instrumentId: string;
|
|
307
|
+
settlementPricePerUnit: number;
|
|
308
|
+
}
|
|
309
|
+
|
|
310
|
+
/** Close a contract and open its successor in one economic event (one provenance). */
|
|
311
|
+
export interface DerivativeRollEvent {
|
|
312
|
+
eventType: 'derivative.roll';
|
|
313
|
+
fromInstrumentId: string;
|
|
314
|
+
toInstrumentId: string;
|
|
315
|
+
/** Contracts rolled, > 0. */
|
|
316
|
+
quantity: number;
|
|
317
|
+
closePricePerUnit: number;
|
|
318
|
+
openPricePerUnit: number;
|
|
319
|
+
/** Terms of the successor contract (the multiplier and settlement style carry over). */
|
|
320
|
+
contract?: DerivativeContractTerms;
|
|
321
|
+
lotSelections?: TradeFillLotSelection[];
|
|
322
|
+
}
|
|
323
|
+
|
|
324
|
+
export type RedemptionType = 'maturity' | 'call' | 'principal-paydown' | 'sinking-fund';
|
|
325
|
+
|
|
326
|
+
/**
|
|
327
|
+
* Principal settled on a fixed-income position: long or short lots relieved at the redemption
|
|
328
|
+
* price. Long holdings receive principal; short holdings pay it. Direction comes from the
|
|
329
|
+
* held position, while the event quantity is always an unsigned magnitude.
|
|
330
|
+
*/
|
|
331
|
+
export interface FixedIncomeRedemptionEvent {
|
|
332
|
+
eventType: 'fixed-income.redemption';
|
|
333
|
+
instrumentId: string;
|
|
334
|
+
redemptionType: RedemptionType;
|
|
335
|
+
/** Magnitude of face units redeemed, > 0, for either a long or short holding. */
|
|
336
|
+
quantity: number;
|
|
337
|
+
/** Redemption price per unit (par = 1 per unit of face, or 100 per 100 face — the fill's unit). */
|
|
338
|
+
pricePerUnit: number;
|
|
339
|
+
currency: string;
|
|
340
|
+
settleTimestampMs?: EpochMs;
|
|
341
|
+
lotSelections?: TradeFillLotSelection[];
|
|
342
|
+
}
|
|
343
|
+
|
|
344
|
+
/** The instrument is renamed; lots, basis, and lot ids carry over. */
|
|
345
|
+
export interface SymbolChangeEvent {
|
|
346
|
+
eventType: 'corporate.symbol-change';
|
|
347
|
+
fromInstrumentId: string;
|
|
348
|
+
toInstrumentId: string;
|
|
349
|
+
}
|
|
350
|
+
|
|
351
|
+
/**
|
|
352
|
+
* A merger: stock-for-stock (`sharesPerShare` of `toInstrumentId` per share held), cash
|
|
353
|
+
* (`cashPerShare`), or both. At least one consideration is REQUIRED.
|
|
354
|
+
*/
|
|
355
|
+
export interface MergerEvent {
|
|
356
|
+
eventType: 'corporate.merger';
|
|
357
|
+
fromInstrumentId: string;
|
|
358
|
+
toInstrumentId?: string;
|
|
359
|
+
sharesPerShare?: number;
|
|
360
|
+
cashPerShare?: number;
|
|
361
|
+
/** Required with `cashPerShare`. */
|
|
362
|
+
currency?: string;
|
|
363
|
+
settleTimestampMs?: EpochMs;
|
|
364
|
+
}
|
|
365
|
+
|
|
366
|
+
/** A spin-off: child shares per parent share with an EXPLICIT basis allocation fraction. */
|
|
367
|
+
export interface SpinOffEvent {
|
|
368
|
+
eventType: 'corporate.spin-off';
|
|
369
|
+
parentInstrumentId: string;
|
|
370
|
+
childInstrumentId: string;
|
|
371
|
+
sharesPerParentShare: number;
|
|
372
|
+
/** Fraction of the parent's basis that moves to the child, in [0, 1]. REQUIRED. */
|
|
373
|
+
basisAllocationFraction: number;
|
|
374
|
+
}
|
|
375
|
+
|
|
376
|
+
/** A return of capital: cash received reduces basis (never income); excess over basis is realized. */
|
|
377
|
+
export interface ReturnOfCapitalEvent {
|
|
378
|
+
eventType: 'corporate.return-of-capital';
|
|
379
|
+
instrumentId: string;
|
|
380
|
+
amountPerShare: number;
|
|
381
|
+
currency: string;
|
|
382
|
+
settleTimestampMs?: EpochMs;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
/** Cash in lieu of a fractional quantity surrendered (after a split, merger, or spin-off). */
|
|
386
|
+
export interface CashInLieuEvent {
|
|
387
|
+
eventType: 'corporate.cash-in-lieu';
|
|
388
|
+
instrumentId: string;
|
|
389
|
+
/** Fractional quantity surrendered, > 0. */
|
|
390
|
+
quantity: number;
|
|
391
|
+
/** Cash received, in `currency`. */
|
|
392
|
+
amount: number;
|
|
393
|
+
currency: string;
|
|
394
|
+
relatesToEventId?: string;
|
|
395
|
+
settleTimestampMs?: EpochMs;
|
|
396
|
+
}
|
|
397
|
+
|
|
398
|
+
/** Lots move between two accounts of the portfolio; basis and opening dates are preserved. */
|
|
399
|
+
export interface PositionTransferEvent {
|
|
400
|
+
eventType: 'position.transfer';
|
|
401
|
+
instrumentId: string;
|
|
402
|
+
/** Unsigned quantity moved, > 0. */
|
|
403
|
+
quantity: number;
|
|
404
|
+
fromAccountId: string;
|
|
405
|
+
toAccountId: string;
|
|
406
|
+
lotSelections?: TradeFillLotSelection[];
|
|
407
|
+
}
|
|
408
|
+
|
|
409
|
+
/** The closed first-slice economic-event union (agent-native doc's decided event families). */
|
|
410
|
+
// ---------------------------------------------------------------------------------------------------
|
|
411
|
+
// Administration (slice 3, 2026-08-28; agent-native "Administration" family, Permanent law 1)
|
|
412
|
+
// ---------------------------------------------------------------------------------------------------
|
|
413
|
+
|
|
414
|
+
/**
|
|
415
|
+
* Reverse an applied fact EXACTLY. The envelope's `reversesEventId` names it; `original` carries
|
|
416
|
+
* the applied envelope verbatim so the fold can prove (by content hash against its registry) that
|
|
417
|
+
* what is being reversed is what was applied — a reversal never targets an imagined fact.
|
|
418
|
+
* History is not rewritten: the original stays in the registry, the reversal is registered beside
|
|
419
|
+
* it, and the state records the link.
|
|
420
|
+
*/
|
|
421
|
+
export interface AdminReversalEvent {
|
|
422
|
+
eventType: 'admin.reversal';
|
|
423
|
+
original: PortfolioEventEnvelope;
|
|
424
|
+
reason?: string;
|
|
425
|
+
}
|
|
426
|
+
|
|
427
|
+
/**
|
|
428
|
+
* Reverse an applied fact exactly and record what it should have been, atomically. The
|
|
429
|
+
* `replacement` folds at the ORIGINAL's effective instant (so lot order and settlement timing are
|
|
430
|
+
* what they would have been had the fact been recorded right), under the correction's identity.
|
|
431
|
+
*/
|
|
432
|
+
export interface AdminCorrectionEvent {
|
|
433
|
+
eventType: 'admin.correction';
|
|
434
|
+
original: PortfolioEventEnvelope;
|
|
435
|
+
replacement: EconomicPortfolioEvent;
|
|
436
|
+
reason?: string;
|
|
437
|
+
}
|
|
438
|
+
|
|
439
|
+
/** An audit marker that an account's identity moved; no economic effect (the marker is the fact). */
|
|
440
|
+
export interface AdminAccountMigrationEvent {
|
|
441
|
+
eventType: 'admin.account-migration';
|
|
442
|
+
fromAccountId: string;
|
|
443
|
+
toAccountId: string;
|
|
444
|
+
reason?: string;
|
|
445
|
+
}
|
|
446
|
+
|
|
447
|
+
/** The events with an economic effect — everything an `admin.*` event can reference or replace. */
|
|
448
|
+
export type EconomicPortfolioEvent =
|
|
449
|
+
| CashDepositEvent
|
|
450
|
+
| CashWithdrawalEvent
|
|
451
|
+
| CashTransferEvent
|
|
452
|
+
| CashConversionEvent
|
|
453
|
+
| TradeFillEvent
|
|
454
|
+
| CostChargeEvent
|
|
455
|
+
| IncomeReceivedEvent
|
|
456
|
+
| FinancingChargeEvent
|
|
457
|
+
| StockSplitEvent
|
|
458
|
+
| OptionExerciseEvent
|
|
459
|
+
| OptionAssignmentEvent
|
|
460
|
+
| OptionExpirationEvent
|
|
461
|
+
| ContractMultiplierChangeEvent
|
|
462
|
+
| VariationMarginEvent
|
|
463
|
+
| DerivativeRollEvent
|
|
464
|
+
| FixedIncomeRedemptionEvent
|
|
465
|
+
| SymbolChangeEvent
|
|
466
|
+
| MergerEvent
|
|
467
|
+
| SpinOffEvent
|
|
468
|
+
| ReturnOfCapitalEvent
|
|
469
|
+
| CashInLieuEvent
|
|
470
|
+
| PositionTransferEvent;
|
|
471
|
+
|
|
472
|
+
export type PortfolioEvent =
|
|
473
|
+
| EconomicPortfolioEvent
|
|
474
|
+
| AdminReversalEvent
|
|
475
|
+
| AdminCorrectionEvent
|
|
476
|
+
| AdminAccountMigrationEvent;
|
|
477
|
+
|
|
478
|
+
export type PortfolioEventType = PortfolioEvent['eventType'];
|
|
479
|
+
|
|
480
|
+
// ---------------------------------------------------------------------------------------------------
|
|
481
|
+
// The envelope (the agent-native doc's decided shape)
|
|
482
|
+
// ---------------------------------------------------------------------------------------------------
|
|
483
|
+
|
|
484
|
+
/**
|
|
485
|
+
* The canonical event envelope — JSON-safe, CloudEvents-mappable without the dependency, and
|
|
486
|
+
* clock-free: BOTH timestamps are supplied explicitly; the package never reads the system clock.
|
|
487
|
+
* `(sourceId, eventId)` is the duplicate boundary: replaying an identical envelope is a no-op,
|
|
488
|
+
* and a same-key envelope with a different body is a typed conflict
|
|
489
|
+
* (`portfolio.duplicate_event_conflict`).
|
|
490
|
+
*/
|
|
491
|
+
export interface PortfolioEventEnvelope {
|
|
492
|
+
/** Unique within `sourceId` — together they are the duplicate boundary. */
|
|
493
|
+
eventId: string;
|
|
494
|
+
/** Must equal {@link PORTFOLIO_EVENT_SCHEMA_VERSION}. */
|
|
495
|
+
schemaVersion: number;
|
|
496
|
+
/** Redundant discriminator; must equal `event.eventType`. */
|
|
497
|
+
eventType: PortfolioEventType;
|
|
498
|
+
/** The system that emitted the event (a broker import, a simulator, a manual entry). */
|
|
499
|
+
sourceId: string;
|
|
500
|
+
/** The account the event is recorded against (for transfers, the FROM account). */
|
|
501
|
+
accountId: string;
|
|
502
|
+
/** When the economic effect occurred. Events fold in non-decreasing `effectiveTimestampMs`. */
|
|
503
|
+
effectiveTimestampMs: EpochMs;
|
|
504
|
+
/** When the event was recorded — may lag the effect; never read from a clock by this package. */
|
|
505
|
+
recordedTimestampMs: EpochMs;
|
|
506
|
+
correlationId?: string;
|
|
507
|
+
causationId?: string;
|
|
508
|
+
/** Names a prior event this one reverses. Recorded now; the repair fold is a later slice. */
|
|
509
|
+
reversesEventId?: string;
|
|
510
|
+
event: PortfolioEvent;
|
|
511
|
+
/** Where the event came from — caller-supplied, never fetched; OUTSIDE the event identity. */
|
|
512
|
+
provenance: Provenance;
|
|
513
|
+
}
|
|
514
|
+
|
|
515
|
+
const ENVELOPE_KEYS = [
|
|
516
|
+
'eventId',
|
|
517
|
+
'schemaVersion',
|
|
518
|
+
'eventType',
|
|
519
|
+
'sourceId',
|
|
520
|
+
'accountId',
|
|
521
|
+
'effectiveTimestampMs',
|
|
522
|
+
'recordedTimestampMs',
|
|
523
|
+
'correlationId',
|
|
524
|
+
'causationId',
|
|
525
|
+
'reversesEventId',
|
|
526
|
+
'event',
|
|
527
|
+
'provenance',
|
|
528
|
+
] as const;
|
|
529
|
+
|
|
530
|
+
const EVENT_KEYS: Record<PortfolioEventType, readonly string[]> = {
|
|
531
|
+
'admin.reversal': ['eventType', 'original', 'reason'],
|
|
532
|
+
'admin.correction': ['eventType', 'original', 'replacement', 'reason'],
|
|
533
|
+
'admin.account-migration': ['eventType', 'fromAccountId', 'toAccountId', 'reason'],
|
|
534
|
+
'cash.deposit': ['eventType', 'amount', 'currency', 'settleTimestampMs'],
|
|
535
|
+
'cash.withdrawal': ['eventType', 'amount', 'currency', 'settleTimestampMs'],
|
|
536
|
+
'cash.transfer': ['eventType', 'amount', 'currency', 'fromAccountId', 'toAccountId'],
|
|
537
|
+
'cash.conversion': ['eventType', 'fromCurrency', 'toCurrency', 'fromAmount', 'toAmount'],
|
|
538
|
+
'trade.fill': [
|
|
539
|
+
'eventType',
|
|
540
|
+
'instrumentId',
|
|
541
|
+
'side',
|
|
542
|
+
'quantity',
|
|
543
|
+
'pricePerUnit',
|
|
544
|
+
'currency',
|
|
545
|
+
'settleTimestampMs',
|
|
546
|
+
'lotSelections',
|
|
547
|
+
'contractMultiplier',
|
|
548
|
+
'settlementStyle',
|
|
549
|
+
'contract',
|
|
550
|
+
'accruedInterest',
|
|
551
|
+
],
|
|
552
|
+
'cost.charge': [
|
|
553
|
+
'eventType',
|
|
554
|
+
'costType',
|
|
555
|
+
'amount',
|
|
556
|
+
'currency',
|
|
557
|
+
'instrumentId',
|
|
558
|
+
'relatesToEventId',
|
|
559
|
+
],
|
|
560
|
+
'income.received': [
|
|
561
|
+
'eventType',
|
|
562
|
+
'incomeType',
|
|
563
|
+
'amount',
|
|
564
|
+
'currency',
|
|
565
|
+
'instrumentId',
|
|
566
|
+
'settleTimestampMs',
|
|
567
|
+
],
|
|
568
|
+
'financing.charge': ['eventType', 'financingType', 'amount', 'currency', 'instrumentId'],
|
|
569
|
+
'corporate.split': ['eventType', 'instrumentId', 'sharesAfterSplit', 'sharesBeforeSplit'],
|
|
570
|
+
'derivative.exercise': [
|
|
571
|
+
'eventType',
|
|
572
|
+
'instrumentId',
|
|
573
|
+
'quantity',
|
|
574
|
+
'settlement',
|
|
575
|
+
'premiumTreatment',
|
|
576
|
+
'settleTimestampMs',
|
|
577
|
+
'lotSelections',
|
|
578
|
+
],
|
|
579
|
+
'derivative.assignment': [
|
|
580
|
+
'eventType',
|
|
581
|
+
'instrumentId',
|
|
582
|
+
'quantity',
|
|
583
|
+
'settlement',
|
|
584
|
+
'premiumTreatment',
|
|
585
|
+
'settleTimestampMs',
|
|
586
|
+
'lotSelections',
|
|
587
|
+
],
|
|
588
|
+
'derivative.expiration': ['eventType', 'instrumentId', 'quantity', 'lotSelections'],
|
|
589
|
+
'derivative.multiplier-change': [
|
|
590
|
+
'eventType',
|
|
591
|
+
'instrumentId',
|
|
592
|
+
'contractMultiplierAfter',
|
|
593
|
+
'strikePricePerUnitAfter',
|
|
594
|
+
'reason',
|
|
595
|
+
],
|
|
596
|
+
'derivative.variation-margin': ['eventType', 'instrumentId', 'settlementPricePerUnit'],
|
|
597
|
+
'derivative.roll': [
|
|
598
|
+
'eventType',
|
|
599
|
+
'fromInstrumentId',
|
|
600
|
+
'toInstrumentId',
|
|
601
|
+
'quantity',
|
|
602
|
+
'closePricePerUnit',
|
|
603
|
+
'openPricePerUnit',
|
|
604
|
+
'contract',
|
|
605
|
+
'lotSelections',
|
|
606
|
+
],
|
|
607
|
+
'fixed-income.redemption': [
|
|
608
|
+
'eventType',
|
|
609
|
+
'instrumentId',
|
|
610
|
+
'redemptionType',
|
|
611
|
+
'quantity',
|
|
612
|
+
'pricePerUnit',
|
|
613
|
+
'currency',
|
|
614
|
+
'settleTimestampMs',
|
|
615
|
+
'lotSelections',
|
|
616
|
+
],
|
|
617
|
+
'corporate.symbol-change': ['eventType', 'fromInstrumentId', 'toInstrumentId'],
|
|
618
|
+
'corporate.merger': [
|
|
619
|
+
'eventType',
|
|
620
|
+
'fromInstrumentId',
|
|
621
|
+
'toInstrumentId',
|
|
622
|
+
'sharesPerShare',
|
|
623
|
+
'cashPerShare',
|
|
624
|
+
'currency',
|
|
625
|
+
'settleTimestampMs',
|
|
626
|
+
],
|
|
627
|
+
'corporate.spin-off': [
|
|
628
|
+
'eventType',
|
|
629
|
+
'parentInstrumentId',
|
|
630
|
+
'childInstrumentId',
|
|
631
|
+
'sharesPerParentShare',
|
|
632
|
+
'basisAllocationFraction',
|
|
633
|
+
],
|
|
634
|
+
'corporate.return-of-capital': [
|
|
635
|
+
'eventType',
|
|
636
|
+
'instrumentId',
|
|
637
|
+
'amountPerShare',
|
|
638
|
+
'currency',
|
|
639
|
+
'settleTimestampMs',
|
|
640
|
+
],
|
|
641
|
+
'corporate.cash-in-lieu': [
|
|
642
|
+
'eventType',
|
|
643
|
+
'instrumentId',
|
|
644
|
+
'quantity',
|
|
645
|
+
'amount',
|
|
646
|
+
'currency',
|
|
647
|
+
'relatesToEventId',
|
|
648
|
+
'settleTimestampMs',
|
|
649
|
+
],
|
|
650
|
+
'position.transfer': [
|
|
651
|
+
'eventType',
|
|
652
|
+
'instrumentId',
|
|
653
|
+
'quantity',
|
|
654
|
+
'fromAccountId',
|
|
655
|
+
'toAccountId',
|
|
656
|
+
'lotSelections',
|
|
657
|
+
],
|
|
658
|
+
};
|
|
659
|
+
|
|
660
|
+
const SETTLEMENT_STYLES: readonly SettlementStyle[] = ['cash-on-trade', 'variation-margin'];
|
|
661
|
+
const CONTRACT_KINDS = ['option', 'future', 'perpetual'] as const;
|
|
662
|
+
const PREMIUM_TREATMENTS: readonly PremiumTreatment[] = ['fold-into-underlying-basis', 'realize'];
|
|
663
|
+
const REDEMPTION_TYPES: readonly RedemptionType[] = [
|
|
664
|
+
'maturity',
|
|
665
|
+
'call',
|
|
666
|
+
'principal-paydown',
|
|
667
|
+
'sinking-fund',
|
|
668
|
+
];
|
|
669
|
+
|
|
670
|
+
const COST_TYPES: readonly CostType[] = [
|
|
671
|
+
'commission',
|
|
672
|
+
'exchange-fee',
|
|
673
|
+
'regulatory-fee',
|
|
674
|
+
'slippage-adjustment',
|
|
675
|
+
];
|
|
676
|
+
const INCOME_TYPES: readonly IncomeType[] = [
|
|
677
|
+
'dividend',
|
|
678
|
+
'coupon',
|
|
679
|
+
'interest',
|
|
680
|
+
'staking-reward',
|
|
681
|
+
'funding-receipt',
|
|
682
|
+
];
|
|
683
|
+
const FINANCING_TYPES: readonly FinancingType[] = [
|
|
684
|
+
'margin-interest',
|
|
685
|
+
'borrow-charge',
|
|
686
|
+
'funding-payment',
|
|
687
|
+
];
|
|
688
|
+
|
|
689
|
+
const EXAMPLE_ENVELOPE =
|
|
690
|
+
"{ eventId: 'evt-1', schemaVersion: 1, eventType: 'cash.deposit', sourceId: 'manual', accountId: 'main', " +
|
|
691
|
+
'effectiveTimestampMs: 1735689600000, recordedTimestampMs: 1735689600000, ' +
|
|
692
|
+
"event: { eventType: 'cash.deposit', amount: 100_000, currency: 'USD' }, provenance: {} }";
|
|
693
|
+
|
|
694
|
+
function requireEnumField<T extends string>(
|
|
695
|
+
functionName: string,
|
|
696
|
+
field: string,
|
|
697
|
+
value: unknown,
|
|
698
|
+
allowed: readonly T[],
|
|
699
|
+
): asserts value is T {
|
|
700
|
+
if (typeof value !== 'string' || !(allowed as readonly string[]).includes(value)) {
|
|
701
|
+
throw new InputError(
|
|
702
|
+
`${functionName}: ${field} must be one of ${allowed.map((v) => `'${v}'`).join(' | ')}. Received ${describeInputValue(value)}.`,
|
|
703
|
+
{ code: ErrorCode.InputInvalidEnum, context: { function: functionName, field } },
|
|
704
|
+
);
|
|
705
|
+
}
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
function requireOptionalSettle(
|
|
709
|
+
functionName: string,
|
|
710
|
+
path: string,
|
|
711
|
+
event: { settleTimestampMs?: unknown },
|
|
712
|
+
effectiveTimestampMs: number,
|
|
713
|
+
): void {
|
|
714
|
+
if (event.settleTimestampMs === undefined) return;
|
|
715
|
+
requireEpochMsField(functionName, `${path}.settleTimestampMs`, event.settleTimestampMs);
|
|
716
|
+
if ((event.settleTimestampMs as number) < effectiveTimestampMs) {
|
|
717
|
+
throw new InputError(
|
|
718
|
+
`${functionName}: ${path}.settleTimestampMs (${event.settleTimestampMs as number}) is before the envelope's effectiveTimestampMs (${effectiveTimestampMs}) — a cash leg cannot settle before its economic effect occurs.`,
|
|
719
|
+
{
|
|
720
|
+
code: ErrorCode.InputOutOfRange,
|
|
721
|
+
context: { function: functionName, field: `${path}.settleTimestampMs` },
|
|
722
|
+
},
|
|
723
|
+
);
|
|
724
|
+
}
|
|
725
|
+
}
|
|
726
|
+
|
|
727
|
+
/** Validate an optional `lotSelections` array (shared by every lot-relieving family). */
|
|
728
|
+
function requireLotSelectionsShape(functionName: string, path: string, selections: unknown): void {
|
|
729
|
+
if (selections === undefined) return;
|
|
730
|
+
if (!Array.isArray(selections) || selections.length === 0) {
|
|
731
|
+
throw new InputError(
|
|
732
|
+
`${functionName}: ${path}.lotSelections must be a non-empty array of { lotId, quantity } when present. Received ${selections === null ? 'null' : Array.isArray(selections) ? 'an empty array' : typeof selections}.`,
|
|
733
|
+
{
|
|
734
|
+
code: ErrorCode.InputWrongType,
|
|
735
|
+
context: { function: functionName, field: `${path}.lotSelections` },
|
|
736
|
+
},
|
|
737
|
+
);
|
|
738
|
+
}
|
|
739
|
+
requireDenseDataArray(functionName, `${path}.lotSelections`, selections);
|
|
740
|
+
const seen = new Set<string>();
|
|
741
|
+
selections.forEach((selection, index) => {
|
|
742
|
+
const selectionPath = `${path}.lotSelections[${index}]`;
|
|
743
|
+
requirePlainDataObject(functionName, selectionPath, selection);
|
|
744
|
+
requireNoInheritedFields(functionName, selectionPath, selection, ['lotId', 'quantity']);
|
|
745
|
+
ensureKnownKeys(functionName, selectionPath, selection as object, ['lotId', 'quantity']);
|
|
746
|
+
const row = selection as Record<string, unknown>;
|
|
747
|
+
requireIdentityString(functionName, `${selectionPath}.lotId`, row['lotId']);
|
|
748
|
+
requirePositiveNumberField(
|
|
749
|
+
functionName,
|
|
750
|
+
`${selectionPath}.quantity`,
|
|
751
|
+
row['quantity'],
|
|
752
|
+
'the unsigned quantity relieved from the named lot',
|
|
753
|
+
);
|
|
754
|
+
if (seen.has(row['lotId'] as string)) {
|
|
755
|
+
throw new InputError(
|
|
756
|
+
`${functionName}: ${selectionPath}.lotId '${String(row['lotId'])}' appears twice — name each relieved lot once, with its total relieved quantity.`,
|
|
757
|
+
{
|
|
758
|
+
code: ErrorCode.InputOutOfRange,
|
|
759
|
+
context: { function: functionName, field: `${selectionPath}.lotId` },
|
|
760
|
+
},
|
|
761
|
+
);
|
|
762
|
+
}
|
|
763
|
+
seen.add(row['lotId'] as string);
|
|
764
|
+
});
|
|
765
|
+
}
|
|
766
|
+
|
|
767
|
+
/** Validate derivative contract terms (closed per kind). */
|
|
768
|
+
function requireContractTerms(functionName: string, path: string, value: unknown): void {
|
|
769
|
+
requirePlainDataObject(functionName, path, value);
|
|
770
|
+
const terms = value as Record<string, unknown>;
|
|
771
|
+
requireNoInheritedFields(functionName, path, terms, ['kind', 'underlyingInstrumentId']);
|
|
772
|
+
const kind = ownValue(terms, 'kind');
|
|
773
|
+
requireEnumField(functionName, `${path}.kind`, kind, CONTRACT_KINDS);
|
|
774
|
+
requireIdentityString(
|
|
775
|
+
functionName,
|
|
776
|
+
`${path}.underlyingInstrumentId`,
|
|
777
|
+
terms['underlyingInstrumentId'],
|
|
778
|
+
);
|
|
779
|
+
if (kind === 'option') {
|
|
780
|
+
const keys = [
|
|
781
|
+
'kind',
|
|
782
|
+
'underlyingInstrumentId',
|
|
783
|
+
'type',
|
|
784
|
+
'strikePricePerUnit',
|
|
785
|
+
'expiryTimestampMs',
|
|
786
|
+
] as const;
|
|
787
|
+
requireNoInheritedFields(functionName, path, terms, keys);
|
|
788
|
+
ensureKnownKeys(functionName, path, terms, keys);
|
|
789
|
+
requireEnumField(functionName, `${path}.type`, terms['type'], ['call', 'put'] as const);
|
|
790
|
+
requireFiniteNumberField(
|
|
791
|
+
functionName,
|
|
792
|
+
`${path}.strikePricePerUnit`,
|
|
793
|
+
terms['strikePricePerUnit'],
|
|
794
|
+
);
|
|
795
|
+
requireEpochMsField(functionName, `${path}.expiryTimestampMs`, terms['expiryTimestampMs']);
|
|
796
|
+
} else if (kind === 'future') {
|
|
797
|
+
const keys = ['kind', 'underlyingInstrumentId', 'expiryTimestampMs'] as const;
|
|
798
|
+
requireNoInheritedFields(functionName, path, terms, keys);
|
|
799
|
+
ensureKnownKeys(functionName, path, terms, keys);
|
|
800
|
+
requireEpochMsField(functionName, `${path}.expiryTimestampMs`, terms['expiryTimestampMs']);
|
|
801
|
+
} else {
|
|
802
|
+
const keys = ['kind', 'underlyingInstrumentId'] as const;
|
|
803
|
+
requireNoInheritedFields(functionName, path, terms, keys);
|
|
804
|
+
ensureKnownKeys(functionName, path, terms, keys);
|
|
805
|
+
}
|
|
806
|
+
}
|
|
807
|
+
|
|
808
|
+
/**
|
|
809
|
+
* The fill's instrument profile: multiplier (> 0, required with contract terms), settlement style
|
|
810
|
+
* (variation margin exactly for futures/perpetuals), and contract terms.
|
|
811
|
+
*/
|
|
812
|
+
function requireContractProfile(
|
|
813
|
+
functionName: string,
|
|
814
|
+
path: string,
|
|
815
|
+
event: Record<string, unknown>,
|
|
816
|
+
): void {
|
|
817
|
+
if (event['contractMultiplier'] !== undefined) {
|
|
818
|
+
requirePositiveNumberField(
|
|
819
|
+
functionName,
|
|
820
|
+
`${path}.contractMultiplier`,
|
|
821
|
+
event['contractMultiplier'],
|
|
822
|
+
'units of the underlying per unit of quantity',
|
|
823
|
+
);
|
|
824
|
+
}
|
|
825
|
+
if (event['settlementStyle'] !== undefined) {
|
|
826
|
+
requireEnumField(
|
|
827
|
+
functionName,
|
|
828
|
+
`${path}.settlementStyle`,
|
|
829
|
+
event['settlementStyle'],
|
|
830
|
+
SETTLEMENT_STYLES,
|
|
831
|
+
);
|
|
832
|
+
}
|
|
833
|
+
if (event['contract'] !== undefined) {
|
|
834
|
+
requireContractTerms(functionName, `${path}.contract`, event['contract']);
|
|
835
|
+
if (event['contractMultiplier'] === undefined) {
|
|
836
|
+
throw new InputError(
|
|
837
|
+
`${functionName}: ${path}.contractMultiplier is required with ${path}.contract — a derivative fill states its multiplier (an equity option's 100, a futures contract size); the ledger never assumes one.`,
|
|
838
|
+
{
|
|
839
|
+
code: ErrorCode.InputMissingField,
|
|
840
|
+
context: { function: functionName, field: `${path}.contractMultiplier` },
|
|
841
|
+
},
|
|
842
|
+
);
|
|
843
|
+
}
|
|
844
|
+
const kind = (event['contract'] as Record<string, unknown>)['kind'];
|
|
845
|
+
const style = event['settlementStyle'] ?? 'cash-on-trade';
|
|
846
|
+
if ((kind === 'future' || kind === 'perpetual') && style !== 'variation-margin') {
|
|
847
|
+
throw new InputError(
|
|
848
|
+
`${functionName}: ${path}.settlementStyle must be 'variation-margin' for a ${kind} — no cash changes hands at the fill; P&L settles through derivative.variation-margin. Received ${describeInputValue(event['settlementStyle'])}.`,
|
|
849
|
+
{
|
|
850
|
+
code: ErrorCode.InputOutOfRange,
|
|
851
|
+
context: { function: functionName, field: `${path}.settlementStyle` },
|
|
852
|
+
},
|
|
853
|
+
);
|
|
854
|
+
}
|
|
855
|
+
if (kind === 'option' && style !== 'cash-on-trade') {
|
|
856
|
+
throw new InputError(
|
|
857
|
+
`${functionName}: ${path}.settlementStyle must be 'cash-on-trade' for an option (the premium is paid at the fill). Received ${describeInputValue(event['settlementStyle'])}.`,
|
|
858
|
+
{
|
|
859
|
+
code: ErrorCode.InputOutOfRange,
|
|
860
|
+
context: { function: functionName, field: `${path}.settlementStyle` },
|
|
861
|
+
},
|
|
862
|
+
);
|
|
863
|
+
}
|
|
864
|
+
} else if (event['settlementStyle'] === 'variation-margin') {
|
|
865
|
+
throw new InputError(
|
|
866
|
+
`${functionName}: ${path}.contract is required with settlementStyle 'variation-margin' — only an explicitly described future or perpetual receives daily variation-margin treatment; a multiplier alone does not turn a cash instrument into a derivative.`,
|
|
867
|
+
{
|
|
868
|
+
code: ErrorCode.InputMissingField,
|
|
869
|
+
context: { function: functionName, field: `${path}.contract` },
|
|
870
|
+
},
|
|
871
|
+
);
|
|
872
|
+
}
|
|
873
|
+
}
|
|
874
|
+
|
|
875
|
+
/** A dated contract may be opened/rolled only while its expiry has not passed (inclusive). */
|
|
876
|
+
function requireContractLiveAt(
|
|
877
|
+
functionName: string,
|
|
878
|
+
path: string,
|
|
879
|
+
value: unknown,
|
|
880
|
+
effectiveTimestampMs: number,
|
|
881
|
+
): void {
|
|
882
|
+
if (value === undefined) return;
|
|
883
|
+
const terms = value as Record<string, unknown>;
|
|
884
|
+
if (
|
|
885
|
+
(terms['kind'] === 'option' || terms['kind'] === 'future') &&
|
|
886
|
+
(terms['expiryTimestampMs'] as number) < effectiveTimestampMs
|
|
887
|
+
) {
|
|
888
|
+
throw new InputError(
|
|
889
|
+
`${functionName}: ${path}.expiryTimestampMs (${String(terms['expiryTimestampMs'])}) is before the event's effectiveTimestampMs (${effectiveTimestampMs}) — a dated contract cannot be opened or rolled after it has expired.`,
|
|
890
|
+
{
|
|
891
|
+
code: ErrorCode.InputOutOfRange,
|
|
892
|
+
context: { function: functionName, field: `${path}.expiryTimestampMs` },
|
|
893
|
+
},
|
|
894
|
+
);
|
|
895
|
+
}
|
|
896
|
+
}
|
|
897
|
+
|
|
898
|
+
function requireDerivativeSettlement(functionName: string, path: string, value: unknown): void {
|
|
899
|
+
requirePlainDataObject(functionName, path, value);
|
|
900
|
+
const settlement = value as Record<string, unknown>;
|
|
901
|
+
const kind = ownValue(settlement, 'kind');
|
|
902
|
+
requireEnumField(functionName, `${path}.kind`, kind, ['physical', 'cash'] as const);
|
|
903
|
+
if (kind === 'physical') {
|
|
904
|
+
requireNoInheritedFields(functionName, path, settlement, ['kind']);
|
|
905
|
+
ensureKnownKeys(functionName, path, settlement, ['kind']);
|
|
906
|
+
} else {
|
|
907
|
+
const keys = ['kind', 'settlementPricePerUnit'] as const;
|
|
908
|
+
requireNoInheritedFields(functionName, path, settlement, keys);
|
|
909
|
+
ensureKnownKeys(functionName, path, settlement, keys);
|
|
910
|
+
requireFiniteNumberField(
|
|
911
|
+
functionName,
|
|
912
|
+
`${path}.settlementPricePerUnit`,
|
|
913
|
+
settlement['settlementPricePerUnit'],
|
|
914
|
+
);
|
|
915
|
+
}
|
|
916
|
+
}
|
|
917
|
+
|
|
918
|
+
function requireQuantityField(
|
|
919
|
+
functionName: string,
|
|
920
|
+
path: string,
|
|
921
|
+
event: Record<string, unknown>,
|
|
922
|
+
meaning: string,
|
|
923
|
+
): void {
|
|
924
|
+
requirePositiveNumberField(functionName, `${path}.quantity`, event['quantity'], meaning);
|
|
925
|
+
}
|
|
926
|
+
|
|
927
|
+
function validateEventPayload(
|
|
928
|
+
functionName: string,
|
|
929
|
+
path: string,
|
|
930
|
+
envelope: PortfolioEventEnvelope,
|
|
931
|
+
): void {
|
|
932
|
+
const event = envelope.event as unknown as Record<string, unknown>;
|
|
933
|
+
requirePlainDataObject(functionName, path, event);
|
|
934
|
+
const eventType = ownValue(event, 'eventType');
|
|
935
|
+
if (typeof eventType !== 'string' || !hasOwnKey(EVENT_KEYS, eventType)) {
|
|
936
|
+
throw new InputError(
|
|
937
|
+
`${functionName}: ${path}.eventType must be one of ${Object.keys(EVENT_KEYS)
|
|
938
|
+
.map((t) => `'${t}'`)
|
|
939
|
+
.join(' | ')}. Received ${describeInputValue(eventType)}.`,
|
|
940
|
+
{
|
|
941
|
+
code: ErrorCode.InputInvalidEnum,
|
|
942
|
+
context: { function: functionName, field: `${path}.eventType` },
|
|
943
|
+
},
|
|
944
|
+
);
|
|
945
|
+
}
|
|
946
|
+
const knownKeys = EVENT_KEYS[eventType as PortfolioEventType];
|
|
947
|
+
requireNoInheritedFields(functionName, path, event, knownKeys);
|
|
948
|
+
ensureKnownKeys(functionName, path, event, knownKeys);
|
|
949
|
+
if (envelope.eventType !== eventType) {
|
|
950
|
+
throw new InputError(
|
|
951
|
+
`${functionName}: the envelope's eventType (${describeInputValue(envelope.eventType)}) must equal ${path}.eventType ('${eventType}') — the redundant discriminator exists so a mismatched envelope is heard, not guessed around.`,
|
|
952
|
+
{ code: ErrorCode.InputOutOfRange, context: { function: functionName, field: 'eventType' } },
|
|
953
|
+
);
|
|
954
|
+
}
|
|
955
|
+
|
|
956
|
+
switch (eventType as PortfolioEventType) {
|
|
957
|
+
case 'cash.deposit':
|
|
958
|
+
case 'cash.withdrawal': {
|
|
959
|
+
requirePositiveNumberField(
|
|
960
|
+
functionName,
|
|
961
|
+
`${path}.amount`,
|
|
962
|
+
event['amount'],
|
|
963
|
+
`the ${eventType === 'cash.deposit' ? 'deposited' : 'withdrawn'} magnitude (direction comes from the event type)`,
|
|
964
|
+
);
|
|
965
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
966
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
967
|
+
break;
|
|
968
|
+
}
|
|
969
|
+
case 'cash.transfer': {
|
|
970
|
+
requirePositiveNumberField(
|
|
971
|
+
functionName,
|
|
972
|
+
`${path}.amount`,
|
|
973
|
+
event['amount'],
|
|
974
|
+
'the transferred magnitude',
|
|
975
|
+
);
|
|
976
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
977
|
+
requireIdentityString(functionName, `${path}.fromAccountId`, event['fromAccountId']);
|
|
978
|
+
requireIdentityString(functionName, `${path}.toAccountId`, event['toAccountId']);
|
|
979
|
+
if (event['fromAccountId'] === event['toAccountId']) {
|
|
980
|
+
throw new InputError(
|
|
981
|
+
`${functionName}: ${path} transfers from account '${String(event['fromAccountId'])}' to itself — fromAccountId and toAccountId must differ.`,
|
|
982
|
+
{
|
|
983
|
+
code: ErrorCode.InputOutOfRange,
|
|
984
|
+
context: { function: functionName, field: `${path}.toAccountId` },
|
|
985
|
+
},
|
|
986
|
+
);
|
|
987
|
+
}
|
|
988
|
+
if (envelope.accountId !== event['fromAccountId']) {
|
|
989
|
+
throw new InputError(
|
|
990
|
+
`${functionName}: the envelope's accountId ('${envelope.accountId}') must equal ${path}.fromAccountId ('${String(event['fromAccountId'])}') — a transfer is recorded against the account it leaves.`,
|
|
991
|
+
{
|
|
992
|
+
code: ErrorCode.InputOutOfRange,
|
|
993
|
+
context: { function: functionName, field: 'accountId' },
|
|
994
|
+
},
|
|
995
|
+
);
|
|
996
|
+
}
|
|
997
|
+
break;
|
|
998
|
+
}
|
|
999
|
+
case 'cash.conversion': {
|
|
1000
|
+
requireCurrencyCode(functionName, `${path}.fromCurrency`, event['fromCurrency']);
|
|
1001
|
+
requireCurrencyCode(functionName, `${path}.toCurrency`, event['toCurrency']);
|
|
1002
|
+
if (event['fromCurrency'] === event['toCurrency']) {
|
|
1003
|
+
throw new InputError(
|
|
1004
|
+
`${functionName}: ${path} converts ${String(event['fromCurrency'])} into itself — fromCurrency and toCurrency must differ.`,
|
|
1005
|
+
{
|
|
1006
|
+
code: ErrorCode.InputOutOfRange,
|
|
1007
|
+
context: { function: functionName, field: `${path}.toCurrency` },
|
|
1008
|
+
},
|
|
1009
|
+
);
|
|
1010
|
+
}
|
|
1011
|
+
requirePositiveNumberField(
|
|
1012
|
+
functionName,
|
|
1013
|
+
`${path}.fromAmount`,
|
|
1014
|
+
event['fromAmount'],
|
|
1015
|
+
'the magnitude of the currency sold',
|
|
1016
|
+
);
|
|
1017
|
+
requirePositiveNumberField(
|
|
1018
|
+
functionName,
|
|
1019
|
+
`${path}.toAmount`,
|
|
1020
|
+
event['toAmount'],
|
|
1021
|
+
'the magnitude of the currency received',
|
|
1022
|
+
);
|
|
1023
|
+
break;
|
|
1024
|
+
}
|
|
1025
|
+
case 'trade.fill': {
|
|
1026
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1027
|
+
requireEnumField(functionName, `${path}.side`, event['side'], ['buy', 'sell'] as const);
|
|
1028
|
+
requirePositiveNumberField(
|
|
1029
|
+
functionName,
|
|
1030
|
+
`${path}.quantity`,
|
|
1031
|
+
event['quantity'],
|
|
1032
|
+
'the filled quantity (side carries the direction)',
|
|
1033
|
+
);
|
|
1034
|
+
requireFiniteNumberField(functionName, `${path}.pricePerUnit`, event['pricePerUnit']);
|
|
1035
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1036
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1037
|
+
requireLotSelectionsShape(functionName, path, event['lotSelections']);
|
|
1038
|
+
requireContractProfile(functionName, path, event);
|
|
1039
|
+
requireContractLiveAt(
|
|
1040
|
+
functionName,
|
|
1041
|
+
`${path}.contract`,
|
|
1042
|
+
event['contract'],
|
|
1043
|
+
envelope.effectiveTimestampMs,
|
|
1044
|
+
);
|
|
1045
|
+
if (event['accruedInterest'] !== undefined) {
|
|
1046
|
+
requireFiniteNumberField(functionName, `${path}.accruedInterest`, event['accruedInterest']);
|
|
1047
|
+
if (event['accruedInterest'] < 0) {
|
|
1048
|
+
throw new InputError(
|
|
1049
|
+
`${functionName}: ${path}.accruedInterest is the unsigned accrued amount exchanged with the fill (side carries the direction: paid on a buy, received on a sell). Received ${event['accruedInterest']}.`,
|
|
1050
|
+
{
|
|
1051
|
+
code: ErrorCode.InputOutOfRange,
|
|
1052
|
+
context: { function: functionName, field: `${path}.accruedInterest` },
|
|
1053
|
+
},
|
|
1054
|
+
);
|
|
1055
|
+
}
|
|
1056
|
+
}
|
|
1057
|
+
break;
|
|
1058
|
+
}
|
|
1059
|
+
case 'cost.charge': {
|
|
1060
|
+
requireEnumField(functionName, `${path}.costType`, event['costType'], COST_TYPES);
|
|
1061
|
+
requireFiniteNumberField(functionName, `${path}.amount`, event['amount']);
|
|
1062
|
+
if ((event['amount'] as number) === 0) {
|
|
1063
|
+
throw new InputError(
|
|
1064
|
+
`${functionName}: ${path}.amount must be non-zero — positive charges cash, negative is a rebate/credit; a zero cost is not an economic event.`,
|
|
1065
|
+
{
|
|
1066
|
+
code: ErrorCode.InputOutOfRange,
|
|
1067
|
+
context: { function: functionName, field: `${path}.amount` },
|
|
1068
|
+
},
|
|
1069
|
+
);
|
|
1070
|
+
}
|
|
1071
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1072
|
+
if (event['instrumentId'] !== undefined) {
|
|
1073
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1074
|
+
}
|
|
1075
|
+
if (event['relatesToEventId'] !== undefined) {
|
|
1076
|
+
requireIdentityString(functionName, `${path}.relatesToEventId`, event['relatesToEventId']);
|
|
1077
|
+
}
|
|
1078
|
+
break;
|
|
1079
|
+
}
|
|
1080
|
+
case 'income.received': {
|
|
1081
|
+
requireEnumField(functionName, `${path}.incomeType`, event['incomeType'], INCOME_TYPES);
|
|
1082
|
+
if (event['incomeType'] === 'dividend' || event['incomeType'] === 'coupon') {
|
|
1083
|
+
requireFiniteNumberField(functionName, `${path}.amount`, event['amount']);
|
|
1084
|
+
if ((event['amount'] as number) === 0) {
|
|
1085
|
+
throw new InputError(
|
|
1086
|
+
`${functionName}: ${path}.amount must be non-zero — positive receives income, negative pays a short-position dividend/coupon obligation; omit a zero income event.`,
|
|
1087
|
+
{
|
|
1088
|
+
code: ErrorCode.InputOutOfRange,
|
|
1089
|
+
context: { function: functionName, field: `${path}.amount` },
|
|
1090
|
+
},
|
|
1091
|
+
);
|
|
1092
|
+
}
|
|
1093
|
+
} else {
|
|
1094
|
+
requirePositiveNumberField(
|
|
1095
|
+
functionName,
|
|
1096
|
+
`${path}.amount`,
|
|
1097
|
+
event['amount'],
|
|
1098
|
+
'income received in cash (a financing PAYMENT is financing.charge)',
|
|
1099
|
+
);
|
|
1100
|
+
}
|
|
1101
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1102
|
+
if (event['instrumentId'] !== undefined) {
|
|
1103
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1104
|
+
}
|
|
1105
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1106
|
+
break;
|
|
1107
|
+
}
|
|
1108
|
+
case 'financing.charge': {
|
|
1109
|
+
requireEnumField(
|
|
1110
|
+
functionName,
|
|
1111
|
+
`${path}.financingType`,
|
|
1112
|
+
event['financingType'],
|
|
1113
|
+
FINANCING_TYPES,
|
|
1114
|
+
);
|
|
1115
|
+
requirePositiveNumberField(
|
|
1116
|
+
functionName,
|
|
1117
|
+
`${path}.amount`,
|
|
1118
|
+
event['amount'],
|
|
1119
|
+
'the financing magnitude paid (a funding RECEIPT is income.received)',
|
|
1120
|
+
);
|
|
1121
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1122
|
+
if (event['instrumentId'] !== undefined) {
|
|
1123
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1124
|
+
}
|
|
1125
|
+
break;
|
|
1126
|
+
}
|
|
1127
|
+
case 'admin.reversal':
|
|
1128
|
+
case 'admin.correction': {
|
|
1129
|
+
requirePlainDataObject(functionName, `${path}.original`, event['original']);
|
|
1130
|
+
// The applied envelope, verbatim — validated as the closed grammar it must already satisfy.
|
|
1131
|
+
requirePortfolioEventEnvelope(functionName, `${path}.original`, event['original'] as never);
|
|
1132
|
+
const original = event['original'] as unknown as PortfolioEventEnvelope;
|
|
1133
|
+
const originalType = original.event.eventType;
|
|
1134
|
+
// A reversal may undo a repair (a reversal of a reversal re-applies the fact; a reversal of a
|
|
1135
|
+
// correction undoes the replacement and re-applies the fact) — that is what makes a wrong
|
|
1136
|
+
// repair recoverable. A correction, and a migration marker, are never the subject of a repair.
|
|
1137
|
+
const repairable =
|
|
1138
|
+
eventType === 'admin.reversal'
|
|
1139
|
+
? originalType !== 'admin.account-migration'
|
|
1140
|
+
: !originalType.startsWith('admin.');
|
|
1141
|
+
if (!repairable) {
|
|
1142
|
+
throw new InputError(
|
|
1143
|
+
`${functionName}: ${path}.original is an '${originalType}' event — ${
|
|
1144
|
+
eventType === 'admin.correction'
|
|
1145
|
+
? 'a correction repairs an economic fact; to undo a repair, record an admin.reversal of it'
|
|
1146
|
+
: 'a migration marker has no effect to reverse'
|
|
1147
|
+
}.`,
|
|
1148
|
+
{
|
|
1149
|
+
code: ErrorCode.InputOutOfRange,
|
|
1150
|
+
context: { function: functionName, field: `${path}.original` },
|
|
1151
|
+
},
|
|
1152
|
+
);
|
|
1153
|
+
}
|
|
1154
|
+
if (envelope.reversesEventId !== original.eventId) {
|
|
1155
|
+
throw new InputError(
|
|
1156
|
+
`${functionName}: ${path.replace(/\.event$/, '')}.reversesEventId must equal ${path}.original.eventId (${describeInputValue(original.eventId)}) — the link and the carried original name the same applied fact. Received ${describeInputValue(envelope.reversesEventId)}.`,
|
|
1157
|
+
{
|
|
1158
|
+
code: ErrorCode.InputOutOfRange,
|
|
1159
|
+
context: { function: functionName, field: `${path}.original.eventId` },
|
|
1160
|
+
},
|
|
1161
|
+
);
|
|
1162
|
+
}
|
|
1163
|
+
if (original.accountId !== envelope.accountId) {
|
|
1164
|
+
throw new InputError(
|
|
1165
|
+
`${functionName}: ${path}.original was recorded on account '${original.accountId}', but this ${eventType as string} is on account '${envelope.accountId}' — a repair is recorded on the account it repairs.`,
|
|
1166
|
+
{
|
|
1167
|
+
code: ErrorCode.InputOutOfRange,
|
|
1168
|
+
context: { function: functionName, field: `${path}.original.accountId` },
|
|
1169
|
+
},
|
|
1170
|
+
);
|
|
1171
|
+
}
|
|
1172
|
+
if (eventType === 'admin.correction') {
|
|
1173
|
+
requirePlainDataObject(functionName, `${path}.replacement`, event['replacement']);
|
|
1174
|
+
const replacementType = ownValue(
|
|
1175
|
+
event['replacement'] as Record<string, unknown>,
|
|
1176
|
+
'eventType',
|
|
1177
|
+
);
|
|
1178
|
+
if (typeof replacementType === 'string' && replacementType.startsWith('admin.')) {
|
|
1179
|
+
throw new InputError(
|
|
1180
|
+
`${functionName}: ${path}.replacement must be an economic event (cash/trade/cost/income/financing/corporate), not '${replacementType}'.`,
|
|
1181
|
+
{
|
|
1182
|
+
code: ErrorCode.InputInvalidEnum,
|
|
1183
|
+
context: { function: functionName, field: `${path}.replacement.eventType` },
|
|
1184
|
+
},
|
|
1185
|
+
);
|
|
1186
|
+
}
|
|
1187
|
+
// Validated at the ORIGINAL's instant — that is when the replacement folds.
|
|
1188
|
+
validateEventPayload(functionName, `${path}.replacement`, {
|
|
1189
|
+
...original,
|
|
1190
|
+
event: event['replacement'] as unknown as PortfolioEvent,
|
|
1191
|
+
});
|
|
1192
|
+
}
|
|
1193
|
+
if (event['reason'] !== undefined) {
|
|
1194
|
+
requireIdentityString(functionName, `${path}.reason`, event['reason']);
|
|
1195
|
+
}
|
|
1196
|
+
break;
|
|
1197
|
+
}
|
|
1198
|
+
case 'admin.account-migration': {
|
|
1199
|
+
requireIdentityString(functionName, `${path}.fromAccountId`, event['fromAccountId']);
|
|
1200
|
+
requireIdentityString(functionName, `${path}.toAccountId`, event['toAccountId']);
|
|
1201
|
+
if (event['fromAccountId'] === event['toAccountId']) {
|
|
1202
|
+
throw new InputError(
|
|
1203
|
+
`${functionName}: ${path} migrates account '${String(event['fromAccountId'])}' to itself — a migration marker names two different account identities.`,
|
|
1204
|
+
{
|
|
1205
|
+
code: ErrorCode.InputOutOfRange,
|
|
1206
|
+
context: { function: functionName, field: `${path}.toAccountId` },
|
|
1207
|
+
},
|
|
1208
|
+
);
|
|
1209
|
+
}
|
|
1210
|
+
if (event['reason'] !== undefined) {
|
|
1211
|
+
requireIdentityString(functionName, `${path}.reason`, event['reason']);
|
|
1212
|
+
}
|
|
1213
|
+
break;
|
|
1214
|
+
}
|
|
1215
|
+
case 'corporate.split': {
|
|
1216
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1217
|
+
for (const field of ['sharesAfterSplit', 'sharesBeforeSplit'] as const) {
|
|
1218
|
+
const value = event[field];
|
|
1219
|
+
if (typeof value !== 'number' || !Number.isSafeInteger(value) || value < 1) {
|
|
1220
|
+
throw new InputError(
|
|
1221
|
+
`${functionName}: ${path}.${field} must be a positive safe-integer share count (a 2-for-1 split is { sharesAfterSplit: 2, sharesBeforeSplit: 1 }; ratios past 2^53 are not share counts). Received ${value === null ? 'null' : typeof value === 'number' ? value : typeof value}.`,
|
|
1222
|
+
{
|
|
1223
|
+
code:
|
|
1224
|
+
typeof value === 'number' ? ErrorCode.InputOutOfRange : ErrorCode.InputWrongType,
|
|
1225
|
+
context: { function: functionName, field: `${path}.${field}` },
|
|
1226
|
+
},
|
|
1227
|
+
);
|
|
1228
|
+
}
|
|
1229
|
+
}
|
|
1230
|
+
if (event['sharesAfterSplit'] === event['sharesBeforeSplit']) {
|
|
1231
|
+
throw new InputError(
|
|
1232
|
+
`${functionName}: ${path} declares a ${String(event['sharesAfterSplit'])}-for-${String(event['sharesBeforeSplit'])} split — a 1:1 "split" changes nothing and is not an economic event.`,
|
|
1233
|
+
{
|
|
1234
|
+
code: ErrorCode.InputOutOfRange,
|
|
1235
|
+
context: { function: functionName, field: `${path}.sharesAfterSplit` },
|
|
1236
|
+
},
|
|
1237
|
+
);
|
|
1238
|
+
}
|
|
1239
|
+
break;
|
|
1240
|
+
}
|
|
1241
|
+
case 'derivative.exercise':
|
|
1242
|
+
case 'derivative.assignment': {
|
|
1243
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1244
|
+
requireQuantityField(functionName, path, event, 'the contracts settled');
|
|
1245
|
+
requireDerivativeSettlement(functionName, `${path}.settlement`, event['settlement']);
|
|
1246
|
+
requireEnumField(
|
|
1247
|
+
functionName,
|
|
1248
|
+
`${path}.premiumTreatment`,
|
|
1249
|
+
event['premiumTreatment'],
|
|
1250
|
+
PREMIUM_TREATMENTS,
|
|
1251
|
+
);
|
|
1252
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1253
|
+
requireLotSelectionsShape(functionName, path, event['lotSelections']);
|
|
1254
|
+
break;
|
|
1255
|
+
}
|
|
1256
|
+
case 'derivative.expiration': {
|
|
1257
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1258
|
+
requireQuantityField(functionName, path, event, 'the contracts expiring');
|
|
1259
|
+
requireLotSelectionsShape(functionName, path, event['lotSelections']);
|
|
1260
|
+
break;
|
|
1261
|
+
}
|
|
1262
|
+
case 'derivative.multiplier-change': {
|
|
1263
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1264
|
+
requirePositiveNumberField(
|
|
1265
|
+
functionName,
|
|
1266
|
+
`${path}.contractMultiplierAfter`,
|
|
1267
|
+
event['contractMultiplierAfter'],
|
|
1268
|
+
'the adjusted units of the underlying per contract',
|
|
1269
|
+
);
|
|
1270
|
+
if (event['strikePricePerUnitAfter'] !== undefined) {
|
|
1271
|
+
requireFiniteNumberField(
|
|
1272
|
+
functionName,
|
|
1273
|
+
`${path}.strikePricePerUnitAfter`,
|
|
1274
|
+
event['strikePricePerUnitAfter'],
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
if (event['reason'] !== undefined && typeof event['reason'] !== 'string') {
|
|
1278
|
+
throw new InputError(`${functionName}: ${path}.reason must be a string.`, {
|
|
1279
|
+
code: ErrorCode.InputWrongType,
|
|
1280
|
+
context: { function: functionName, field: `${path}.reason` },
|
|
1281
|
+
});
|
|
1282
|
+
}
|
|
1283
|
+
break;
|
|
1284
|
+
}
|
|
1285
|
+
case 'derivative.variation-margin': {
|
|
1286
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1287
|
+
requireFiniteNumberField(
|
|
1288
|
+
functionName,
|
|
1289
|
+
`${path}.settlementPricePerUnit`,
|
|
1290
|
+
event['settlementPricePerUnit'],
|
|
1291
|
+
);
|
|
1292
|
+
break;
|
|
1293
|
+
}
|
|
1294
|
+
case 'derivative.roll': {
|
|
1295
|
+
requireIdentityString(functionName, `${path}.fromInstrumentId`, event['fromInstrumentId']);
|
|
1296
|
+
requireIdentityString(functionName, `${path}.toInstrumentId`, event['toInstrumentId']);
|
|
1297
|
+
if (event['fromInstrumentId'] === event['toInstrumentId']) {
|
|
1298
|
+
throw new InputError(
|
|
1299
|
+
`${functionName}: ${path} rolls ${String(event['fromInstrumentId'])} into itself — a roll closes one contract and opens its successor.`,
|
|
1300
|
+
{
|
|
1301
|
+
code: ErrorCode.InputOutOfRange,
|
|
1302
|
+
context: { function: functionName, field: `${path}.toInstrumentId` },
|
|
1303
|
+
},
|
|
1304
|
+
);
|
|
1305
|
+
}
|
|
1306
|
+
requireQuantityField(functionName, path, event, 'the contracts rolled');
|
|
1307
|
+
requireFiniteNumberField(
|
|
1308
|
+
functionName,
|
|
1309
|
+
`${path}.closePricePerUnit`,
|
|
1310
|
+
event['closePricePerUnit'],
|
|
1311
|
+
);
|
|
1312
|
+
requireFiniteNumberField(functionName, `${path}.openPricePerUnit`, event['openPricePerUnit']);
|
|
1313
|
+
if (event['contract'] !== undefined) {
|
|
1314
|
+
requireContractTerms(functionName, `${path}.contract`, event['contract']);
|
|
1315
|
+
requireContractLiveAt(
|
|
1316
|
+
functionName,
|
|
1317
|
+
`${path}.contract`,
|
|
1318
|
+
event['contract'],
|
|
1319
|
+
envelope.effectiveTimestampMs,
|
|
1320
|
+
);
|
|
1321
|
+
}
|
|
1322
|
+
requireLotSelectionsShape(functionName, path, event['lotSelections']);
|
|
1323
|
+
break;
|
|
1324
|
+
}
|
|
1325
|
+
case 'fixed-income.redemption': {
|
|
1326
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1327
|
+
requireEnumField(
|
|
1328
|
+
functionName,
|
|
1329
|
+
`${path}.redemptionType`,
|
|
1330
|
+
event['redemptionType'],
|
|
1331
|
+
REDEMPTION_TYPES,
|
|
1332
|
+
);
|
|
1333
|
+
requireQuantityField(functionName, path, event, 'the face units redeemed');
|
|
1334
|
+
requireFiniteNumberField(functionName, `${path}.pricePerUnit`, event['pricePerUnit']);
|
|
1335
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1336
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1337
|
+
requireLotSelectionsShape(functionName, path, event['lotSelections']);
|
|
1338
|
+
break;
|
|
1339
|
+
}
|
|
1340
|
+
case 'corporate.symbol-change': {
|
|
1341
|
+
requireIdentityString(functionName, `${path}.fromInstrumentId`, event['fromInstrumentId']);
|
|
1342
|
+
requireIdentityString(functionName, `${path}.toInstrumentId`, event['toInstrumentId']);
|
|
1343
|
+
if (event['fromInstrumentId'] === event['toInstrumentId']) {
|
|
1344
|
+
throw new InputError(
|
|
1345
|
+
`${functionName}: ${path} renames ${String(event['fromInstrumentId'])} to itself — not an economic event.`,
|
|
1346
|
+
{
|
|
1347
|
+
code: ErrorCode.InputOutOfRange,
|
|
1348
|
+
context: { function: functionName, field: `${path}.toInstrumentId` },
|
|
1349
|
+
},
|
|
1350
|
+
);
|
|
1351
|
+
}
|
|
1352
|
+
break;
|
|
1353
|
+
}
|
|
1354
|
+
case 'corporate.merger': {
|
|
1355
|
+
requireIdentityString(functionName, `${path}.fromInstrumentId`, event['fromInstrumentId']);
|
|
1356
|
+
const hasShares = event['sharesPerShare'] !== undefined;
|
|
1357
|
+
const hasCash = event['cashPerShare'] !== undefined;
|
|
1358
|
+
if (!hasShares && !hasCash) {
|
|
1359
|
+
throw new InputError(
|
|
1360
|
+
`${functionName}: ${path} must declare a consideration — sharesPerShare (with toInstrumentId), cashPerShare (with currency), or both.`,
|
|
1361
|
+
{
|
|
1362
|
+
code: ErrorCode.InputMissingField,
|
|
1363
|
+
context: { function: functionName, field: `${path}.sharesPerShare` },
|
|
1364
|
+
},
|
|
1365
|
+
);
|
|
1366
|
+
}
|
|
1367
|
+
if (hasShares) {
|
|
1368
|
+
requirePositiveNumberField(
|
|
1369
|
+
functionName,
|
|
1370
|
+
`${path}.sharesPerShare`,
|
|
1371
|
+
event['sharesPerShare'],
|
|
1372
|
+
'new shares per share held',
|
|
1373
|
+
);
|
|
1374
|
+
if (event['toInstrumentId'] === undefined) {
|
|
1375
|
+
throw new InputError(
|
|
1376
|
+
`${functionName}: ${path}.toInstrumentId is required with sharesPerShare — the shares must be of something.`,
|
|
1377
|
+
{
|
|
1378
|
+
code: ErrorCode.InputMissingField,
|
|
1379
|
+
context: { function: functionName, field: `${path}.toInstrumentId` },
|
|
1380
|
+
},
|
|
1381
|
+
);
|
|
1382
|
+
}
|
|
1383
|
+
requireIdentityString(functionName, `${path}.toInstrumentId`, event['toInstrumentId']);
|
|
1384
|
+
if (event['toInstrumentId'] === event['fromInstrumentId']) {
|
|
1385
|
+
throw new InputError(
|
|
1386
|
+
`${functionName}: ${path} merges ${String(event['fromInstrumentId'])} into itself — use corporate.split for a share-count change.`,
|
|
1387
|
+
{
|
|
1388
|
+
code: ErrorCode.InputOutOfRange,
|
|
1389
|
+
context: { function: functionName, field: `${path}.toInstrumentId` },
|
|
1390
|
+
},
|
|
1391
|
+
);
|
|
1392
|
+
}
|
|
1393
|
+
} else if (event['toInstrumentId'] !== undefined) {
|
|
1394
|
+
throw new InputError(
|
|
1395
|
+
`${functionName}: ${path}.toInstrumentId is only meaningful with sharesPerShare (a cash merger delivers no shares).`,
|
|
1396
|
+
{
|
|
1397
|
+
code: ErrorCode.InputOutOfRange,
|
|
1398
|
+
context: { function: functionName, field: `${path}.toInstrumentId` },
|
|
1399
|
+
},
|
|
1400
|
+
);
|
|
1401
|
+
}
|
|
1402
|
+
if (hasCash) {
|
|
1403
|
+
requirePositiveNumberField(
|
|
1404
|
+
functionName,
|
|
1405
|
+
`${path}.cashPerShare`,
|
|
1406
|
+
event['cashPerShare'],
|
|
1407
|
+
'cash per share held',
|
|
1408
|
+
);
|
|
1409
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1410
|
+
} else if (event['currency'] !== undefined) {
|
|
1411
|
+
throw new InputError(
|
|
1412
|
+
`${functionName}: ${path}.currency is only meaningful with cashPerShare.`,
|
|
1413
|
+
{
|
|
1414
|
+
code: ErrorCode.InputOutOfRange,
|
|
1415
|
+
context: { function: functionName, field: `${path}.currency` },
|
|
1416
|
+
},
|
|
1417
|
+
);
|
|
1418
|
+
}
|
|
1419
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1420
|
+
break;
|
|
1421
|
+
}
|
|
1422
|
+
case 'corporate.spin-off': {
|
|
1423
|
+
requireIdentityString(
|
|
1424
|
+
functionName,
|
|
1425
|
+
`${path}.parentInstrumentId`,
|
|
1426
|
+
event['parentInstrumentId'],
|
|
1427
|
+
);
|
|
1428
|
+
requireIdentityString(functionName, `${path}.childInstrumentId`, event['childInstrumentId']);
|
|
1429
|
+
if (event['parentInstrumentId'] === event['childInstrumentId']) {
|
|
1430
|
+
throw new InputError(
|
|
1431
|
+
`${functionName}: ${path} spins ${String(event['parentInstrumentId'])} off from itself.`,
|
|
1432
|
+
{
|
|
1433
|
+
code: ErrorCode.InputOutOfRange,
|
|
1434
|
+
context: { function: functionName, field: `${path}.childInstrumentId` },
|
|
1435
|
+
},
|
|
1436
|
+
);
|
|
1437
|
+
}
|
|
1438
|
+
requirePositiveNumberField(
|
|
1439
|
+
functionName,
|
|
1440
|
+
`${path}.sharesPerParentShare`,
|
|
1441
|
+
event['sharesPerParentShare'],
|
|
1442
|
+
'child shares per parent share',
|
|
1443
|
+
);
|
|
1444
|
+
requireFiniteNumberField(
|
|
1445
|
+
functionName,
|
|
1446
|
+
`${path}.basisAllocationFraction`,
|
|
1447
|
+
event['basisAllocationFraction'],
|
|
1448
|
+
);
|
|
1449
|
+
if (event['basisAllocationFraction'] < 0 || event['basisAllocationFraction'] > 1) {
|
|
1450
|
+
throw new InputError(
|
|
1451
|
+
`${functionName}: ${path}.basisAllocationFraction is the fraction of the parent's basis that moves to the child, in [0, 1]. Received ${event['basisAllocationFraction']}.`,
|
|
1452
|
+
{
|
|
1453
|
+
code: ErrorCode.InputOutOfRange,
|
|
1454
|
+
context: { function: functionName, field: `${path}.basisAllocationFraction` },
|
|
1455
|
+
},
|
|
1456
|
+
);
|
|
1457
|
+
}
|
|
1458
|
+
break;
|
|
1459
|
+
}
|
|
1460
|
+
case 'corporate.return-of-capital': {
|
|
1461
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1462
|
+
requirePositiveNumberField(
|
|
1463
|
+
functionName,
|
|
1464
|
+
`${path}.amountPerShare`,
|
|
1465
|
+
event['amountPerShare'],
|
|
1466
|
+
'capital returned per share held',
|
|
1467
|
+
);
|
|
1468
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1469
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1470
|
+
break;
|
|
1471
|
+
}
|
|
1472
|
+
case 'corporate.cash-in-lieu': {
|
|
1473
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1474
|
+
requireQuantityField(functionName, path, event, 'the fractional quantity surrendered');
|
|
1475
|
+
requireFiniteNumberField(functionName, `${path}.amount`, event['amount']);
|
|
1476
|
+
if (event['amount'] < 0) {
|
|
1477
|
+
throw new InputError(
|
|
1478
|
+
`${functionName}: ${path}.amount is the cash received in lieu, ≥ 0. Received ${event['amount']}.`,
|
|
1479
|
+
{
|
|
1480
|
+
code: ErrorCode.InputOutOfRange,
|
|
1481
|
+
context: { function: functionName, field: `${path}.amount` },
|
|
1482
|
+
},
|
|
1483
|
+
);
|
|
1484
|
+
}
|
|
1485
|
+
requireCurrencyCode(functionName, `${path}.currency`, event['currency']);
|
|
1486
|
+
if (event['relatesToEventId'] !== undefined) {
|
|
1487
|
+
requireIdentityString(functionName, `${path}.relatesToEventId`, event['relatesToEventId']);
|
|
1488
|
+
}
|
|
1489
|
+
requireOptionalSettle(functionName, path, event, envelope.effectiveTimestampMs);
|
|
1490
|
+
break;
|
|
1491
|
+
}
|
|
1492
|
+
case 'position.transfer': {
|
|
1493
|
+
requireIdentityString(functionName, `${path}.instrumentId`, event['instrumentId']);
|
|
1494
|
+
requireQuantityField(functionName, path, event, 'the unsigned quantity moved');
|
|
1495
|
+
requireIdentityString(functionName, `${path}.fromAccountId`, event['fromAccountId']);
|
|
1496
|
+
requireIdentityString(functionName, `${path}.toAccountId`, event['toAccountId']);
|
|
1497
|
+
if (event['fromAccountId'] === event['toAccountId']) {
|
|
1498
|
+
throw new InputError(
|
|
1499
|
+
`${functionName}: ${path} transfers ${String(event['instrumentId'])} from account '${String(event['fromAccountId'])}' to itself — fromAccountId and toAccountId must differ.`,
|
|
1500
|
+
{
|
|
1501
|
+
code: ErrorCode.InputOutOfRange,
|
|
1502
|
+
context: { function: functionName, field: `${path}.toAccountId` },
|
|
1503
|
+
},
|
|
1504
|
+
);
|
|
1505
|
+
}
|
|
1506
|
+
if (envelope.accountId !== event['fromAccountId']) {
|
|
1507
|
+
throw new InputError(
|
|
1508
|
+
`${functionName}: the envelope's accountId ('${envelope.accountId}') must equal ${path}.fromAccountId ('${String(event['fromAccountId'])}') — a transfer is recorded against the account it leaves.`,
|
|
1509
|
+
{
|
|
1510
|
+
code: ErrorCode.InputOutOfRange,
|
|
1511
|
+
context: { function: functionName, field: 'accountId' },
|
|
1512
|
+
},
|
|
1513
|
+
);
|
|
1514
|
+
}
|
|
1515
|
+
requireLotSelectionsShape(functionName, path, event['lotSelections']);
|
|
1516
|
+
break;
|
|
1517
|
+
}
|
|
1518
|
+
}
|
|
1519
|
+
}
|
|
1520
|
+
|
|
1521
|
+
/**
|
|
1522
|
+
* Validate one {@link PortfolioEventEnvelope} at a public boundary (Law 12 closed request): known
|
|
1523
|
+
* keys at every level, identity strings, finite explicit timestamps, the schema version, the
|
|
1524
|
+
* envelope/payload discriminator agreement, and the full per-variant payload contract. The guard
|
|
1525
|
+
* validates its own `functionName` and `label` first (the `requireFundamentalPeriod` precedent) so
|
|
1526
|
+
* its teaching errors always name the real boundary.
|
|
1527
|
+
*/
|
|
1528
|
+
export function requirePortfolioEventEnvelope(
|
|
1529
|
+
functionName: string,
|
|
1530
|
+
label: string,
|
|
1531
|
+
envelope: PortfolioEventEnvelope,
|
|
1532
|
+
): asserts envelope is PortfolioEventEnvelope {
|
|
1533
|
+
if (typeof functionName !== 'string' || functionName.length === 0) {
|
|
1534
|
+
throw new InputError(
|
|
1535
|
+
`requirePortfolioEventEnvelope: functionName must be a non-empty string (the public boundary being validated). Received ${functionName === null ? 'null' : functionName === undefined ? 'undefined' : typeof functionName === 'string' ? "''" : typeof functionName}.`,
|
|
1536
|
+
{ code: ErrorCode.InputWrongType, context: { field: 'functionName' } },
|
|
1537
|
+
);
|
|
1538
|
+
}
|
|
1539
|
+
if (typeof label !== 'string' || label.length === 0) {
|
|
1540
|
+
throw new InputError(
|
|
1541
|
+
`requirePortfolioEventEnvelope: label must be a non-empty string (the caller's name for the envelope field being validated). Received ${label === null ? 'null' : label === undefined ? 'undefined' : typeof label === 'string' ? "''" : typeof label}.`,
|
|
1542
|
+
{ code: ErrorCode.InputWrongType, context: { field: 'label' } },
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
requirePlainDataObject(functionName, label, envelope);
|
|
1546
|
+
requireNoInheritedFields(functionName, label, envelope, ENVELOPE_KEYS);
|
|
1547
|
+
ensureKnownKeys(functionName, label, envelope, ENVELOPE_KEYS);
|
|
1548
|
+
requireIdentityString(functionName, `${label}.eventId`, envelope.eventId);
|
|
1549
|
+
if (envelope.schemaVersion !== PORTFOLIO_EVENT_SCHEMA_VERSION) {
|
|
1550
|
+
const received = describeInputValue(envelope.schemaVersion);
|
|
1551
|
+
throw new InputError(
|
|
1552
|
+
`${functionName}: ${label}.schemaVersion must be ${PORTFOLIO_EVENT_SCHEMA_VERSION} (this build's event grammar). Received ${received}. Older stored events restore through readPortfolioLedgerSnapshot with a registered migration; a newer version needs a newer @insiderfinance/totalfinance release.\n e.g. ${EXAMPLE_ENVELOPE}`,
|
|
1553
|
+
{
|
|
1554
|
+
code:
|
|
1555
|
+
typeof envelope.schemaVersion === 'number'
|
|
1556
|
+
? ErrorCode.SnapshotUnsupportedVersion
|
|
1557
|
+
: ErrorCode.InputWrongType,
|
|
1558
|
+
context: { function: functionName, field: `${label}.schemaVersion`, received },
|
|
1559
|
+
},
|
|
1560
|
+
);
|
|
1561
|
+
}
|
|
1562
|
+
requireIdentityString(functionName, `${label}.sourceId`, envelope.sourceId);
|
|
1563
|
+
requireIdentityString(functionName, `${label}.accountId`, envelope.accountId);
|
|
1564
|
+
requireEpochMsField(functionName, `${label}.effectiveTimestampMs`, envelope.effectiveTimestampMs);
|
|
1565
|
+
requireEpochMsField(functionName, `${label}.recordedTimestampMs`, envelope.recordedTimestampMs);
|
|
1566
|
+
for (const field of ['correlationId', 'causationId', 'reversesEventId'] as const) {
|
|
1567
|
+
if (envelope[field] !== undefined) {
|
|
1568
|
+
requireIdentityString(functionName, `${label}.${field}`, envelope[field]);
|
|
1569
|
+
}
|
|
1570
|
+
}
|
|
1571
|
+
{
|
|
1572
|
+
// Inspect the discriminator only after proving the nested value is stored data. Optional
|
|
1573
|
+
// chaining would otherwise execute an inherited/accessor `eventType` before the payload guard
|
|
1574
|
+
// got a chance to refuse it.
|
|
1575
|
+
requirePlainDataObject(functionName, `${label}.event`, envelope.event);
|
|
1576
|
+
const type = ownValue(envelope.event as unknown as Record<string, unknown>, 'eventType');
|
|
1577
|
+
const isRepair = type === 'admin.reversal' || type === 'admin.correction';
|
|
1578
|
+
if (envelope.reversesEventId !== undefined && !isRepair) {
|
|
1579
|
+
throw new InputError(
|
|
1580
|
+
`${functionName}: ${label}.reversesEventId is set, but only admin.reversal and admin.correction fold that link — a ${describeInputValue(type)} event cannot reverse anything (its own effect stands). Record an admin.reversal naming the fact, or drop the link.`,
|
|
1581
|
+
{
|
|
1582
|
+
code: ErrorCode.InputOutOfRange,
|
|
1583
|
+
context: { function: functionName, field: `${label}.reversesEventId` },
|
|
1584
|
+
},
|
|
1585
|
+
);
|
|
1586
|
+
}
|
|
1587
|
+
if (envelope.reversesEventId === undefined && isRepair) {
|
|
1588
|
+
throw new InputError(
|
|
1589
|
+
`${functionName}: ${label}.reversesEventId is required on an ${describeInputValue(type)} — the envelope names the applied fact it repairs (equal to event.original.eventId).`,
|
|
1590
|
+
{
|
|
1591
|
+
code: ErrorCode.InputMissingField,
|
|
1592
|
+
context: { function: functionName, field: `${label}.reversesEventId` },
|
|
1593
|
+
},
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
if (envelope.provenance === undefined) {
|
|
1598
|
+
throw new InputError(
|
|
1599
|
+
`${functionName}: ${label}.provenance is required — every economic event states where it came from (an empty object {} is a valid "no further detail"). It is caller-supplied, never fetched, and excluded from the event identity.\n e.g. ${EXAMPLE_ENVELOPE}`,
|
|
1600
|
+
{
|
|
1601
|
+
code: ErrorCode.InputMissingField,
|
|
1602
|
+
context: { function: functionName, field: `${label}.provenance` },
|
|
1603
|
+
},
|
|
1604
|
+
);
|
|
1605
|
+
}
|
|
1606
|
+
requireProvenanceShape(functionName, `${label}.provenance`, envelope.provenance);
|
|
1607
|
+
validateEventPayload(functionName, `${label}.event`, envelope);
|
|
1608
|
+
}
|
|
1609
|
+
|
|
1610
|
+
/**
|
|
1611
|
+
* The event's content identity and the CONFLICT boundary for duplicate `(sourceId, eventId)`
|
|
1612
|
+
* delivery: the `sha256:` content hash (Gate B canonical JSON) of the envelope EXCLUDING
|
|
1613
|
+
* `provenance` — two deliveries of the same economic fact under different source labels are the
|
|
1614
|
+
* SAME event (Gate B Decision 3: provenance is outside every identity). The envelope is fully
|
|
1615
|
+
* validated first; a malformed envelope never acquires a confident-looking hash.
|
|
1616
|
+
*/
|
|
1617
|
+
export function portfolioEventContentHash(envelope: PortfolioEventEnvelope): string {
|
|
1618
|
+
requirePortfolioEventEnvelope('portfolioEventContentHash', 'envelope', envelope);
|
|
1619
|
+
const body: Record<string, unknown> = { ...envelope };
|
|
1620
|
+
delete body['provenance'];
|
|
1621
|
+
return contentHash(body);
|
|
1622
|
+
}
|
|
1623
|
+
|
|
1624
|
+
/**
|
|
1625
|
+
* The `(sourceId, eventId)` duplicate-boundary key — the exact registry key `PortfolioState`
|
|
1626
|
+
* records under `appliedEvents`, exposed so stores and importers can pre-check delivery without
|
|
1627
|
+
* re-deriving the encoding.
|
|
1628
|
+
*/
|
|
1629
|
+
export function duplicateBoundaryKey(envelope: PortfolioEventEnvelope): string {
|
|
1630
|
+
// A boundary, not a shortcut: the key is only meaningful for a VALID envelope, so the full
|
|
1631
|
+
// closed-key validator runs here exactly as it does for the content hash — a malformed or
|
|
1632
|
+
// decorated envelope teaches instead of reading `sourceId` off `undefined` (2026-08-28).
|
|
1633
|
+
requirePortfolioEventEnvelope('duplicateBoundaryKey', 'envelope', envelope);
|
|
1634
|
+
return canonicalJsonOf([envelope.sourceId, envelope.eventId]);
|
|
1635
|
+
}
|
|
1636
|
+
|
|
1637
|
+
// ---------------------------------------------------------------------------------------------------
|
|
1638
|
+
// The normalized fill — the audited bridge from an execution fact to economic events (Stage 4.6,
|
|
1639
|
+
// FC8 Decision 2). Backtest, deterministic replay, paper, and live adapters all produce THIS shape;
|
|
1640
|
+
// the ledger records the `trade.fill` and `cost.charge` events it maps to. The package owns the
|
|
1641
|
+
// bridge so no simulator or broker adapter defines a fill of its own.
|
|
1642
|
+
// ---------------------------------------------------------------------------------------------------
|
|
1643
|
+
|
|
1644
|
+
/** Additional cash charges, each in the fill's currency, ≥ 0. Never repeat costs embedded in pricePerUnit. */
|
|
1645
|
+
export interface NormalizedFillCosts {
|
|
1646
|
+
commission?: number;
|
|
1647
|
+
exchangeFees?: number;
|
|
1648
|
+
regulatoryFees?: number;
|
|
1649
|
+
slippageAdjustment?: number;
|
|
1650
|
+
}
|
|
1651
|
+
|
|
1652
|
+
/** Whether the fill added liquidity (rested) or removed it (crossed); unknown when the venue did not say. */
|
|
1653
|
+
export type NormalizedFillLiquidity = 'maker' | 'taker' | 'unknown';
|
|
1654
|
+
|
|
1655
|
+
/**
|
|
1656
|
+
* One execution fact, normalized. Everything an economic ledger needs to book the fill is here;
|
|
1657
|
+
* nothing about the order's journey (acknowledgements, partials, replacements) is — that is the
|
|
1658
|
+
* execution journal's, which stays separate from the ledger by design.
|
|
1659
|
+
*/
|
|
1660
|
+
export interface NormalizedFill {
|
|
1661
|
+
/** Unique within `sourceId`; becomes the `trade.fill` event's id, so a replayed fill folds once. */
|
|
1662
|
+
fillId: string;
|
|
1663
|
+
accountId: string;
|
|
1664
|
+
instrumentId: string;
|
|
1665
|
+
side: 'buy' | 'sell';
|
|
1666
|
+
/** Filled quantity, > 0 (fractional supported); `side` carries the direction. */
|
|
1667
|
+
quantity: number;
|
|
1668
|
+
/** Execution price per unit in `currency`. Finite; sign-unconstrained (negative prints are real). */
|
|
1669
|
+
pricePerUnit: number;
|
|
1670
|
+
currency: string;
|
|
1671
|
+
/** When the fill happened — the event's effective instant. */
|
|
1672
|
+
filledTimestampMs: EpochMs;
|
|
1673
|
+
/** When the cash leg settles; omitted = settles at the fill. Never before `filledTimestampMs`. */
|
|
1674
|
+
settleTimestampMs?: EpochMs;
|
|
1675
|
+
/** Units of the underlying per unit of quantity; REQUIRED when `contract` is given (the ledger's law). */
|
|
1676
|
+
contractMultiplier?: number;
|
|
1677
|
+
settlementStyle?: SettlementStyle;
|
|
1678
|
+
contract?: DerivativeContractTerms;
|
|
1679
|
+
/** Accrued interest paid (bought) or received (sold) with a bond fill, in `currency`. */
|
|
1680
|
+
accruedInterest?: number;
|
|
1681
|
+
costs?: NormalizedFillCosts;
|
|
1682
|
+
/** Absolute execution-price deviation × quantity × multiplier, in currency, ≥ 0. Attribution
|
|
1683
|
+
* only: already embedded in pricePerUnit, NEVER emitted as another cash charge. */
|
|
1684
|
+
executionPriceAdjustment?: number;
|
|
1685
|
+
/** The order this fill answers; becomes the events' `correlationId`. */
|
|
1686
|
+
orderId?: string;
|
|
1687
|
+
venue?: string;
|
|
1688
|
+
liquidity?: NormalizedFillLiquidity;
|
|
1689
|
+
}
|
|
1690
|
+
|
|
1691
|
+
export const NORMALIZED_FILL_KEYS = [
|
|
1692
|
+
'fillId',
|
|
1693
|
+
'accountId',
|
|
1694
|
+
'instrumentId',
|
|
1695
|
+
'side',
|
|
1696
|
+
'quantity',
|
|
1697
|
+
'pricePerUnit',
|
|
1698
|
+
'currency',
|
|
1699
|
+
'filledTimestampMs',
|
|
1700
|
+
'settleTimestampMs',
|
|
1701
|
+
'contractMultiplier',
|
|
1702
|
+
'settlementStyle',
|
|
1703
|
+
'contract',
|
|
1704
|
+
'accruedInterest',
|
|
1705
|
+
'costs',
|
|
1706
|
+
'executionPriceAdjustment',
|
|
1707
|
+
'orderId',
|
|
1708
|
+
'venue',
|
|
1709
|
+
'liquidity',
|
|
1710
|
+
] as const;
|
|
1711
|
+
|
|
1712
|
+
const NORMALIZED_FILL_COST_KEYS = [
|
|
1713
|
+
'commission',
|
|
1714
|
+
'exchangeFees',
|
|
1715
|
+
'regulatoryFees',
|
|
1716
|
+
'slippageAdjustment',
|
|
1717
|
+
] as const;
|
|
1718
|
+
|
|
1719
|
+
/** Cost component → the ledger's `costType` and the event-id suffix, in emission order. */
|
|
1720
|
+
const COST_COMPONENTS: readonly (readonly [keyof NormalizedFillCosts, CostType])[] = [
|
|
1721
|
+
['commission', 'commission'],
|
|
1722
|
+
['exchangeFees', 'exchange-fee'],
|
|
1723
|
+
['regulatoryFees', 'regulatory-fee'],
|
|
1724
|
+
['slippageAdjustment', 'slippage-adjustment'],
|
|
1725
|
+
];
|
|
1726
|
+
|
|
1727
|
+
const EXAMPLE_FILL =
|
|
1728
|
+
"portfolioEventsFromFill({ fill: { fillId: 'f-1', accountId: 'main', instrumentId: 'AAPL', side: 'buy', quantity: 100, pricePerUnit: 150, currency: 'USD', filledTimestampMs: 1767200400000, costs: { commission: 1 } }, sourceId: 'backtest:run-1', recordedTimestampMs: 1767200400000 })";
|
|
1729
|
+
|
|
1730
|
+
/**
|
|
1731
|
+
* Validate a {@link NormalizedFill} at a public boundary: a closed plain-data record whose numbers
|
|
1732
|
+
* are finite, whose quantity is positive, whose settlement never precedes the fill, whose cost
|
|
1733
|
+
* components are non-negative, and whose derivative terms come with their multiplier. The
|
|
1734
|
+
* economic laws a fill must satisfy inside the ledger (a future settles by variation margin, a lot
|
|
1735
|
+
* selection names real lots, …) are enforced by the event validator the mapped events pass through.
|
|
1736
|
+
*/
|
|
1737
|
+
export function requireNormalizedFill(
|
|
1738
|
+
functionName: string,
|
|
1739
|
+
label: string,
|
|
1740
|
+
fill: unknown,
|
|
1741
|
+
): asserts fill is NormalizedFill {
|
|
1742
|
+
requirePlainDataObject(functionName, label, fill);
|
|
1743
|
+
requireNoInheritedFields(functionName, label, fill, NORMALIZED_FILL_KEYS);
|
|
1744
|
+
ensureKnownKeys(functionName, label, fill, NORMALIZED_FILL_KEYS);
|
|
1745
|
+
const record = fill as Record<string, unknown>;
|
|
1746
|
+
for (const field of ['fillId', 'accountId', 'instrumentId'] as const) {
|
|
1747
|
+
requireIdentityString(functionName, `${label}.${field}`, record[field]);
|
|
1748
|
+
}
|
|
1749
|
+
if (record['side'] !== 'buy' && record['side'] !== 'sell') {
|
|
1750
|
+
throw new InputError(
|
|
1751
|
+
`${functionName}: ${label}.side must be 'buy' | 'sell'. Received ${describeInputValue(record['side'])}.\n e.g. ${EXAMPLE_FILL}`,
|
|
1752
|
+
{
|
|
1753
|
+
code: ErrorCode.InputInvalidEnum,
|
|
1754
|
+
context: { function: functionName, field: `${label}.side` },
|
|
1755
|
+
},
|
|
1756
|
+
);
|
|
1757
|
+
}
|
|
1758
|
+
requirePositiveNumberField(
|
|
1759
|
+
functionName,
|
|
1760
|
+
`${label}.quantity`,
|
|
1761
|
+
record['quantity'],
|
|
1762
|
+
'the filled quantity; side carries the direction',
|
|
1763
|
+
);
|
|
1764
|
+
requireFiniteNumberField(functionName, `${label}.pricePerUnit`, record['pricePerUnit']);
|
|
1765
|
+
requireCurrencyCode(functionName, `${label}.currency`, record['currency']);
|
|
1766
|
+
requireEpochMsField(functionName, `${label}.filledTimestampMs`, record['filledTimestampMs']);
|
|
1767
|
+
if (hasOwnKey(record, 'settleTimestampMs')) {
|
|
1768
|
+
requireEpochMsField(functionName, `${label}.settleTimestampMs`, record['settleTimestampMs']);
|
|
1769
|
+
if ((record['settleTimestampMs'] as number) < (record['filledTimestampMs'] as number)) {
|
|
1770
|
+
throw new InputError(
|
|
1771
|
+
`${functionName}: ${label}.settleTimestampMs (${String(record['settleTimestampMs'])}) precedes filledTimestampMs (${String(record['filledTimestampMs'])}) — cash settles at or after the fill, never before.`,
|
|
1772
|
+
{
|
|
1773
|
+
code: ErrorCode.InputOutOfRange,
|
|
1774
|
+
context: { function: functionName, field: `${label}.settleTimestampMs` },
|
|
1775
|
+
},
|
|
1776
|
+
);
|
|
1777
|
+
}
|
|
1778
|
+
}
|
|
1779
|
+
if (hasOwnKey(record, 'contractMultiplier')) {
|
|
1780
|
+
requirePositiveNumberField(
|
|
1781
|
+
functionName,
|
|
1782
|
+
`${label}.contractMultiplier`,
|
|
1783
|
+
record['contractMultiplier'],
|
|
1784
|
+
'units of the underlying per unit of quantity',
|
|
1785
|
+
);
|
|
1786
|
+
}
|
|
1787
|
+
if (hasOwnKey(record, 'settlementStyle')) {
|
|
1788
|
+
if (
|
|
1789
|
+
record['settlementStyle'] !== 'cash-on-trade' &&
|
|
1790
|
+
record['settlementStyle'] !== 'variation-margin'
|
|
1791
|
+
) {
|
|
1792
|
+
throw new InputError(
|
|
1793
|
+
`${functionName}: ${label}.settlementStyle must be 'cash-on-trade' | 'variation-margin'. Received ${describeInputValue(record['settlementStyle'])}.`,
|
|
1794
|
+
{
|
|
1795
|
+
code: ErrorCode.InputInvalidEnum,
|
|
1796
|
+
context: { function: functionName, field: `${label}.settlementStyle` },
|
|
1797
|
+
},
|
|
1798
|
+
);
|
|
1799
|
+
}
|
|
1800
|
+
}
|
|
1801
|
+
if (hasOwnKey(record, 'contract')) {
|
|
1802
|
+
requirePlainDataObject(functionName, `${label}.contract`, record['contract']);
|
|
1803
|
+
if (!hasOwnKey(record, 'contractMultiplier')) {
|
|
1804
|
+
throw new InputError(
|
|
1805
|
+
`${functionName}: ${label}.contract is given but ${label}.contractMultiplier is not — a derivative fill states its multiplier (an equity option's 100, a futures contract size); the ledger never assumes one.`,
|
|
1806
|
+
{
|
|
1807
|
+
code: ErrorCode.InputMissingField,
|
|
1808
|
+
context: { function: functionName, field: `${label}.contractMultiplier` },
|
|
1809
|
+
},
|
|
1810
|
+
);
|
|
1811
|
+
}
|
|
1812
|
+
}
|
|
1813
|
+
if (hasOwnKey(record, 'accruedInterest')) {
|
|
1814
|
+
requireFiniteNumberField(functionName, `${label}.accruedInterest`, record['accruedInterest']);
|
|
1815
|
+
}
|
|
1816
|
+
if (hasOwnKey(record, 'costs')) {
|
|
1817
|
+
requirePlainDataObject(functionName, `${label}.costs`, record['costs']);
|
|
1818
|
+
const costs = record['costs'] as Record<string, unknown>;
|
|
1819
|
+
requireNoInheritedFields(functionName, `${label}.costs`, costs, NORMALIZED_FILL_COST_KEYS);
|
|
1820
|
+
ensureKnownKeys(functionName, `${label}.costs`, costs, NORMALIZED_FILL_COST_KEYS);
|
|
1821
|
+
for (const component of NORMALIZED_FILL_COST_KEYS) {
|
|
1822
|
+
if (!hasOwnKey(costs, component)) continue;
|
|
1823
|
+
requireFiniteNumberField(functionName, `${label}.costs.${component}`, costs[component]);
|
|
1824
|
+
if ((costs[component] as number) < 0) {
|
|
1825
|
+
throw new InputError(
|
|
1826
|
+
`${functionName}: ${label}.costs.${component} must be ≥ 0 (a cost the account paid, in ${String(record['currency'])}); a rebate is income, not a negative cost. Received ${String(costs[component])}.`,
|
|
1827
|
+
{
|
|
1828
|
+
code: ErrorCode.InputOutOfRange,
|
|
1829
|
+
context: { function: functionName, field: `${label}.costs.${component}` },
|
|
1830
|
+
},
|
|
1831
|
+
);
|
|
1832
|
+
}
|
|
1833
|
+
}
|
|
1834
|
+
}
|
|
1835
|
+
if (hasOwnKey(record, 'executionPriceAdjustment')) {
|
|
1836
|
+
requireFiniteNumberField(
|
|
1837
|
+
functionName,
|
|
1838
|
+
`${label}.executionPriceAdjustment`,
|
|
1839
|
+
record['executionPriceAdjustment'],
|
|
1840
|
+
);
|
|
1841
|
+
if ((record['executionPriceAdjustment'] as number) < 0)
|
|
1842
|
+
throw new InputError(
|
|
1843
|
+
`${functionName}: ${label}.executionPriceAdjustment must be non-negative; it reports the absolute price deviation already embedded in the fill.`,
|
|
1844
|
+
{
|
|
1845
|
+
code: ErrorCode.InputOutOfRange,
|
|
1846
|
+
context: { function: functionName, field: `${label}.executionPriceAdjustment` },
|
|
1847
|
+
},
|
|
1848
|
+
);
|
|
1849
|
+
}
|
|
1850
|
+
if (hasOwnKey(record, 'orderId')) {
|
|
1851
|
+
requireIdentityString(functionName, `${label}.orderId`, record['orderId']);
|
|
1852
|
+
}
|
|
1853
|
+
if (hasOwnKey(record, 'venue')) {
|
|
1854
|
+
requireIdentityString(functionName, `${label}.venue`, record['venue']);
|
|
1855
|
+
}
|
|
1856
|
+
if (hasOwnKey(record, 'liquidity')) {
|
|
1857
|
+
const liquidity = record['liquidity'];
|
|
1858
|
+
if (liquidity !== 'maker' && liquidity !== 'taker' && liquidity !== 'unknown') {
|
|
1859
|
+
throw new InputError(
|
|
1860
|
+
`${functionName}: ${label}.liquidity must be 'maker' | 'taker' | 'unknown'. Received ${describeInputValue(liquidity)}.`,
|
|
1861
|
+
{
|
|
1862
|
+
code: ErrorCode.InputInvalidEnum,
|
|
1863
|
+
context: { function: functionName, field: `${label}.liquidity` },
|
|
1864
|
+
},
|
|
1865
|
+
);
|
|
1866
|
+
}
|
|
1867
|
+
}
|
|
1868
|
+
}
|
|
1869
|
+
|
|
1870
|
+
/** Input for {@link portfolioEventsFromFill}. */
|
|
1871
|
+
export interface PortfolioEventsFromFillInput {
|
|
1872
|
+
fill: NormalizedFill;
|
|
1873
|
+
/** The system that produced the fill — `'backtest:<runId>'`, a broker import id, a paper account. */
|
|
1874
|
+
sourceId: string;
|
|
1875
|
+
/** When the events are recorded — supplied, never read from a clock. */
|
|
1876
|
+
recordedTimestampMs: EpochMs;
|
|
1877
|
+
/** Where the fill came from; `{}` when there is no further detail. Outside the event identity. */
|
|
1878
|
+
provenance?: Provenance;
|
|
1879
|
+
}
|
|
1880
|
+
|
|
1881
|
+
const EVENTS_FROM_FILL_KEYS = ['fill', 'sourceId', 'recordedTimestampMs', 'provenance'] as const;
|
|
1882
|
+
|
|
1883
|
+
/**
|
|
1884
|
+
* Map one {@link NormalizedFill} to the economic events the ledger folds: exactly one `trade.fill`
|
|
1885
|
+
* (id = `fillId`) followed by one `cost.charge` per non-zero cost component (id =
|
|
1886
|
+
* `<fillId>:cost:<component>`, `relatesToEventId` = the fill), in the fixed order commission →
|
|
1887
|
+
* exchange fees → regulatory fees → slippage adjustment. The mapping is deterministic and the ids
|
|
1888
|
+
* are derived from the fill, so an identical fill delivered twice folds once (the ledger's
|
|
1889
|
+
* duplicate boundary) and a replay emits identical envelopes. Every envelope passes the same
|
|
1890
|
+
* validator a hand-written one would.
|
|
1891
|
+
*/
|
|
1892
|
+
export function portfolioEventsFromFill(
|
|
1893
|
+
input: PortfolioEventsFromFillInput,
|
|
1894
|
+
): PortfolioEventEnvelope[] {
|
|
1895
|
+
const functionName = 'portfolioEventsFromFill';
|
|
1896
|
+
requirePlainDataObject(functionName, 'input', input);
|
|
1897
|
+
requireNoInheritedFields(functionName, 'input', input, EVENTS_FROM_FILL_KEYS);
|
|
1898
|
+
ensureKnownKeys(functionName, 'input', input, EVENTS_FROM_FILL_KEYS);
|
|
1899
|
+
const { fill, sourceId, recordedTimestampMs } = input;
|
|
1900
|
+
requireNormalizedFill(functionName, 'input.fill', fill);
|
|
1901
|
+
requireIdentityString(functionName, 'input.sourceId', sourceId);
|
|
1902
|
+
requireEpochMsField(functionName, 'input.recordedTimestampMs', recordedTimestampMs);
|
|
1903
|
+
const provenance: Provenance = hasOwnKey(input, 'provenance')
|
|
1904
|
+
? (input.provenance as Provenance)
|
|
1905
|
+
: {};
|
|
1906
|
+
requireProvenanceShape(functionName, 'input.provenance', provenance);
|
|
1907
|
+
|
|
1908
|
+
const tradeFill: TradeFillEvent = {
|
|
1909
|
+
eventType: 'trade.fill',
|
|
1910
|
+
instrumentId: fill.instrumentId,
|
|
1911
|
+
side: fill.side,
|
|
1912
|
+
quantity: fill.quantity,
|
|
1913
|
+
pricePerUnit: fill.pricePerUnit,
|
|
1914
|
+
currency: fill.currency,
|
|
1915
|
+
...(fill.settleTimestampMs !== undefined ? { settleTimestampMs: fill.settleTimestampMs } : {}),
|
|
1916
|
+
...(fill.contractMultiplier !== undefined
|
|
1917
|
+
? { contractMultiplier: fill.contractMultiplier }
|
|
1918
|
+
: {}),
|
|
1919
|
+
...(fill.settlementStyle !== undefined ? { settlementStyle: fill.settlementStyle } : {}),
|
|
1920
|
+
...(fill.contract !== undefined ? { contract: cloneJson(fill.contract) } : {}),
|
|
1921
|
+
...(fill.accruedInterest !== undefined ? { accruedInterest: fill.accruedInterest } : {}),
|
|
1922
|
+
};
|
|
1923
|
+
const correlation = fill.orderId !== undefined ? { correlationId: fill.orderId } : {};
|
|
1924
|
+
const envelopes: PortfolioEventEnvelope[] = [
|
|
1925
|
+
{
|
|
1926
|
+
eventId: fill.fillId,
|
|
1927
|
+
schemaVersion: PORTFOLIO_EVENT_SCHEMA_VERSION,
|
|
1928
|
+
eventType: 'trade.fill',
|
|
1929
|
+
sourceId,
|
|
1930
|
+
accountId: fill.accountId,
|
|
1931
|
+
effectiveTimestampMs: fill.filledTimestampMs,
|
|
1932
|
+
recordedTimestampMs,
|
|
1933
|
+
...correlation,
|
|
1934
|
+
event: tradeFill,
|
|
1935
|
+
provenance: cloneJson(provenance),
|
|
1936
|
+
},
|
|
1937
|
+
];
|
|
1938
|
+
const costs = fill.costs ?? {};
|
|
1939
|
+
for (const [component, costType] of COST_COMPONENTS) {
|
|
1940
|
+
const amount = costs[component];
|
|
1941
|
+
if (amount === undefined || amount === 0) continue;
|
|
1942
|
+
const charge: CostChargeEvent = {
|
|
1943
|
+
eventType: 'cost.charge',
|
|
1944
|
+
costType,
|
|
1945
|
+
amount,
|
|
1946
|
+
currency: fill.currency,
|
|
1947
|
+
instrumentId: fill.instrumentId,
|
|
1948
|
+
relatesToEventId: fill.fillId,
|
|
1949
|
+
};
|
|
1950
|
+
envelopes.push({
|
|
1951
|
+
eventId: `${fill.fillId}:cost:${component}`,
|
|
1952
|
+
schemaVersion: PORTFOLIO_EVENT_SCHEMA_VERSION,
|
|
1953
|
+
eventType: 'cost.charge',
|
|
1954
|
+
sourceId,
|
|
1955
|
+
accountId: fill.accountId,
|
|
1956
|
+
effectiveTimestampMs: fill.filledTimestampMs,
|
|
1957
|
+
recordedTimestampMs,
|
|
1958
|
+
...correlation,
|
|
1959
|
+
causationId: fill.fillId,
|
|
1960
|
+
event: charge,
|
|
1961
|
+
provenance: cloneJson(provenance),
|
|
1962
|
+
});
|
|
1963
|
+
}
|
|
1964
|
+
envelopes.forEach((envelope, index) =>
|
|
1965
|
+
requirePortfolioEventEnvelope(functionName, `events[${index}]`, envelope),
|
|
1966
|
+
);
|
|
1967
|
+
return envelopes;
|
|
1968
|
+
}
|