@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,2873 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `@insiderfinance/totalfinance/backtest/artifacts` (Stage 4.6, FC8 Decision 8): reproducible run artifacts over the
|
|
3
|
+
* Stage 4.5 grammar — an `AnalysisArtifact` of type `totalfinance.backtest-run` whose `result` is the
|
|
4
|
+
* typed {@link BacktestRunReport}: the run verbatim, the request with bulk row sets embedded or
|
|
5
|
+
* referenced by `TableHandle`, every execution and accounting model recorded by its description,
|
|
6
|
+
* the run's content hash, and the FC8 identity list (strategy and recipe version, dataset identity,
|
|
7
|
+
* universe id and history hash, point-in-time policy, conventions and calendar, engine and model
|
|
8
|
+
* labels/versions, seed, costs, benchmark, annualization). Four verbs: `backtestRunArtifact`,
|
|
9
|
+
* `readBacktestRun`, `replayBacktestRun`, `compareBacktestRuns`. Nothing here computes a number a
|
|
10
|
+
* run did not — the engine is the engine; the artifact is its record.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
import {
|
|
14
|
+
CONVENTIONS_VERSION,
|
|
15
|
+
ErrorCode,
|
|
16
|
+
InputError,
|
|
17
|
+
ensureKnownKeys,
|
|
18
|
+
isQuantError,
|
|
19
|
+
requireArgumentArray,
|
|
20
|
+
requireArgumentObject,
|
|
21
|
+
warning,
|
|
22
|
+
type Provenance,
|
|
23
|
+
type QuantWarning,
|
|
24
|
+
WarningCode,
|
|
25
|
+
} from '@totalfinance/core';
|
|
26
|
+
import {
|
|
27
|
+
ARTIFACT_WORK_LIMITS,
|
|
28
|
+
applyReportMigrations,
|
|
29
|
+
artifactReplayParity,
|
|
30
|
+
canonicalJsonOf,
|
|
31
|
+
contentHash,
|
|
32
|
+
createAnalysisArtifact,
|
|
33
|
+
fromCanonicalJson,
|
|
34
|
+
isTableHandle,
|
|
35
|
+
readAnalysisArtifact,
|
|
36
|
+
requireComparisonTolerance,
|
|
37
|
+
requireWorkLimit,
|
|
38
|
+
scanCanonicalData,
|
|
39
|
+
tableHandleForRows,
|
|
40
|
+
verifyReferencedRows,
|
|
41
|
+
type AnalysisArtifact,
|
|
42
|
+
type AppliedMigration,
|
|
43
|
+
type ArtifactMigrationRegistry,
|
|
44
|
+
type ArtifactReplayParity,
|
|
45
|
+
type ComparisonLimits,
|
|
46
|
+
type ComparisonTolerance,
|
|
47
|
+
type TableHandle,
|
|
48
|
+
} from '@totalfinance/core/artifacts';
|
|
49
|
+
import type { CostModel, SlippageModel } from './costs.js';
|
|
50
|
+
import { crossSectionalBacktest } from './cross-sectional/engine.js';
|
|
51
|
+
import {
|
|
52
|
+
crossSectionalBacktestGrid,
|
|
53
|
+
requireCrossSectionalBacktestGridRequest,
|
|
54
|
+
} from './cross-sectional/grid.js';
|
|
55
|
+
import type {
|
|
56
|
+
CrossSectionalBacktestGridRequest,
|
|
57
|
+
CrossSectionalBacktestGridResult,
|
|
58
|
+
} from './cross-sectional/grid.js';
|
|
59
|
+
import type {
|
|
60
|
+
CrossSectionalBacktestRequest,
|
|
61
|
+
CrossSectionalBacktestResult,
|
|
62
|
+
} from './cross-sectional/types.js';
|
|
63
|
+
import { requireCrossSectionalBacktestRequest } from './cross-sectional/validate.js';
|
|
64
|
+
import { describeExecutionPolicy, execution as executionPolicies } from './execution/policy.js';
|
|
65
|
+
import { optionsBacktest, requireOptionsBacktestConfig } from './options/engine.js';
|
|
66
|
+
import { portfolioBacktest } from './portfolio/engine.js';
|
|
67
|
+
import { requireEnvironmentEpisodeInput, runEnvironmentEpisode } from './environment/episode.js';
|
|
68
|
+
import type { EnvironmentEpisodeInput, EnvironmentEpisodeResult } from './environment/types.js';
|
|
69
|
+
import type { PortfolioBacktestRequest, PortfolioBacktestResult } from './portfolio/types.js';
|
|
70
|
+
import { requirePortfolioBacktestRequest } from './portfolio/validate.js';
|
|
71
|
+
import type { OptionsBacktestConfig, OptionsBacktestResult } from './options/types.js';
|
|
72
|
+
import type { ExecutionPolicy, ExecutionPolicyDescription } from './execution/types.js';
|
|
73
|
+
|
|
74
|
+
export const BACKTEST_RUN_ARTIFACT_TYPE = 'totalfinance.backtest-run';
|
|
75
|
+
|
|
76
|
+
/** Decision 9's bounded-work table (core's `ARTIFACT_WORK_LIMITS`, re-exported for this subpath's callers). */
|
|
77
|
+
export const BACKTEST_RUN_LIMITS = ARTIFACT_WORK_LIMITS;
|
|
78
|
+
|
|
79
|
+
/** The run kinds this subpath records. */
|
|
80
|
+
export type BacktestRunKind =
|
|
81
|
+
| 'cross-sectional'
|
|
82
|
+
| 'cross-sectional-grid'
|
|
83
|
+
| 'options'
|
|
84
|
+
| 'portfolio'
|
|
85
|
+
| 'environment';
|
|
86
|
+
|
|
87
|
+
export interface BacktestRunInputs {
|
|
88
|
+
'cross-sectional': CrossSectionalBacktestRequest;
|
|
89
|
+
'cross-sectional-grid': CrossSectionalBacktestGridRequest;
|
|
90
|
+
options: OptionsBacktestConfig;
|
|
91
|
+
portfolio: PortfolioBacktestRequest;
|
|
92
|
+
environment: EnvironmentEpisodeInput;
|
|
93
|
+
}
|
|
94
|
+
export interface BacktestRunResults {
|
|
95
|
+
'cross-sectional': CrossSectionalBacktestResult;
|
|
96
|
+
'cross-sectional-grid': CrossSectionalBacktestGridResult;
|
|
97
|
+
options: OptionsBacktestResult;
|
|
98
|
+
portfolio: PortfolioBacktestResult;
|
|
99
|
+
environment: EnvironmentEpisodeResult;
|
|
100
|
+
}
|
|
101
|
+
export type InputOf<K extends BacktestRunKind> = BacktestRunInputs[K];
|
|
102
|
+
export type RunOf<K extends BacktestRunKind> = BacktestRunResults[K];
|
|
103
|
+
|
|
104
|
+
/** The frozen, data-only description of one run kind. */
|
|
105
|
+
export interface BacktestRunKindDescriptor {
|
|
106
|
+
kind: BacktestRunKind;
|
|
107
|
+
runVersion: number;
|
|
108
|
+
/** The direct verb the run re-issues on replay. */
|
|
109
|
+
operation: string;
|
|
110
|
+
/** Bulk row sets of the request (dotted paths); each may be embedded or referenced by table handle. */
|
|
111
|
+
inputRowSets: readonly string[];
|
|
112
|
+
/** Bulk row sets of the run (dotted paths under `run.`); each may be embedded or referenced. */
|
|
113
|
+
resultRowSets: readonly string[];
|
|
114
|
+
/** Request fields that, when they carry a caller function, make the run non-replayable. */
|
|
115
|
+
callbackFields: readonly string[];
|
|
116
|
+
/** Request fields recorded by description (execution policy, cost models); replay takes them back as `models`. */
|
|
117
|
+
modelFields: readonly string[];
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
export interface BacktestRunArtifactLimits {
|
|
121
|
+
maximumEmbeddedBytes?: number;
|
|
122
|
+
embeddedRowLimit?: number;
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** The research-hygiene verdicts a caller attaches to a single run — verbatim `@insiderfinance/totalfinance/risk` results. */
|
|
126
|
+
export interface BacktestHygieneBlock {
|
|
127
|
+
researchProtocol?: Record<string, unknown>;
|
|
128
|
+
deflatedSharpe?: Record<string, unknown>;
|
|
129
|
+
backtestOverfitting?: Record<string, unknown>;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/** The recorded models of a run: descriptions and labels, never functions. */
|
|
133
|
+
export interface RecordedModels {
|
|
134
|
+
execution: ExecutionPolicyDescription | null;
|
|
135
|
+
commission: string | null;
|
|
136
|
+
slippage: string | null;
|
|
137
|
+
}
|
|
138
|
+
|
|
139
|
+
/** The FC8 identity list, read from the run's assumptions and the request — never recomputed. */
|
|
140
|
+
export interface BacktestRunIdentity {
|
|
141
|
+
/** The engine's content-addressed run id (the sweep id for a grid). */
|
|
142
|
+
runId: string;
|
|
143
|
+
/** Every child run id, in variation order (grids only). */
|
|
144
|
+
childRunIds: string[] | null;
|
|
145
|
+
universeId: string;
|
|
146
|
+
/** Content hash of the universe history's member rows. */
|
|
147
|
+
universeHistoryHash: string;
|
|
148
|
+
/** The signal as the engine disclosed it (`assumptions.signal`). */
|
|
149
|
+
strategy: Record<string, unknown>;
|
|
150
|
+
recipe: { recipeName: string; recipeVersion: number } | null;
|
|
151
|
+
pointInTimePolicy: string;
|
|
152
|
+
conventions: {
|
|
153
|
+
conventionsVersion: string;
|
|
154
|
+
sessionInstantConvention: string;
|
|
155
|
+
pricing: string;
|
|
156
|
+
};
|
|
157
|
+
calendar: {
|
|
158
|
+
sessions: number;
|
|
159
|
+
firstMarkTimestampMs: number | null;
|
|
160
|
+
lastMarkTimestampMs: number | null;
|
|
161
|
+
};
|
|
162
|
+
engine: { operation: string; runVersion: number };
|
|
163
|
+
models: RecordedModels;
|
|
164
|
+
seed: number | null;
|
|
165
|
+
benchmark: boolean;
|
|
166
|
+
annualization: { periodsPerYear: number; riskFreeRate: number };
|
|
167
|
+
initialCapital: number;
|
|
168
|
+
baseCurrency: string;
|
|
169
|
+
/** The grid's axes (grids only). */
|
|
170
|
+
variations: Array<{ path: string; values: unknown[] }> | null;
|
|
171
|
+
}
|
|
172
|
+
|
|
173
|
+
/** The typed report every verb reads and writes — the artifact's `result`, verbatim. */
|
|
174
|
+
export type BacktestRunReport<Kind extends BacktestRunKind = BacktestRunKind> = Readonly<
|
|
175
|
+
Record<string, unknown>
|
|
176
|
+
> & {
|
|
177
|
+
kind: Kind;
|
|
178
|
+
runVersion: number;
|
|
179
|
+
/** The verb's result verbatim, with referenced result row sets replaced by their table handles. */
|
|
180
|
+
run: Record<string, unknown>;
|
|
181
|
+
/** The request with bulk row sets embedded or referenced, callbacks omitted, models by description. */
|
|
182
|
+
inputs: Record<string, unknown>;
|
|
183
|
+
/** Table references for every row set that was not embedded, keyed by label (`dataset.returns`, `run.holdings`). */
|
|
184
|
+
referencedData: Record<string, TableHandle>;
|
|
185
|
+
/** `contentHash` of the stored run (the projection above) — the run's identity. */
|
|
186
|
+
runHash: string;
|
|
187
|
+
identity: BacktestRunIdentity;
|
|
188
|
+
/** The caller's hygiene block (single runs) or the grid's own verdicts (grids), verbatim. */
|
|
189
|
+
hygiene: BacktestHygieneBlock | null;
|
|
190
|
+
/** Reserved (Decision 8): a cooperative checkpoint/resume lands in Stage 7B without changing the format. */
|
|
191
|
+
execution: { completed: true };
|
|
192
|
+
assumptions: {
|
|
193
|
+
conventionsVersion: string;
|
|
194
|
+
kind: Kind;
|
|
195
|
+
runVersion: number;
|
|
196
|
+
operation: string;
|
|
197
|
+
/** `false` exactly when a caller function participated. */
|
|
198
|
+
replayable: boolean;
|
|
199
|
+
nonReplayableField: string | null;
|
|
200
|
+
inputPolicy: 'embedded' | 'referenced';
|
|
201
|
+
embeddedRowLimit: number;
|
|
202
|
+
modelPolicy: string;
|
|
203
|
+
projection: string;
|
|
204
|
+
};
|
|
205
|
+
diagnostics: {
|
|
206
|
+
warnings: QuantWarning[];
|
|
207
|
+
embeddedRows: number;
|
|
208
|
+
referencedRows: number;
|
|
209
|
+
runWarningCount: number;
|
|
210
|
+
};
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
export interface BacktestRunArtifactInput<Kind extends BacktestRunKind> {
|
|
214
|
+
kind: Kind;
|
|
215
|
+
/** The verb's result, verbatim. */
|
|
216
|
+
run: RunOf<Kind>;
|
|
217
|
+
/** The request as it was called — rows included; callbacks recorded and not stored; models recorded by description. */
|
|
218
|
+
input: InputOf<Kind>;
|
|
219
|
+
/** Row-set labels (`dataset.returns`, `run.holdings`, `run.ledger.events`) to store by `TableHandle` instead of embedding. */
|
|
220
|
+
referenceRowSets?: readonly string[];
|
|
221
|
+
/** Storage locators to stamp on the minted handles, keyed by row-set label. */
|
|
222
|
+
locators?: Record<string, string>;
|
|
223
|
+
/** Verbatim `@insiderfinance/totalfinance/risk` verdicts for a single run; a grid carries its own and refuses this. */
|
|
224
|
+
hygiene?: BacktestHygieneBlock;
|
|
225
|
+
snapshotHash?: string;
|
|
226
|
+
libraryVersion?: string;
|
|
227
|
+
createdFrom?: string[];
|
|
228
|
+
provenance?: Provenance;
|
|
229
|
+
limits?: BacktestRunArtifactLimits;
|
|
230
|
+
}
|
|
231
|
+
|
|
232
|
+
export interface ReadBacktestRunResult<Kind extends BacktestRunKind = BacktestRunKind> {
|
|
233
|
+
report: BacktestRunReport<Kind>;
|
|
234
|
+
artifact: AnalysisArtifact;
|
|
235
|
+
migrationsApplied: AppliedMigration[];
|
|
236
|
+
modelMigrationsApplied: AppliedMigration[];
|
|
237
|
+
/** Labels whose referenced rows were supplied, verified by hash, and restored into `report`. */
|
|
238
|
+
restoredRowSets: string[];
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
/** The models a replay takes back, each verified against the recorded description before the run. */
|
|
242
|
+
export interface ReplayModels {
|
|
243
|
+
execution?: ExecutionPolicy;
|
|
244
|
+
transactionCostModel?: { commission?: CostModel; slippage?: SlippageModel };
|
|
245
|
+
/** The options kind's labeled models, keyed by their request path (`commission`, `slippage`, `hedge.commission`, `hedge.slippage`). */
|
|
246
|
+
labeled?: Record<string, CostModel | SlippageModel>;
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
export interface BacktestRunReplay<Kind extends BacktestRunKind = BacktestRunKind> {
|
|
250
|
+
kind: Kind;
|
|
251
|
+
artifactId: string;
|
|
252
|
+
/** The recomputed report (the same projection as the saved one). */
|
|
253
|
+
recomputed: BacktestRunReport<Kind>;
|
|
254
|
+
runHash: { saved: string; recomputed: string };
|
|
255
|
+
/** `true` exactly when the recomputed run hash equals the saved one. */
|
|
256
|
+
matches: boolean;
|
|
257
|
+
parity: ArtifactReplayParity;
|
|
258
|
+
assumptions: {
|
|
259
|
+
conventionsVersion: string;
|
|
260
|
+
kind: Kind;
|
|
261
|
+
runVersion: number;
|
|
262
|
+
operation: string;
|
|
263
|
+
libraryVersion: { saved: string | null; current: string | null };
|
|
264
|
+
referencedRowSets: string[];
|
|
265
|
+
models: {
|
|
266
|
+
execution: 'recorded-default' | 'supplied' | 'none';
|
|
267
|
+
transactionCostModel: 'supplied' | 'none';
|
|
268
|
+
};
|
|
269
|
+
};
|
|
270
|
+
diagnostics: { warnings: QuantWarning[] };
|
|
271
|
+
}
|
|
272
|
+
|
|
273
|
+
export interface IdListSection {
|
|
274
|
+
count: number;
|
|
275
|
+
ids: string[];
|
|
276
|
+
remainderCount: number;
|
|
277
|
+
}
|
|
278
|
+
export interface MembershipSection {
|
|
279
|
+
entered: IdListSection;
|
|
280
|
+
exited: IdListSection;
|
|
281
|
+
kept: IdListSection;
|
|
282
|
+
}
|
|
283
|
+
export interface NamedDelta {
|
|
284
|
+
name: string;
|
|
285
|
+
baselineValue: number | null;
|
|
286
|
+
candidateValue: number | null;
|
|
287
|
+
absoluteDelta: number | null;
|
|
288
|
+
/** Under an explicit tolerance: whether the delta is within it; `null` without one. */
|
|
289
|
+
withinTolerance: boolean | null;
|
|
290
|
+
}
|
|
291
|
+
export interface RebalanceDelta {
|
|
292
|
+
rebalanceIndex: number;
|
|
293
|
+
sessionDate: { baseline: string; candidate: string };
|
|
294
|
+
turnover: { baseline: number; candidate: number; absoluteDelta: number };
|
|
295
|
+
costs: { baseline: number; candidate: number; absoluteDelta: number };
|
|
296
|
+
longCount: { baseline: number; candidate: number };
|
|
297
|
+
shortCount: { baseline: number; candidate: number };
|
|
298
|
+
}
|
|
299
|
+
export interface VariationDelta {
|
|
300
|
+
parameters: Record<string, unknown>;
|
|
301
|
+
metric: string;
|
|
302
|
+
baselineValue: number | null;
|
|
303
|
+
candidateValue: number | null;
|
|
304
|
+
absoluteDelta: number | null;
|
|
305
|
+
}
|
|
306
|
+
|
|
307
|
+
export interface BacktestRunComparison<Kind extends BacktestRunKind = BacktestRunKind> {
|
|
308
|
+
kind: Kind;
|
|
309
|
+
artifactIds: { baseline: string | null; candidate: string | null };
|
|
310
|
+
runHashes: { baseline: string; candidate: string };
|
|
311
|
+
identical: boolean;
|
|
312
|
+
sameInputs: boolean;
|
|
313
|
+
sameUniverse: boolean;
|
|
314
|
+
sameStrategy: boolean;
|
|
315
|
+
sameModels: boolean;
|
|
316
|
+
sameConventions: boolean;
|
|
317
|
+
/** The performance block and the run-level totals, name by name. */
|
|
318
|
+
metrics: NamedDelta[];
|
|
319
|
+
/** Final-holding membership (names held at the last rebalance) — single runs only. */
|
|
320
|
+
holdings: MembershipSection | null;
|
|
321
|
+
/** Rebalance-by-rebalance turnover and cost deltas over the shared index range, listed up to `listedIds`. */
|
|
322
|
+
rebalances: { compared: number; rows: RebalanceDelta[]; remainderCount: number } | null;
|
|
323
|
+
/** Per-variation deltas of the grid's selection metric, matched by parameters — grids only. */
|
|
324
|
+
variations: {
|
|
325
|
+
matched: number;
|
|
326
|
+
baselineOnly: number;
|
|
327
|
+
candidateOnly: number;
|
|
328
|
+
rows: VariationDelta[];
|
|
329
|
+
remainderCount: number;
|
|
330
|
+
best: { baseline: number | null; candidate: number | null; moved: boolean };
|
|
331
|
+
} | null;
|
|
332
|
+
hygiene: { baseline: string | null; candidate: string | null; changed: boolean } | null;
|
|
333
|
+
/** The structural diff of the two stored runs through the parity walk. */
|
|
334
|
+
run: {
|
|
335
|
+
differenceCount: number;
|
|
336
|
+
retainedDifferences: number;
|
|
337
|
+
addedPaths: string[];
|
|
338
|
+
removedPaths: string[];
|
|
339
|
+
truncated: boolean;
|
|
340
|
+
};
|
|
341
|
+
/** Under an explicit tolerance: every metric within it; `null` without one. */
|
|
342
|
+
withinTolerance: boolean | null;
|
|
343
|
+
assumptions: {
|
|
344
|
+
conventionsVersion: string;
|
|
345
|
+
kind: Kind;
|
|
346
|
+
tolerance: ComparisonTolerance | null;
|
|
347
|
+
limits: { maximumDifferences: number; maximumLeaves: number; listedIds: number };
|
|
348
|
+
};
|
|
349
|
+
diagnostics: { warnings: QuantWarning[] };
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
// ─────────────────────────────────────────── kinds ──────────────────────────────────────────────
|
|
353
|
+
|
|
354
|
+
type Path = readonly string[];
|
|
355
|
+
interface RowSetSpec {
|
|
356
|
+
readonly label: string;
|
|
357
|
+
readonly path: Path;
|
|
358
|
+
}
|
|
359
|
+
interface CallbackSpec {
|
|
360
|
+
readonly field: string;
|
|
361
|
+
readonly path: Path;
|
|
362
|
+
/** The stored form: the function removed, a marker kept so a reader knows what was there. */
|
|
363
|
+
readonly strip: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
364
|
+
}
|
|
365
|
+
interface KindSpec<K extends BacktestRunKind> {
|
|
366
|
+
readonly descriptor: BacktestRunKindDescriptor;
|
|
367
|
+
readonly inputRowSets: readonly RowSetSpec[];
|
|
368
|
+
readonly resultRowSets: readonly RowSetSpec[];
|
|
369
|
+
readonly callbacks: readonly CallbackSpec[];
|
|
370
|
+
/** Where the request's `execution` and `transactionCostModel` live (the cross-sectional kinds). */
|
|
371
|
+
readonly modelRoot: Path;
|
|
372
|
+
/** Labeled cost models recorded by label (the options kind): dotted paths in the request. */
|
|
373
|
+
readonly labeledModels: readonly string[];
|
|
374
|
+
/** Callback-bearing members that a fixed path cannot name (an entry array's rules). */
|
|
375
|
+
readonly dynamicCallbacks: (record: Record<string, unknown>) => Array<{
|
|
376
|
+
field: string;
|
|
377
|
+
strip: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
378
|
+
}>;
|
|
379
|
+
readonly runKeys: readonly string[];
|
|
380
|
+
/** The verb's own closed request guard — the stored request must be one the verb accepts. */
|
|
381
|
+
readonly requireInput: (functionName: string, label: string, value: unknown) => void;
|
|
382
|
+
readonly run: (input: InputOf<K>) => RunOf<K>;
|
|
383
|
+
readonly identity: (run: RunOf<K>, storedInput: Record<string, unknown>) => BacktestRunIdentity;
|
|
384
|
+
}
|
|
385
|
+
|
|
386
|
+
const rowSet = (label: string): RowSetSpec => ({ label, path: label.split('.') });
|
|
387
|
+
const resultRowSet = (label: string): RowSetSpec => ({
|
|
388
|
+
label: `run.${label}`,
|
|
389
|
+
path: label.split('.'),
|
|
390
|
+
});
|
|
391
|
+
|
|
392
|
+
const CROSS_SECTIONAL_INPUT_ROW_SETS = [
|
|
393
|
+
'dataset.observations',
|
|
394
|
+
'dataset.returns',
|
|
395
|
+
'dataset.benchmarkReturns',
|
|
396
|
+
'universeHistory.members',
|
|
397
|
+
] as const;
|
|
398
|
+
const CROSS_SECTIONAL_RESULT_ROW_SETS = [
|
|
399
|
+
'rebalances',
|
|
400
|
+
'holdings',
|
|
401
|
+
'points',
|
|
402
|
+
'returns',
|
|
403
|
+
'trades',
|
|
404
|
+
'fills',
|
|
405
|
+
'ledger.events',
|
|
406
|
+
'timeline.rows',
|
|
407
|
+
'attribution.perRebalance',
|
|
408
|
+
] as const;
|
|
409
|
+
const CROSS_SECTIONAL_RUN_KEYS = [
|
|
410
|
+
'rebalances',
|
|
411
|
+
'holdings',
|
|
412
|
+
'points',
|
|
413
|
+
'returns',
|
|
414
|
+
'trades',
|
|
415
|
+
'fills',
|
|
416
|
+
'ledger',
|
|
417
|
+
'timeline',
|
|
418
|
+
'attribution',
|
|
419
|
+
'benchmark',
|
|
420
|
+
'performance',
|
|
421
|
+
'performanceConfidence',
|
|
422
|
+
'finalValue',
|
|
423
|
+
'runId',
|
|
424
|
+
'assumptions',
|
|
425
|
+
'diagnostics',
|
|
426
|
+
] as const;
|
|
427
|
+
const GRID_RUN_KEYS = [
|
|
428
|
+
'sweepId',
|
|
429
|
+
'variations',
|
|
430
|
+
'runs',
|
|
431
|
+
'best',
|
|
432
|
+
'hygiene',
|
|
433
|
+
'assumptions',
|
|
434
|
+
'diagnostics',
|
|
435
|
+
] as const;
|
|
436
|
+
|
|
437
|
+
function callbackAt(
|
|
438
|
+
field: string,
|
|
439
|
+
marker: (record: Record<string, unknown>) => Record<string, unknown>,
|
|
440
|
+
): CallbackSpec {
|
|
441
|
+
const path = field.split('.');
|
|
442
|
+
return { field, path, strip: marker };
|
|
443
|
+
}
|
|
444
|
+
|
|
445
|
+
const SIGNAL_CALLBACK = (prefix: Path): CallbackSpec =>
|
|
446
|
+
callbackAt(
|
|
447
|
+
[...prefix, 'signal', 'callback'].join('.'),
|
|
448
|
+
(record) =>
|
|
449
|
+
withPath(record, [...prefix, 'signal'], {
|
|
450
|
+
callback: '[caller function — not stored]',
|
|
451
|
+
}) as Record<string, unknown>,
|
|
452
|
+
);
|
|
453
|
+
const SUPPLIED_WEIGHTS_CALLBACK = (prefix: Path): CallbackSpec =>
|
|
454
|
+
callbackAt([...prefix, 'portfolioConstruction', 'suppliedWeights'].join('.'), (record) => {
|
|
455
|
+
const construction = {
|
|
456
|
+
...(readPath(record, [...prefix, 'portfolioConstruction']) as Record<string, unknown>),
|
|
457
|
+
};
|
|
458
|
+
delete construction['suppliedWeights'];
|
|
459
|
+
return withPath(record, [...prefix, 'portfolioConstruction'], construction) as Record<
|
|
460
|
+
string,
|
|
461
|
+
unknown
|
|
462
|
+
>;
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
function crossSectionalIdentity(
|
|
466
|
+
run: CrossSectionalBacktestResult,
|
|
467
|
+
storedInput: Record<string, unknown>,
|
|
468
|
+
extra: {
|
|
469
|
+
runId: string;
|
|
470
|
+
childRunIds: string[] | null;
|
|
471
|
+
variations: BacktestRunIdentity['variations'];
|
|
472
|
+
operation: string;
|
|
473
|
+
runVersion: number;
|
|
474
|
+
},
|
|
475
|
+
requestRoot: Path,
|
|
476
|
+
): BacktestRunIdentity {
|
|
477
|
+
const assumptions = run.assumptions;
|
|
478
|
+
const members = readPath(storedInput, [...requestRoot, 'universeHistory', 'members']);
|
|
479
|
+
const models = readPath(storedInput, requestRoot) as Record<string, unknown>;
|
|
480
|
+
const costs = (models['transactionCostModel'] ?? null) as {
|
|
481
|
+
commission?: string;
|
|
482
|
+
slippage?: string;
|
|
483
|
+
} | null;
|
|
484
|
+
const signal = assumptions.signal as unknown as Record<string, unknown>;
|
|
485
|
+
return {
|
|
486
|
+
runId: extra.runId,
|
|
487
|
+
childRunIds: extra.childRunIds,
|
|
488
|
+
universeId: assumptions.universeId,
|
|
489
|
+
universeHistoryHash: isTableHandle(members) ? members.contentHash : contentHash(members),
|
|
490
|
+
strategy: { ...signal },
|
|
491
|
+
recipe:
|
|
492
|
+
signal['kind'] === 'factor-recipe'
|
|
493
|
+
? {
|
|
494
|
+
recipeName: String(signal['recipeName']),
|
|
495
|
+
recipeVersion: Number(signal['recipeVersion']),
|
|
496
|
+
}
|
|
497
|
+
: null,
|
|
498
|
+
pointInTimePolicy:
|
|
499
|
+
'a feature is visible to a decision instant only when availableTimestampMs ≤ the instant; a recipe lag counts trading sessions through the session index; universe membership is read at the instant',
|
|
500
|
+
conventions: {
|
|
501
|
+
conventionsVersion: assumptions.conventionsVersion,
|
|
502
|
+
sessionInstantConvention: assumptions.sessionInstantConvention,
|
|
503
|
+
pricing: assumptions.pricing,
|
|
504
|
+
},
|
|
505
|
+
calendar: {
|
|
506
|
+
sessions: run.diagnostics.sessionCount,
|
|
507
|
+
firstMarkTimestampMs: run.points.length > 0 ? run.points[0]!.timestampMs : null,
|
|
508
|
+
lastMarkTimestampMs:
|
|
509
|
+
run.points.length > 0 ? run.points[run.points.length - 1]!.timestampMs : null,
|
|
510
|
+
},
|
|
511
|
+
engine: { operation: extra.operation, runVersion: extra.runVersion },
|
|
512
|
+
models: {
|
|
513
|
+
execution: (models['execution'] as ExecutionPolicyDescription | undefined) ?? null,
|
|
514
|
+
commission: costs?.commission ?? null,
|
|
515
|
+
slippage: costs?.slippage ?? null,
|
|
516
|
+
},
|
|
517
|
+
seed: assumptions.seed,
|
|
518
|
+
benchmark: run.benchmark !== null,
|
|
519
|
+
annualization: {
|
|
520
|
+
periodsPerYear: assumptions.periodsPerYear,
|
|
521
|
+
riskFreeRate: assumptions.riskFreeRate,
|
|
522
|
+
},
|
|
523
|
+
initialCapital: assumptions.initialCapital,
|
|
524
|
+
baseCurrency: assumptions.baseCurrency,
|
|
525
|
+
variations: extra.variations,
|
|
526
|
+
};
|
|
527
|
+
}
|
|
528
|
+
|
|
529
|
+
const CROSS_SECTIONAL_SPEC: KindSpec<'cross-sectional'> = {
|
|
530
|
+
descriptor: Object.freeze({
|
|
531
|
+
kind: 'cross-sectional',
|
|
532
|
+
runVersion: 1,
|
|
533
|
+
operation: 'crossSectionalBacktest',
|
|
534
|
+
inputRowSets: CROSS_SECTIONAL_INPUT_ROW_SETS,
|
|
535
|
+
resultRowSets: CROSS_SECTIONAL_RESULT_ROW_SETS.map((label) => `run.${label}`),
|
|
536
|
+
callbackFields: ['signal.callback', 'portfolioConstruction.suppliedWeights'],
|
|
537
|
+
modelFields: ['execution', 'transactionCostModel'],
|
|
538
|
+
}),
|
|
539
|
+
inputRowSets: CROSS_SECTIONAL_INPUT_ROW_SETS.map(rowSet),
|
|
540
|
+
resultRowSets: CROSS_SECTIONAL_RESULT_ROW_SETS.map(resultRowSet),
|
|
541
|
+
callbacks: [SIGNAL_CALLBACK([]), SUPPLIED_WEIGHTS_CALLBACK([])],
|
|
542
|
+
modelRoot: [],
|
|
543
|
+
labeledModels: [],
|
|
544
|
+
dynamicCallbacks: () => [],
|
|
545
|
+
runKeys: CROSS_SECTIONAL_RUN_KEYS,
|
|
546
|
+
requireInput: (functionName, label, value) => {
|
|
547
|
+
requireCrossSectionalBacktestRequest(functionName, label, value);
|
|
548
|
+
},
|
|
549
|
+
run: crossSectionalBacktest,
|
|
550
|
+
identity: (run, storedInput) =>
|
|
551
|
+
crossSectionalIdentity(
|
|
552
|
+
run,
|
|
553
|
+
storedInput,
|
|
554
|
+
{
|
|
555
|
+
runId: run.runId,
|
|
556
|
+
childRunIds: null,
|
|
557
|
+
variations: null,
|
|
558
|
+
operation: 'crossSectionalBacktest',
|
|
559
|
+
runVersion: 1,
|
|
560
|
+
},
|
|
561
|
+
[],
|
|
562
|
+
),
|
|
563
|
+
};
|
|
564
|
+
|
|
565
|
+
const GRID_SPEC: KindSpec<'cross-sectional-grid'> = {
|
|
566
|
+
descriptor: Object.freeze({
|
|
567
|
+
kind: 'cross-sectional-grid',
|
|
568
|
+
runVersion: 1,
|
|
569
|
+
operation: 'crossSectionalBacktestGrid',
|
|
570
|
+
inputRowSets: CROSS_SECTIONAL_INPUT_ROW_SETS.map((label) => `request.${label}`),
|
|
571
|
+
resultRowSets: ['run.runs', 'run.variations'],
|
|
572
|
+
callbackFields: ['request.signal.callback', 'request.portfolioConstruction.suppliedWeights'],
|
|
573
|
+
modelFields: ['request.execution', 'request.transactionCostModel'],
|
|
574
|
+
}),
|
|
575
|
+
inputRowSets: CROSS_SECTIONAL_INPUT_ROW_SETS.map((label) => rowSet(`request.${label}`)),
|
|
576
|
+
resultRowSets: [resultRowSet('runs'), resultRowSet('variations')],
|
|
577
|
+
callbacks: [SIGNAL_CALLBACK(['request']), SUPPLIED_WEIGHTS_CALLBACK(['request'])],
|
|
578
|
+
modelRoot: ['request'],
|
|
579
|
+
labeledModels: [],
|
|
580
|
+
dynamicCallbacks: () => [],
|
|
581
|
+
runKeys: GRID_RUN_KEYS,
|
|
582
|
+
requireInput: (functionName, label, value) => {
|
|
583
|
+
requireCrossSectionalBacktestGridRequest(functionName, label, value);
|
|
584
|
+
},
|
|
585
|
+
run: crossSectionalBacktestGrid,
|
|
586
|
+
identity: (run, storedInput) => {
|
|
587
|
+
const child = run.runs[0];
|
|
588
|
+
if (child === undefined) {
|
|
589
|
+
fail(
|
|
590
|
+
'backtestRunArtifact',
|
|
591
|
+
'run.runs is empty — a grid always holds at least one child run.',
|
|
592
|
+
ErrorCode.InputOutOfRange,
|
|
593
|
+
{ field: 'run.runs' },
|
|
594
|
+
);
|
|
595
|
+
}
|
|
596
|
+
const variations = (
|
|
597
|
+
readPath(storedInput, ['variations']) as Array<{ path: string; values: unknown[] }>
|
|
598
|
+
).map((axis) => ({ path: axis.path, values: [...axis.values] }));
|
|
599
|
+
return crossSectionalIdentity(
|
|
600
|
+
child,
|
|
601
|
+
storedInput,
|
|
602
|
+
{
|
|
603
|
+
runId: run.sweepId,
|
|
604
|
+
childRunIds: run.variations.map((row) => row.runId),
|
|
605
|
+
variations,
|
|
606
|
+
operation: 'crossSectionalBacktestGrid',
|
|
607
|
+
runVersion: 1,
|
|
608
|
+
},
|
|
609
|
+
['request'],
|
|
610
|
+
);
|
|
611
|
+
},
|
|
612
|
+
};
|
|
613
|
+
|
|
614
|
+
const OPTIONS_INPUT_ROW_SETS = ['chains', 'corporateActions', 'dividends'] as const;
|
|
615
|
+
const OPTIONS_RESULT_ROW_SETS = [
|
|
616
|
+
'points',
|
|
617
|
+
'returns',
|
|
618
|
+
'trades',
|
|
619
|
+
'settlements',
|
|
620
|
+
'fills',
|
|
621
|
+
'limitRejections',
|
|
622
|
+
'fillRejections',
|
|
623
|
+
'surface',
|
|
624
|
+
'ledger.events',
|
|
625
|
+
'timeline.rows',
|
|
626
|
+
] as const;
|
|
627
|
+
const OPTIONS_RUN_KEYS = [
|
|
628
|
+
'points',
|
|
629
|
+
'returns',
|
|
630
|
+
'trades',
|
|
631
|
+
'settlements',
|
|
632
|
+
'fills',
|
|
633
|
+
'finalValue',
|
|
634
|
+
'performance',
|
|
635
|
+
'limitRejections',
|
|
636
|
+
'fillRejections',
|
|
637
|
+
'surface',
|
|
638
|
+
'ledger',
|
|
639
|
+
'timeline',
|
|
640
|
+
'runId',
|
|
641
|
+
'assumptions',
|
|
642
|
+
'diagnostics',
|
|
643
|
+
] as const;
|
|
644
|
+
|
|
645
|
+
/** The options request's callback-bearing members: every rule's `build` / function `when`, `exit.when`, `roll.when.when`. */
|
|
646
|
+
function optionsCallbacks(record: Record<string, unknown>): Array<{
|
|
647
|
+
field: string;
|
|
648
|
+
strip: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
649
|
+
}> {
|
|
650
|
+
const found: Array<{
|
|
651
|
+
field: string;
|
|
652
|
+
strip: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
653
|
+
}> = [];
|
|
654
|
+
const isBook = Array.isArray(record['rules']);
|
|
655
|
+
const rules: unknown[] = isBook ? [...(record['rules'] as unknown[])] : [record['entry']];
|
|
656
|
+
const marker = '[caller function — not stored]';
|
|
657
|
+
rules.forEach((rule, index) => {
|
|
658
|
+
if (rule === null || typeof rule !== 'object') return;
|
|
659
|
+
const r = rule as Record<string, unknown>;
|
|
660
|
+
const at =
|
|
661
|
+
(key: string) =>
|
|
662
|
+
(target: Record<string, unknown>): Record<string, unknown> => {
|
|
663
|
+
if (isBook) {
|
|
664
|
+
const list = [...(target['rules'] as unknown[])];
|
|
665
|
+
list[index] = { ...(list[index] as Record<string, unknown>), [key]: marker };
|
|
666
|
+
return { ...target, rules: list };
|
|
667
|
+
}
|
|
668
|
+
return {
|
|
669
|
+
...target,
|
|
670
|
+
entry: { ...(target['entry'] as Record<string, unknown>), [key]: marker },
|
|
671
|
+
};
|
|
672
|
+
};
|
|
673
|
+
const label = isBook ? `rules[${index}]` : 'entry';
|
|
674
|
+
if (typeof r['build'] === 'function')
|
|
675
|
+
found.push({ field: `${label}.build`, strip: at('build') });
|
|
676
|
+
if (typeof r['when'] === 'function') found.push({ field: `${label}.when`, strip: at('when') });
|
|
677
|
+
});
|
|
678
|
+
const exit = record['exit'] as Record<string, unknown> | undefined;
|
|
679
|
+
if (exit !== null && typeof exit === 'object' && typeof exit['when'] === 'function') {
|
|
680
|
+
found.push({
|
|
681
|
+
field: 'exit.when',
|
|
682
|
+
strip: (target) => ({
|
|
683
|
+
...target,
|
|
684
|
+
exit: { ...(target['exit'] as Record<string, unknown>), when: marker },
|
|
685
|
+
}),
|
|
686
|
+
});
|
|
687
|
+
}
|
|
688
|
+
const roll = record['roll'] as Record<string, unknown> | undefined;
|
|
689
|
+
const rollWhen =
|
|
690
|
+
roll !== null && typeof roll === 'object'
|
|
691
|
+
? (roll['when'] as Record<string, unknown> | undefined)
|
|
692
|
+
: undefined;
|
|
693
|
+
if (rollWhen !== null && typeof rollWhen === 'object' && typeof rollWhen['when'] === 'function') {
|
|
694
|
+
found.push({
|
|
695
|
+
field: 'roll.when.when',
|
|
696
|
+
strip: (target) => ({
|
|
697
|
+
...target,
|
|
698
|
+
roll: {
|
|
699
|
+
...(target['roll'] as Record<string, unknown>),
|
|
700
|
+
when: { ...(rollWhen as Record<string, unknown>), when: marker },
|
|
701
|
+
},
|
|
702
|
+
}),
|
|
703
|
+
});
|
|
704
|
+
}
|
|
705
|
+
return found;
|
|
706
|
+
}
|
|
707
|
+
|
|
708
|
+
const OPTIONS_SPEC: KindSpec<'options'> = {
|
|
709
|
+
descriptor: Object.freeze({
|
|
710
|
+
kind: 'options',
|
|
711
|
+
runVersion: 1,
|
|
712
|
+
operation: 'optionsBacktest',
|
|
713
|
+
inputRowSets: OPTIONS_INPUT_ROW_SETS,
|
|
714
|
+
resultRowSets: OPTIONS_RESULT_ROW_SETS.map((label) => `run.${label}`),
|
|
715
|
+
callbackFields: [
|
|
716
|
+
'entry.build',
|
|
717
|
+
'entry.when',
|
|
718
|
+
'rules[].build',
|
|
719
|
+
'rules[].when',
|
|
720
|
+
'exit.when',
|
|
721
|
+
'roll.when.when',
|
|
722
|
+
],
|
|
723
|
+
modelFields: ['commission', 'slippage', 'hedge.commission', 'hedge.slippage'],
|
|
724
|
+
}),
|
|
725
|
+
inputRowSets: OPTIONS_INPUT_ROW_SETS.map(rowSet),
|
|
726
|
+
resultRowSets: OPTIONS_RESULT_ROW_SETS.map(resultRowSet),
|
|
727
|
+
callbacks: [],
|
|
728
|
+
modelRoot: [],
|
|
729
|
+
labeledModels: ['commission', 'slippage', 'hedge.commission', 'hedge.slippage'],
|
|
730
|
+
dynamicCallbacks: optionsCallbacks,
|
|
731
|
+
runKeys: OPTIONS_RUN_KEYS,
|
|
732
|
+
requireInput: (functionName, label, value) => {
|
|
733
|
+
requireOptionsBacktestConfig(functionName, label, value);
|
|
734
|
+
},
|
|
735
|
+
run: optionsBacktest,
|
|
736
|
+
identity: (run, storedInput) => {
|
|
737
|
+
const assumptions = run.assumptions;
|
|
738
|
+
const chains = readPath(storedInput, ['chains']);
|
|
739
|
+
const underlying = run.trades[0]?.underlying ?? run.settlements[0]?.underlying ?? 'UNDERLYING';
|
|
740
|
+
return {
|
|
741
|
+
runId: run.runId,
|
|
742
|
+
childRunIds: null,
|
|
743
|
+
universeId: underlying,
|
|
744
|
+
universeHistoryHash: isTableHandle(chains) ? chains.contentHash : contentHash(chains),
|
|
745
|
+
strategy: {
|
|
746
|
+
kind: 'options-rules',
|
|
747
|
+
rules: assumptions.rules,
|
|
748
|
+
exit: readPath(storedInput, ['exit']) ?? null,
|
|
749
|
+
roll: readPath(storedInput, ['roll']) ?? null,
|
|
750
|
+
},
|
|
751
|
+
recipe: null,
|
|
752
|
+
pointInTimePolicy:
|
|
753
|
+
'each snapshot sees only its own chain; a leg marks from its exact current-snapshot contract quote under the marking policy; fills read the selected price side of the current quote and refuse a stale one',
|
|
754
|
+
conventions: {
|
|
755
|
+
conventionsVersion: assumptions.conventionsVersion,
|
|
756
|
+
sessionInstantConvention:
|
|
757
|
+
'the snapshot asOf; the ledger marks at the following midnight, one mark per calendar date',
|
|
758
|
+
pricing: `Black–Scholes marks from current quotes (${assumptions.marking.volatility}, missing mark: ${assumptions.marking.missingMark}); settlements at intrinsic`,
|
|
759
|
+
},
|
|
760
|
+
calendar: {
|
|
761
|
+
sessions: run.diagnostics.snapshotCount,
|
|
762
|
+
firstMarkTimestampMs: run.points.length > 0 ? run.points[0]!.timestampMs : null,
|
|
763
|
+
lastMarkTimestampMs:
|
|
764
|
+
run.points.length > 0 ? run.points[run.points.length - 1]!.timestampMs : null,
|
|
765
|
+
},
|
|
766
|
+
engine: { operation: 'optionsBacktest', runVersion: 1 },
|
|
767
|
+
models: {
|
|
768
|
+
execution: null,
|
|
769
|
+
commission: assumptions.commission,
|
|
770
|
+
slippage: assumptions.slippage,
|
|
771
|
+
},
|
|
772
|
+
seed: null,
|
|
773
|
+
benchmark: false,
|
|
774
|
+
annualization: {
|
|
775
|
+
periodsPerYear: assumptions.periodsPerYear,
|
|
776
|
+
riskFreeRate: assumptions.riskFreeRate,
|
|
777
|
+
},
|
|
778
|
+
initialCapital: assumptions.initialCapital,
|
|
779
|
+
baseCurrency: assumptions.baseCurrency,
|
|
780
|
+
variations: null,
|
|
781
|
+
};
|
|
782
|
+
},
|
|
783
|
+
};
|
|
784
|
+
|
|
785
|
+
const PORTFOLIO_INPUT_ROW_SETS = [
|
|
786
|
+
'marketData.bars',
|
|
787
|
+
'marketData.quotes',
|
|
788
|
+
'marketData.trades',
|
|
789
|
+
'marketData.orderBooks',
|
|
790
|
+
'marketData.optionChains',
|
|
791
|
+
'marketData.fxRates',
|
|
792
|
+
'marketData.forwardRates',
|
|
793
|
+
'marketData.fundingRates',
|
|
794
|
+
'marketData.corporateActions',
|
|
795
|
+
'marketData.dividends',
|
|
796
|
+
'marketData.coupons',
|
|
797
|
+
'externalFlows',
|
|
798
|
+
] as const;
|
|
799
|
+
const PORTFOLIO_RESULT_ROW_SETS = [
|
|
800
|
+
'orders',
|
|
801
|
+
'fills',
|
|
802
|
+
'rejections',
|
|
803
|
+
'liquidations',
|
|
804
|
+
'events',
|
|
805
|
+
'valuationMarks',
|
|
806
|
+
'points',
|
|
807
|
+
'returns',
|
|
808
|
+
'ledger.events',
|
|
809
|
+
'timeline.rows',
|
|
810
|
+
] as const;
|
|
811
|
+
const PORTFOLIO_RUN_KEYS = [
|
|
812
|
+
'ledger',
|
|
813
|
+
'timeline',
|
|
814
|
+
'pnl',
|
|
815
|
+
'orders',
|
|
816
|
+
'fills',
|
|
817
|
+
'rejections',
|
|
818
|
+
'liquidations',
|
|
819
|
+
'events',
|
|
820
|
+
'valuationMarks',
|
|
821
|
+
'points',
|
|
822
|
+
'returns',
|
|
823
|
+
'performance',
|
|
824
|
+
'finalValue',
|
|
825
|
+
'runId',
|
|
826
|
+
'assumptions',
|
|
827
|
+
'diagnostics',
|
|
828
|
+
] as const;
|
|
829
|
+
|
|
830
|
+
/** A custom instrument's adapter is a function-bearing object: recorded by kind and version, never stored. */
|
|
831
|
+
function portfolioCallbacks(record: Record<string, unknown>): Array<{
|
|
832
|
+
field: string;
|
|
833
|
+
strip: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
834
|
+
}> {
|
|
835
|
+
const found: Array<{
|
|
836
|
+
field: string;
|
|
837
|
+
strip: (record: Record<string, unknown>) => Record<string, unknown>;
|
|
838
|
+
}> = [];
|
|
839
|
+
const instruments = record['instruments'];
|
|
840
|
+
if (instruments !== null && typeof instruments === 'object') {
|
|
841
|
+
for (const [id, spec] of Object.entries(instruments as Record<string, unknown>)) {
|
|
842
|
+
const adapter = (spec as { adapter?: unknown } | null)?.adapter;
|
|
843
|
+
if (adapter === null || typeof adapter !== 'object') continue;
|
|
844
|
+
found.push({
|
|
845
|
+
field: `instruments.${id}.adapter`,
|
|
846
|
+
strip: (target) => {
|
|
847
|
+
const specs = { ...(target['instruments'] as Record<string, unknown>) };
|
|
848
|
+
const own = specs[id] as Record<string, unknown>;
|
|
849
|
+
const a = own['adapter'] as { kind?: unknown; version?: unknown };
|
|
850
|
+
specs[id] = {
|
|
851
|
+
...own,
|
|
852
|
+
adapter: {
|
|
853
|
+
kind: a.kind,
|
|
854
|
+
version: a.version,
|
|
855
|
+
methods: '[caller functions — not stored]',
|
|
856
|
+
},
|
|
857
|
+
};
|
|
858
|
+
return { ...target, instruments: specs };
|
|
859
|
+
},
|
|
860
|
+
});
|
|
861
|
+
}
|
|
862
|
+
}
|
|
863
|
+
return found;
|
|
864
|
+
}
|
|
865
|
+
|
|
866
|
+
const PORTFOLIO_SPEC: KindSpec<'portfolio'> = {
|
|
867
|
+
descriptor: Object.freeze({
|
|
868
|
+
kind: 'portfolio',
|
|
869
|
+
runVersion: 1,
|
|
870
|
+
operation: 'portfolioBacktest',
|
|
871
|
+
inputRowSets: PORTFOLIO_INPUT_ROW_SETS,
|
|
872
|
+
resultRowSets: PORTFOLIO_RESULT_ROW_SETS.map((label) => `run.${label}`),
|
|
873
|
+
callbackFields: ['strategy.onSession', 'instruments.<id>.adapter'],
|
|
874
|
+
modelFields: ['execution'],
|
|
875
|
+
}),
|
|
876
|
+
inputRowSets: PORTFOLIO_INPUT_ROW_SETS.map(rowSet),
|
|
877
|
+
resultRowSets: PORTFOLIO_RESULT_ROW_SETS.map(resultRowSet),
|
|
878
|
+
callbacks: [
|
|
879
|
+
callbackAt(
|
|
880
|
+
'strategy.onSession',
|
|
881
|
+
(record) =>
|
|
882
|
+
withPath(record, ['strategy'], { onSession: '[caller function — not stored]' }) as Record<
|
|
883
|
+
string,
|
|
884
|
+
unknown
|
|
885
|
+
>,
|
|
886
|
+
),
|
|
887
|
+
],
|
|
888
|
+
modelRoot: [],
|
|
889
|
+
labeledModels: [],
|
|
890
|
+
dynamicCallbacks: portfolioCallbacks,
|
|
891
|
+
runKeys: PORTFOLIO_RUN_KEYS,
|
|
892
|
+
requireInput: (functionName, label, value) => {
|
|
893
|
+
requirePortfolioBacktestRequest(functionName, label, value);
|
|
894
|
+
},
|
|
895
|
+
run: portfolioBacktest,
|
|
896
|
+
identity: (run, storedInput) => {
|
|
897
|
+
const assumptions = run.assumptions;
|
|
898
|
+
const models = readPath(storedInput, []) as Record<string, unknown>;
|
|
899
|
+
const instruments = readPath(storedInput, ['instruments']);
|
|
900
|
+
return {
|
|
901
|
+
runId: run.runId,
|
|
902
|
+
childRunIds: null,
|
|
903
|
+
universeId: `portfolio:${assumptions.instruments.length}`,
|
|
904
|
+
universeHistoryHash: contentHash(instruments),
|
|
905
|
+
strategy: { ...assumptions.strategy } as unknown as Record<string, unknown>,
|
|
906
|
+
recipe: null,
|
|
907
|
+
pointInTimePolicy: assumptions.sessionConvention,
|
|
908
|
+
conventions: {
|
|
909
|
+
conventionsVersion: assumptions.conventionsVersion,
|
|
910
|
+
sessionInstantConvention: assumptions.sessionConvention,
|
|
911
|
+
pricing: assumptions.markConvention,
|
|
912
|
+
},
|
|
913
|
+
calendar: {
|
|
914
|
+
sessions: run.diagnostics.sessionCount,
|
|
915
|
+
firstMarkTimestampMs: run.points.length > 0 ? run.points[0]!.timestampMs : null,
|
|
916
|
+
lastMarkTimestampMs:
|
|
917
|
+
run.points.length > 0 ? run.points[run.points.length - 1]!.timestampMs : null,
|
|
918
|
+
},
|
|
919
|
+
engine: { operation: 'portfolioBacktest', runVersion: 1 },
|
|
920
|
+
models: {
|
|
921
|
+
execution: (models['execution'] as ExecutionPolicyDescription | undefined) ?? null,
|
|
922
|
+
commission: assumptions.execution.costs.commission,
|
|
923
|
+
slippage: assumptions.execution.costs.slippage,
|
|
924
|
+
},
|
|
925
|
+
seed: assumptions.seed,
|
|
926
|
+
benchmark: false,
|
|
927
|
+
annualization: { periodsPerYear: assumptions.periodsPerYear, riskFreeRate: 0 },
|
|
928
|
+
initialCapital: run.points.length > 0 ? run.points[0]!.equity : 0,
|
|
929
|
+
baseCurrency: assumptions.baseCurrency,
|
|
930
|
+
variations: null,
|
|
931
|
+
};
|
|
932
|
+
},
|
|
933
|
+
};
|
|
934
|
+
|
|
935
|
+
const ENVIRONMENT_INPUT_ROW_SETS = [
|
|
936
|
+
...PORTFOLIO_INPUT_ROW_SETS.map((label) => `definition.${label}`),
|
|
937
|
+
'actions',
|
|
938
|
+
] as const;
|
|
939
|
+
const ENVIRONMENT_RESULT_ROW_SETS = [
|
|
940
|
+
'steps',
|
|
941
|
+
'rewards',
|
|
942
|
+
...PORTFOLIO_RESULT_ROW_SETS.map((label) => `result.${label}`),
|
|
943
|
+
] as const;
|
|
944
|
+
const ENVIRONMENT_RUN_KEYS = [
|
|
945
|
+
'runId',
|
|
946
|
+
'engineRunId',
|
|
947
|
+
'definitionHash',
|
|
948
|
+
'seed',
|
|
949
|
+
'traceHash',
|
|
950
|
+
'steps',
|
|
951
|
+
'rewards',
|
|
952
|
+
'rewardTotal',
|
|
953
|
+
'terminated',
|
|
954
|
+
'truncated',
|
|
955
|
+
'reason',
|
|
956
|
+
'result',
|
|
957
|
+
'assumptions',
|
|
958
|
+
'diagnostics',
|
|
959
|
+
] as const;
|
|
960
|
+
|
|
961
|
+
const ENVIRONMENT_SPEC: KindSpec<'environment'> = {
|
|
962
|
+
descriptor: Object.freeze({
|
|
963
|
+
kind: 'environment',
|
|
964
|
+
runVersion: 1,
|
|
965
|
+
operation: 'runEnvironmentEpisode',
|
|
966
|
+
inputRowSets: ENVIRONMENT_INPUT_ROW_SETS,
|
|
967
|
+
resultRowSets: ENVIRONMENT_RESULT_ROW_SETS.map((label) => `run.${label}`),
|
|
968
|
+
callbackFields: ['definition.reward.goal', 'definition.instruments.<id>.adapter'],
|
|
969
|
+
modelFields: ['definition.execution'],
|
|
970
|
+
}),
|
|
971
|
+
inputRowSets: ENVIRONMENT_INPUT_ROW_SETS.map(rowSet),
|
|
972
|
+
resultRowSets: ENVIRONMENT_RESULT_ROW_SETS.map(resultRowSet),
|
|
973
|
+
callbacks: [
|
|
974
|
+
callbackAt('definition.reward.goal', (record) => {
|
|
975
|
+
const reward = { ...(readPath(record, ['definition', 'reward']) as Record<string, unknown>) };
|
|
976
|
+
reward['goal'] = '[caller function — not stored]';
|
|
977
|
+
return withPath(record, ['definition', 'reward'], reward) as Record<string, unknown>;
|
|
978
|
+
}),
|
|
979
|
+
],
|
|
980
|
+
modelRoot: ['definition'],
|
|
981
|
+
labeledModels: [],
|
|
982
|
+
dynamicCallbacks: (record) => {
|
|
983
|
+
const definition = record['definition'];
|
|
984
|
+
if (definition === null || typeof definition !== 'object') return [];
|
|
985
|
+
return portfolioCallbacks(definition as Record<string, unknown>).map((callback) => ({
|
|
986
|
+
field: `definition.${callback.field}`,
|
|
987
|
+
strip: (target) => ({
|
|
988
|
+
...target,
|
|
989
|
+
definition: callback.strip(target['definition'] as Record<string, unknown>),
|
|
990
|
+
}),
|
|
991
|
+
}));
|
|
992
|
+
},
|
|
993
|
+
runKeys: ENVIRONMENT_RUN_KEYS,
|
|
994
|
+
requireInput: (functionName, label, value) => {
|
|
995
|
+
requireEnvironmentEpisodeInput(functionName, label, value);
|
|
996
|
+
},
|
|
997
|
+
run: runEnvironmentEpisode,
|
|
998
|
+
identity: (run, storedInput) => {
|
|
999
|
+
const engine = run.result.assumptions;
|
|
1000
|
+
const definition = readPath(storedInput, ['definition']) as Record<string, unknown>;
|
|
1001
|
+
return {
|
|
1002
|
+
runId: run.runId,
|
|
1003
|
+
childRunIds: [run.engineRunId],
|
|
1004
|
+
universeId: `environment:${engine.instruments.length}`,
|
|
1005
|
+
universeHistoryHash: contentHash(readPath(definition, ['instruments'])),
|
|
1006
|
+
strategy: { kind: 'environment', actions: run.steps.length, traceHash: run.traceHash },
|
|
1007
|
+
recipe: null,
|
|
1008
|
+
pointInTimePolicy: run.assumptions.nextObservationLaw,
|
|
1009
|
+
conventions: {
|
|
1010
|
+
conventionsVersion: run.assumptions.conventionsVersion,
|
|
1011
|
+
sessionInstantConvention: engine.sessionConvention,
|
|
1012
|
+
pricing: engine.markConvention,
|
|
1013
|
+
},
|
|
1014
|
+
calendar: {
|
|
1015
|
+
sessions: run.result.diagnostics.sessionCount,
|
|
1016
|
+
firstMarkTimestampMs:
|
|
1017
|
+
run.result.points.length > 0 ? run.result.points[0]!.timestampMs : null,
|
|
1018
|
+
lastMarkTimestampMs:
|
|
1019
|
+
run.result.points.length > 0
|
|
1020
|
+
? run.result.points[run.result.points.length - 1]!.timestampMs
|
|
1021
|
+
: null,
|
|
1022
|
+
},
|
|
1023
|
+
engine: { operation: 'runEnvironmentEpisode', runVersion: 1 },
|
|
1024
|
+
models: {
|
|
1025
|
+
execution: (definition['execution'] as ExecutionPolicyDescription | undefined) ?? null,
|
|
1026
|
+
commission: engine.execution.costs.commission,
|
|
1027
|
+
slippage: engine.execution.costs.slippage,
|
|
1028
|
+
},
|
|
1029
|
+
seed: run.seed,
|
|
1030
|
+
benchmark:
|
|
1031
|
+
(definition['reward'] as { benchmark?: unknown } | undefined)?.benchmark !== undefined,
|
|
1032
|
+
annualization: { periodsPerYear: engine.periodsPerYear, riskFreeRate: 0 },
|
|
1033
|
+
initialCapital: run.result.points.length > 0 ? run.result.points[0]!.equity : 0,
|
|
1034
|
+
baseCurrency: engine.baseCurrency,
|
|
1035
|
+
variations: null,
|
|
1036
|
+
};
|
|
1037
|
+
},
|
|
1038
|
+
};
|
|
1039
|
+
|
|
1040
|
+
const KIND_SPECS: { readonly [K in BacktestRunKind]: KindSpec<K> } = {
|
|
1041
|
+
'cross-sectional': CROSS_SECTIONAL_SPEC,
|
|
1042
|
+
'cross-sectional-grid': GRID_SPEC,
|
|
1043
|
+
options: OPTIONS_SPEC,
|
|
1044
|
+
portfolio: PORTFOLIO_SPEC,
|
|
1045
|
+
environment: ENVIRONMENT_SPEC,
|
|
1046
|
+
};
|
|
1047
|
+
|
|
1048
|
+
export const BACKTEST_RUN_KIND_LIST: readonly BacktestRunKind[] = Object.freeze([
|
|
1049
|
+
'cross-sectional',
|
|
1050
|
+
'cross-sectional-grid',
|
|
1051
|
+
'options',
|
|
1052
|
+
'portfolio',
|
|
1053
|
+
'environment',
|
|
1054
|
+
]);
|
|
1055
|
+
|
|
1056
|
+
/** The frozen data projection of the kind table — what an agent reads before choosing a kind. */
|
|
1057
|
+
export const BACKTEST_RUN_KINDS: Readonly<Record<BacktestRunKind, BacktestRunKindDescriptor>> =
|
|
1058
|
+
Object.freeze({
|
|
1059
|
+
'cross-sectional': CROSS_SECTIONAL_SPEC.descriptor,
|
|
1060
|
+
'cross-sectional-grid': GRID_SPEC.descriptor,
|
|
1061
|
+
options: OPTIONS_SPEC.descriptor,
|
|
1062
|
+
portfolio: PORTFOLIO_SPEC.descriptor,
|
|
1063
|
+
environment: ENVIRONMENT_SPEC.descriptor,
|
|
1064
|
+
});
|
|
1065
|
+
|
|
1066
|
+
// ─────────────────────────────────────────── helpers ────────────────────────────────────────────
|
|
1067
|
+
|
|
1068
|
+
const REPORT_KEYS = [
|
|
1069
|
+
'kind',
|
|
1070
|
+
'runVersion',
|
|
1071
|
+
'run',
|
|
1072
|
+
'inputs',
|
|
1073
|
+
'referencedData',
|
|
1074
|
+
'runHash',
|
|
1075
|
+
'identity',
|
|
1076
|
+
'hygiene',
|
|
1077
|
+
'execution',
|
|
1078
|
+
'assumptions',
|
|
1079
|
+
'diagnostics',
|
|
1080
|
+
] as const;
|
|
1081
|
+
const ASSUMPTION_KEYS = [
|
|
1082
|
+
'conventionsVersion',
|
|
1083
|
+
'kind',
|
|
1084
|
+
'runVersion',
|
|
1085
|
+
'operation',
|
|
1086
|
+
'replayable',
|
|
1087
|
+
'nonReplayableField',
|
|
1088
|
+
'inputPolicy',
|
|
1089
|
+
'embeddedRowLimit',
|
|
1090
|
+
'modelPolicy',
|
|
1091
|
+
'projection',
|
|
1092
|
+
] as const;
|
|
1093
|
+
const DIAGNOSTIC_KEYS = ['warnings', 'embeddedRows', 'referencedRows', 'runWarningCount'] as const;
|
|
1094
|
+
const HYGIENE_KEYS = ['researchProtocol', 'deflatedSharpe', 'backtestOverfitting'] as const;
|
|
1095
|
+
const HYGIENE_REQUIRED: Record<(typeof HYGIENE_KEYS)[number], string> = {
|
|
1096
|
+
researchProtocol: 'deflatedSharpe',
|
|
1097
|
+
deflatedSharpe: 'deflatedSharpe',
|
|
1098
|
+
backtestOverfitting: 'backtestOverfittingProbability',
|
|
1099
|
+
};
|
|
1100
|
+
const MODEL_POLICY =
|
|
1101
|
+
'execution is stored as describeExecutionPolicy(policy); commission and slippage as their labels; replay takes the live models back as `models` and verifies each against its recorded description before the run';
|
|
1102
|
+
const PROJECTION =
|
|
1103
|
+
'run = the verb result verbatim with referenced result row sets replaced by table handles; inputs = the request with bulk row sets embedded or replaced by verified table handles, caller functions omitted (recorded as nonReplayableField), and models by description';
|
|
1104
|
+
const METRIC_NAMES = [
|
|
1105
|
+
'totalReturn',
|
|
1106
|
+
'annualizedReturn',
|
|
1107
|
+
'annualizedVolatility',
|
|
1108
|
+
'sharpe',
|
|
1109
|
+
'sortino',
|
|
1110
|
+
'calmar',
|
|
1111
|
+
'maxDrawdown',
|
|
1112
|
+
'hitRate',
|
|
1113
|
+
'profitFactor',
|
|
1114
|
+
'finalValue',
|
|
1115
|
+
'meanTurnover',
|
|
1116
|
+
'totalCosts',
|
|
1117
|
+
] as const;
|
|
1118
|
+
|
|
1119
|
+
function fail(
|
|
1120
|
+
functionName: string,
|
|
1121
|
+
message: string,
|
|
1122
|
+
code: string,
|
|
1123
|
+
context: Record<string, unknown> = {},
|
|
1124
|
+
): never {
|
|
1125
|
+
throw new InputError(`${functionName}: ${message}`, {
|
|
1126
|
+
code,
|
|
1127
|
+
context: { function: functionName, ...context },
|
|
1128
|
+
});
|
|
1129
|
+
}
|
|
1130
|
+
|
|
1131
|
+
function detach<T>(value: T): T {
|
|
1132
|
+
return fromCanonicalJson(canonicalJsonOf(value)) as T;
|
|
1133
|
+
}
|
|
1134
|
+
|
|
1135
|
+
function deepFreeze<T>(value: T): T {
|
|
1136
|
+
if (value !== null && typeof value === 'object' && !Object.isFrozen(value)) {
|
|
1137
|
+
Object.freeze(value);
|
|
1138
|
+
for (const member of Object.values(value as Record<string, unknown>)) deepFreeze(member);
|
|
1139
|
+
}
|
|
1140
|
+
return value;
|
|
1141
|
+
}
|
|
1142
|
+
|
|
1143
|
+
function isArtifact(value: unknown): value is AnalysisArtifact {
|
|
1144
|
+
return (
|
|
1145
|
+
value !== null &&
|
|
1146
|
+
typeof value === 'object' &&
|
|
1147
|
+
(value as { kind?: unknown }).kind === 'totalfinance.analysis-artifact'
|
|
1148
|
+
);
|
|
1149
|
+
}
|
|
1150
|
+
|
|
1151
|
+
function hasOwn(record: object, key: string): boolean {
|
|
1152
|
+
return Object.prototype.hasOwnProperty.call(record, key);
|
|
1153
|
+
}
|
|
1154
|
+
|
|
1155
|
+
function readPath(record: unknown, path: Path): unknown {
|
|
1156
|
+
let cursor: unknown = record;
|
|
1157
|
+
for (const segment of path) {
|
|
1158
|
+
if (cursor === null || typeof cursor !== 'object') return undefined;
|
|
1159
|
+
cursor = (cursor as Record<string, unknown>)[segment];
|
|
1160
|
+
}
|
|
1161
|
+
return cursor;
|
|
1162
|
+
}
|
|
1163
|
+
|
|
1164
|
+
/** Copy-on-write along one path; every other reference is shared. */
|
|
1165
|
+
function withPath(record: unknown, path: Path, value: unknown): unknown {
|
|
1166
|
+
if (path.length === 0) return value;
|
|
1167
|
+
const [head, ...rest] = path;
|
|
1168
|
+
const base =
|
|
1169
|
+
record !== null && typeof record === 'object' && !Array.isArray(record)
|
|
1170
|
+
? (record as Record<string, unknown>)
|
|
1171
|
+
: {};
|
|
1172
|
+
return { ...base, [head!]: withPath(base[head!], rest, value) };
|
|
1173
|
+
}
|
|
1174
|
+
|
|
1175
|
+
function scanEmbedded(
|
|
1176
|
+
functionName: string,
|
|
1177
|
+
label: string,
|
|
1178
|
+
value: unknown,
|
|
1179
|
+
maximumEmbeddedBytes: number,
|
|
1180
|
+
): void {
|
|
1181
|
+
try {
|
|
1182
|
+
scanCanonicalData(value, {
|
|
1183
|
+
functionName,
|
|
1184
|
+
label,
|
|
1185
|
+
maximumWorkUnits: maximumEmbeddedBytes,
|
|
1186
|
+
requireFiniteNumbers: true,
|
|
1187
|
+
});
|
|
1188
|
+
} catch (error) {
|
|
1189
|
+
if (
|
|
1190
|
+
isQuantError(error, ErrorCode.InputOutOfRange) &&
|
|
1191
|
+
error.message.includes('data-work limit')
|
|
1192
|
+
) {
|
|
1193
|
+
fail(
|
|
1194
|
+
functionName,
|
|
1195
|
+
`the embedded ${label} exceeds the embedded budget (${maximumEmbeddedBytes.toLocaleString()} work units ≈ canonical bytes) — reference its bulk row sets (referenceRowSets) or raise limits.maximumEmbeddedBytes up to ${BACKTEST_RUN_LIMITS.maximumEmbeddedBytes.maximum.toLocaleString()}.`,
|
|
1196
|
+
ErrorCode.ArtifactEmbeddedInputTooLarge,
|
|
1197
|
+
{ field: label, maximumEmbeddedBytes },
|
|
1198
|
+
);
|
|
1199
|
+
}
|
|
1200
|
+
throw error;
|
|
1201
|
+
}
|
|
1202
|
+
}
|
|
1203
|
+
|
|
1204
|
+
function requireKind(functionName: string, value: unknown): BacktestRunKind {
|
|
1205
|
+
if (typeof value !== 'string' || !(value in KIND_SPECS)) {
|
|
1206
|
+
fail(
|
|
1207
|
+
functionName,
|
|
1208
|
+
`kind must be one of ${BACKTEST_RUN_KIND_LIST.map((k) => `'${k}'`).join(' | ')}. Received ${value === null ? 'null' : JSON.stringify(value)}.`,
|
|
1209
|
+
ErrorCode.InputInvalidEnum,
|
|
1210
|
+
{ field: 'kind' },
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
return value as BacktestRunKind;
|
|
1214
|
+
}
|
|
1215
|
+
|
|
1216
|
+
function specOf<K extends BacktestRunKind>(kind: K): KindSpec<K> {
|
|
1217
|
+
return KIND_SPECS[kind] as unknown as KindSpec<K>;
|
|
1218
|
+
}
|
|
1219
|
+
|
|
1220
|
+
function requireSnapshotHash(functionName: string, value: unknown): string | null {
|
|
1221
|
+
if (value === undefined) return null;
|
|
1222
|
+
if (typeof value !== 'string' || !value.startsWith('sha256:')) {
|
|
1223
|
+
fail(
|
|
1224
|
+
functionName,
|
|
1225
|
+
'snapshotHash must be a `sha256:` content hash when present.',
|
|
1226
|
+
ErrorCode.InputWrongType,
|
|
1227
|
+
{ field: 'snapshotHash' },
|
|
1228
|
+
);
|
|
1229
|
+
}
|
|
1230
|
+
return value;
|
|
1231
|
+
}
|
|
1232
|
+
|
|
1233
|
+
function requireHygieneBlock(
|
|
1234
|
+
functionName: string,
|
|
1235
|
+
field: string,
|
|
1236
|
+
value: unknown,
|
|
1237
|
+
): BacktestHygieneBlock {
|
|
1238
|
+
requireArgumentObject(functionName, field, value);
|
|
1239
|
+
const block = value as Record<string, unknown>;
|
|
1240
|
+
ensureKnownKeys(functionName, field, block, HYGIENE_KEYS);
|
|
1241
|
+
for (const key of HYGIENE_KEYS) {
|
|
1242
|
+
if (!hasOwn(block, key)) continue;
|
|
1243
|
+
const member = block[key];
|
|
1244
|
+
requireArgumentObject(functionName, `${field}.${key}`, member);
|
|
1245
|
+
const required = HYGIENE_REQUIRED[key];
|
|
1246
|
+
const probe = (member as Record<string, unknown>)[required];
|
|
1247
|
+
if (typeof probe !== 'number' || !Number.isFinite(probe)) {
|
|
1248
|
+
fail(
|
|
1249
|
+
functionName,
|
|
1250
|
+
`${field}.${key}.${required} must be the finite number the @insiderfinance/totalfinance/risk verb reported — attach the verdict verbatim.`,
|
|
1251
|
+
ErrorCode.InputWrongType,
|
|
1252
|
+
{ field: `${field}.${key}.${required}` },
|
|
1253
|
+
);
|
|
1254
|
+
}
|
|
1255
|
+
}
|
|
1256
|
+
return value as BacktestHygieneBlock;
|
|
1257
|
+
}
|
|
1258
|
+
|
|
1259
|
+
function requireRunShape(
|
|
1260
|
+
functionName: string,
|
|
1261
|
+
field: string,
|
|
1262
|
+
spec: KindSpec<BacktestRunKind>,
|
|
1263
|
+
value: unknown,
|
|
1264
|
+
): void {
|
|
1265
|
+
requireArgumentObject(functionName, field, value);
|
|
1266
|
+
const record = value as Record<string, unknown>;
|
|
1267
|
+
ensureKnownKeys(functionName, field, record, spec.runKeys);
|
|
1268
|
+
for (const key of spec.runKeys) {
|
|
1269
|
+
if (!hasOwn(record, key)) {
|
|
1270
|
+
fail(
|
|
1271
|
+
functionName,
|
|
1272
|
+
`${field}.${key} is missing — a '${spec.descriptor.kind}' run is the verbatim result of ${spec.descriptor.operation}, which always reports it.`,
|
|
1273
|
+
ErrorCode.InputMissingField,
|
|
1274
|
+
{ field: `${field}.${key}` },
|
|
1275
|
+
);
|
|
1276
|
+
}
|
|
1277
|
+
}
|
|
1278
|
+
requireArgumentObject(functionName, `${field}.assumptions`, record['assumptions']);
|
|
1279
|
+
requireArgumentObject(functionName, `${field}.diagnostics`, record['diagnostics']);
|
|
1280
|
+
}
|
|
1281
|
+
|
|
1282
|
+
/** Models → descriptions and labels. Present-but-invalid models are refused (they could not have produced the run). */
|
|
1283
|
+
function recordModels(
|
|
1284
|
+
functionName: string,
|
|
1285
|
+
input: Record<string, unknown>,
|
|
1286
|
+
root: Path,
|
|
1287
|
+
): Record<string, unknown> {
|
|
1288
|
+
const request = readPath(input, root) as Record<string, unknown>;
|
|
1289
|
+
let working = { ...request };
|
|
1290
|
+
if (hasOwn(working, 'execution') && working['execution'] !== undefined) {
|
|
1291
|
+
const policy = working['execution'];
|
|
1292
|
+
if (
|
|
1293
|
+
policy === null ||
|
|
1294
|
+
typeof policy !== 'object' ||
|
|
1295
|
+
typeof (policy as { label?: unknown }).label !== 'string'
|
|
1296
|
+
) {
|
|
1297
|
+
fail(
|
|
1298
|
+
functionName,
|
|
1299
|
+
`input.${[...root, 'execution'].join('.')} must be an execution policy (execution.simplified() or execution.declared(...)).`,
|
|
1300
|
+
ErrorCode.InputWrongType,
|
|
1301
|
+
{ field: 'input.execution' },
|
|
1302
|
+
);
|
|
1303
|
+
}
|
|
1304
|
+
working = { ...working, execution: describeExecutionPolicy(policy as ExecutionPolicy) };
|
|
1305
|
+
}
|
|
1306
|
+
if (hasOwn(working, 'transactionCostModel') && working['transactionCostModel'] !== undefined) {
|
|
1307
|
+
const models = working['transactionCostModel'];
|
|
1308
|
+
requireArgumentObject(
|
|
1309
|
+
functionName,
|
|
1310
|
+
`input.${[...root, 'transactionCostModel'].join('.')}`,
|
|
1311
|
+
models,
|
|
1312
|
+
);
|
|
1313
|
+
const record = models as Record<string, unknown>;
|
|
1314
|
+
const labels: Record<string, string> = {};
|
|
1315
|
+
for (const key of ['commission', 'slippage'] as const) {
|
|
1316
|
+
if (!hasOwn(record, key) || record[key] === undefined) continue;
|
|
1317
|
+
const label = (record[key] as { label?: unknown } | null)?.label;
|
|
1318
|
+
if (typeof label !== 'string' || label.length === 0) {
|
|
1319
|
+
fail(
|
|
1320
|
+
functionName,
|
|
1321
|
+
`input.${[...root, 'transactionCostModel', key].join('.')} must be a labeled ${key} model (fees.* / slippage.*).`,
|
|
1322
|
+
ErrorCode.InputWrongType,
|
|
1323
|
+
{ field: `input.transactionCostModel.${key}` },
|
|
1324
|
+
);
|
|
1325
|
+
}
|
|
1326
|
+
labels[key] = label;
|
|
1327
|
+
}
|
|
1328
|
+
working = { ...working, transactionCostModel: labels };
|
|
1329
|
+
}
|
|
1330
|
+
return withPath(input, root, working) as Record<string, unknown>;
|
|
1331
|
+
}
|
|
1332
|
+
|
|
1333
|
+
/** Labeled cost models (fees.* / slippage.*) → their labels, at the kind's dotted paths. */
|
|
1334
|
+
function recordLabeledModels(
|
|
1335
|
+
functionName: string,
|
|
1336
|
+
input: Record<string, unknown>,
|
|
1337
|
+
paths: readonly string[],
|
|
1338
|
+
): Record<string, unknown> {
|
|
1339
|
+
let working = input;
|
|
1340
|
+
for (const dotted of paths) {
|
|
1341
|
+
const path = dotted.split('.');
|
|
1342
|
+
const model = readPath(working, path);
|
|
1343
|
+
if (model === undefined) continue;
|
|
1344
|
+
const label = (model as { label?: unknown } | null)?.label;
|
|
1345
|
+
if (typeof label !== 'string' || label.length === 0) {
|
|
1346
|
+
fail(
|
|
1347
|
+
functionName,
|
|
1348
|
+
`input.${dotted} must be a labeled cost model (fees.* / slippage.*).`,
|
|
1349
|
+
ErrorCode.InputWrongType,
|
|
1350
|
+
{ field: `input.${dotted}` },
|
|
1351
|
+
);
|
|
1352
|
+
}
|
|
1353
|
+
working = withPath(working, path, { label }) as Record<string, unknown>;
|
|
1354
|
+
}
|
|
1355
|
+
return working;
|
|
1356
|
+
}
|
|
1357
|
+
|
|
1358
|
+
function projectRun(
|
|
1359
|
+
run: Record<string, unknown>,
|
|
1360
|
+
spec: KindSpec<BacktestRunKind>,
|
|
1361
|
+
referenced: readonly string[],
|
|
1362
|
+
locators: Record<string, string> | undefined,
|
|
1363
|
+
): {
|
|
1364
|
+
stored: Record<string, unknown>;
|
|
1365
|
+
handles: Record<string, TableHandle>;
|
|
1366
|
+
embeddedRows: number;
|
|
1367
|
+
rowCounts: Record<string, number>;
|
|
1368
|
+
} {
|
|
1369
|
+
let stored: Record<string, unknown> = run;
|
|
1370
|
+
const handles: Record<string, TableHandle> = {};
|
|
1371
|
+
const rowCounts: Record<string, number> = {};
|
|
1372
|
+
let embeddedRows = 0;
|
|
1373
|
+
for (const set of spec.resultRowSets) {
|
|
1374
|
+
const rows = readPath(run, set.path);
|
|
1375
|
+
if (!Array.isArray(rows)) continue;
|
|
1376
|
+
rowCounts[set.label] = rows.length;
|
|
1377
|
+
if (referenced.includes(set.label)) {
|
|
1378
|
+
const handle = tableHandleForRows({
|
|
1379
|
+
rows,
|
|
1380
|
+
...(locators?.[set.label] !== undefined ? { locator: locators[set.label]! } : {}),
|
|
1381
|
+
});
|
|
1382
|
+
handles[set.label] = handle;
|
|
1383
|
+
stored = withPath(stored, set.path, handle) as Record<string, unknown>;
|
|
1384
|
+
} else {
|
|
1385
|
+
embeddedRows += rows.length;
|
|
1386
|
+
}
|
|
1387
|
+
}
|
|
1388
|
+
return { stored, handles, embeddedRows, rowCounts };
|
|
1389
|
+
}
|
|
1390
|
+
|
|
1391
|
+
function buildReport(input: {
|
|
1392
|
+
spec: KindSpec<BacktestRunKind>;
|
|
1393
|
+
run: Record<string, unknown>;
|
|
1394
|
+
storedRun: Record<string, unknown>;
|
|
1395
|
+
storedInput: Record<string, unknown>;
|
|
1396
|
+
referencedData: Record<string, TableHandle>;
|
|
1397
|
+
hygiene: BacktestHygieneBlock | null;
|
|
1398
|
+
nonReplayableField: string | null;
|
|
1399
|
+
embeddedRows: number;
|
|
1400
|
+
embeddedRowLimit: number;
|
|
1401
|
+
}): BacktestRunReport {
|
|
1402
|
+
const { spec } = input;
|
|
1403
|
+
const runHash = contentHash(input.storedRun);
|
|
1404
|
+
const referencedRows = Object.values(input.referencedData).reduce(
|
|
1405
|
+
(sum, handle) => sum + handle.rowCount,
|
|
1406
|
+
0,
|
|
1407
|
+
);
|
|
1408
|
+
const runWarnings = (input.run['diagnostics'] as { warnings?: unknown[] }).warnings;
|
|
1409
|
+
return {
|
|
1410
|
+
kind: spec.descriptor.kind,
|
|
1411
|
+
runVersion: spec.descriptor.runVersion,
|
|
1412
|
+
run: input.storedRun,
|
|
1413
|
+
inputs: input.storedInput,
|
|
1414
|
+
referencedData: input.referencedData,
|
|
1415
|
+
runHash,
|
|
1416
|
+
identity: spec.identity(input.run as never, input.storedInput),
|
|
1417
|
+
hygiene: input.hygiene,
|
|
1418
|
+
execution: { completed: true },
|
|
1419
|
+
assumptions: {
|
|
1420
|
+
conventionsVersion: CONVENTIONS_VERSION,
|
|
1421
|
+
kind: spec.descriptor.kind,
|
|
1422
|
+
runVersion: spec.descriptor.runVersion,
|
|
1423
|
+
operation: spec.descriptor.operation,
|
|
1424
|
+
replayable: input.nonReplayableField === null,
|
|
1425
|
+
nonReplayableField: input.nonReplayableField,
|
|
1426
|
+
inputPolicy: Object.keys(input.referencedData).length > 0 ? 'referenced' : 'embedded',
|
|
1427
|
+
embeddedRowLimit: input.embeddedRowLimit,
|
|
1428
|
+
modelPolicy: MODEL_POLICY,
|
|
1429
|
+
projection: PROJECTION,
|
|
1430
|
+
},
|
|
1431
|
+
diagnostics: {
|
|
1432
|
+
warnings: [],
|
|
1433
|
+
embeddedRows: input.embeddedRows,
|
|
1434
|
+
referencedRows,
|
|
1435
|
+
runWarningCount: Array.isArray(runWarnings) ? runWarnings.length : 0,
|
|
1436
|
+
},
|
|
1437
|
+
};
|
|
1438
|
+
}
|
|
1439
|
+
|
|
1440
|
+
const IDENTITY_KEYS = [
|
|
1441
|
+
'runId',
|
|
1442
|
+
'childRunIds',
|
|
1443
|
+
'universeId',
|
|
1444
|
+
'universeHistoryHash',
|
|
1445
|
+
'strategy',
|
|
1446
|
+
'recipe',
|
|
1447
|
+
'pointInTimePolicy',
|
|
1448
|
+
'conventions',
|
|
1449
|
+
'calendar',
|
|
1450
|
+
'engine',
|
|
1451
|
+
'models',
|
|
1452
|
+
'seed',
|
|
1453
|
+
'benchmark',
|
|
1454
|
+
'annualization',
|
|
1455
|
+
'initialCapital',
|
|
1456
|
+
'baseCurrency',
|
|
1457
|
+
'variations',
|
|
1458
|
+
] as const;
|
|
1459
|
+
|
|
1460
|
+
function requireIdentity(functionName: string, identity: Record<string, unknown>): void {
|
|
1461
|
+
ensureKnownKeys(functionName, 'report.identity', identity, IDENTITY_KEYS);
|
|
1462
|
+
for (const key of IDENTITY_KEYS) {
|
|
1463
|
+
if (!hasOwn(identity, key))
|
|
1464
|
+
fail(functionName, `report.identity.${key} is missing.`, ErrorCode.InputMissingField, {
|
|
1465
|
+
field: `report.identity.${key}`,
|
|
1466
|
+
});
|
|
1467
|
+
}
|
|
1468
|
+
const nonEmpty = (key: string): void => {
|
|
1469
|
+
if (typeof identity[key] !== 'string' || (identity[key] as string).length === 0) {
|
|
1470
|
+
fail(
|
|
1471
|
+
functionName,
|
|
1472
|
+
`report.identity.${key} must be a non-empty string. Received ${identity[key] === null ? 'null' : typeof identity[key]}.`,
|
|
1473
|
+
ErrorCode.InputWrongType,
|
|
1474
|
+
{ field: `report.identity.${key}` },
|
|
1475
|
+
);
|
|
1476
|
+
}
|
|
1477
|
+
};
|
|
1478
|
+
for (const key of [
|
|
1479
|
+
'runId',
|
|
1480
|
+
'universeId',
|
|
1481
|
+
'universeHistoryHash',
|
|
1482
|
+
'pointInTimePolicy',
|
|
1483
|
+
'baseCurrency',
|
|
1484
|
+
])
|
|
1485
|
+
nonEmpty(key);
|
|
1486
|
+
if (
|
|
1487
|
+
!(identity['runId'] as string).startsWith('sha256:') ||
|
|
1488
|
+
!(identity['universeHistoryHash'] as string).startsWith('sha256:')
|
|
1489
|
+
) {
|
|
1490
|
+
fail(
|
|
1491
|
+
functionName,
|
|
1492
|
+
'report.identity.runId and universeHistoryHash must be `sha256:` content hashes.',
|
|
1493
|
+
ErrorCode.InputWrongType,
|
|
1494
|
+
{ field: 'report.identity.runId' },
|
|
1495
|
+
);
|
|
1496
|
+
}
|
|
1497
|
+
const objectOrNull = (key: string, nullable: boolean): void => {
|
|
1498
|
+
const value = identity[key];
|
|
1499
|
+
if (value === null && nullable) return;
|
|
1500
|
+
if (value === null || typeof value !== 'object' || Array.isArray(value)) {
|
|
1501
|
+
fail(
|
|
1502
|
+
functionName,
|
|
1503
|
+
`report.identity.${key} must be an object${nullable ? ' or null' : ''}. Received ${value === null ? 'null' : Array.isArray(value) ? 'array' : typeof value}.`,
|
|
1504
|
+
ErrorCode.InputWrongType,
|
|
1505
|
+
{ field: `report.identity.${key}` },
|
|
1506
|
+
);
|
|
1507
|
+
}
|
|
1508
|
+
};
|
|
1509
|
+
for (const key of ['strategy', 'conventions', 'calendar', 'engine', 'models', 'annualization'])
|
|
1510
|
+
objectOrNull(key, false);
|
|
1511
|
+
objectOrNull('recipe', true);
|
|
1512
|
+
for (const key of ['childRunIds', 'variations']) {
|
|
1513
|
+
const value = identity[key];
|
|
1514
|
+
if (value !== null && !Array.isArray(value))
|
|
1515
|
+
fail(
|
|
1516
|
+
functionName,
|
|
1517
|
+
`report.identity.${key} must be an array or null.`,
|
|
1518
|
+
ErrorCode.InputWrongType,
|
|
1519
|
+
{ field: `report.identity.${key}` },
|
|
1520
|
+
);
|
|
1521
|
+
}
|
|
1522
|
+
if (identity['seed'] !== null && !Number.isSafeInteger(identity['seed']))
|
|
1523
|
+
fail(
|
|
1524
|
+
functionName,
|
|
1525
|
+
'report.identity.seed must be a safe integer or null.',
|
|
1526
|
+
ErrorCode.InputWrongType,
|
|
1527
|
+
{ field: 'report.identity.seed' },
|
|
1528
|
+
);
|
|
1529
|
+
if (typeof identity['benchmark'] !== 'boolean')
|
|
1530
|
+
fail(functionName, 'report.identity.benchmark must be a boolean.', ErrorCode.InputWrongType, {
|
|
1531
|
+
field: 'report.identity.benchmark',
|
|
1532
|
+
});
|
|
1533
|
+
if (
|
|
1534
|
+
typeof identity['initialCapital'] !== 'number' ||
|
|
1535
|
+
!Number.isFinite(identity['initialCapital']) ||
|
|
1536
|
+
(identity['initialCapital'] as number) <= 0
|
|
1537
|
+
) {
|
|
1538
|
+
fail(
|
|
1539
|
+
functionName,
|
|
1540
|
+
'report.identity.initialCapital must be a positive finite number.',
|
|
1541
|
+
ErrorCode.InputOutOfRange,
|
|
1542
|
+
{ field: 'report.identity.initialCapital' },
|
|
1543
|
+
);
|
|
1544
|
+
}
|
|
1545
|
+
const conventions = identity['conventions'] as Record<string, unknown>;
|
|
1546
|
+
ensureKnownKeys(functionName, 'report.identity.conventions', conventions, [
|
|
1547
|
+
'conventionsVersion',
|
|
1548
|
+
'sessionInstantConvention',
|
|
1549
|
+
'pricing',
|
|
1550
|
+
]);
|
|
1551
|
+
for (const key of ['conventionsVersion', 'sessionInstantConvention', 'pricing']) {
|
|
1552
|
+
if (typeof conventions[key] !== 'string' || (conventions[key] as string).length === 0)
|
|
1553
|
+
fail(
|
|
1554
|
+
functionName,
|
|
1555
|
+
`report.identity.conventions.${key} must be a non-empty string.`,
|
|
1556
|
+
ErrorCode.InputWrongType,
|
|
1557
|
+
{ field: `report.identity.conventions.${key}` },
|
|
1558
|
+
);
|
|
1559
|
+
}
|
|
1560
|
+
const engine = identity['engine'] as Record<string, unknown>;
|
|
1561
|
+
ensureKnownKeys(functionName, 'report.identity.engine', engine, ['operation', 'runVersion']);
|
|
1562
|
+
if (typeof engine['operation'] !== 'string' || !Number.isSafeInteger(engine['runVersion']))
|
|
1563
|
+
fail(
|
|
1564
|
+
functionName,
|
|
1565
|
+
'report.identity.engine must carry the operation name and an integer runVersion.',
|
|
1566
|
+
ErrorCode.InputWrongType,
|
|
1567
|
+
{ field: 'report.identity.engine' },
|
|
1568
|
+
);
|
|
1569
|
+
const calendar = identity['calendar'] as Record<string, unknown>;
|
|
1570
|
+
ensureKnownKeys(functionName, 'report.identity.calendar', calendar, [
|
|
1571
|
+
'sessions',
|
|
1572
|
+
'firstMarkTimestampMs',
|
|
1573
|
+
'lastMarkTimestampMs',
|
|
1574
|
+
]);
|
|
1575
|
+
if (!Number.isSafeInteger(calendar['sessions']) || (calendar['sessions'] as number) < 0)
|
|
1576
|
+
fail(
|
|
1577
|
+
functionName,
|
|
1578
|
+
'report.identity.calendar.sessions must be a non-negative safe integer.',
|
|
1579
|
+
ErrorCode.InputOutOfRange,
|
|
1580
|
+
{ field: 'report.identity.calendar.sessions' },
|
|
1581
|
+
);
|
|
1582
|
+
for (const key of ['firstMarkTimestampMs', 'lastMarkTimestampMs']) {
|
|
1583
|
+
const value = calendar[key];
|
|
1584
|
+
if (value !== null && (typeof value !== 'number' || !Number.isFinite(value)))
|
|
1585
|
+
fail(
|
|
1586
|
+
functionName,
|
|
1587
|
+
`report.identity.calendar.${key} must be a finite number or null.`,
|
|
1588
|
+
ErrorCode.InputWrongType,
|
|
1589
|
+
{ field: `report.identity.calendar.${key}` },
|
|
1590
|
+
);
|
|
1591
|
+
}
|
|
1592
|
+
const annualization = identity['annualization'] as Record<string, unknown>;
|
|
1593
|
+
ensureKnownKeys(functionName, 'report.identity.annualization', annualization, [
|
|
1594
|
+
'periodsPerYear',
|
|
1595
|
+
'riskFreeRate',
|
|
1596
|
+
]);
|
|
1597
|
+
if (
|
|
1598
|
+
typeof annualization['periodsPerYear'] !== 'number' ||
|
|
1599
|
+
!(annualization['periodsPerYear'] > 0) ||
|
|
1600
|
+
typeof annualization['riskFreeRate'] !== 'number' ||
|
|
1601
|
+
!Number.isFinite(annualization['riskFreeRate'])
|
|
1602
|
+
) {
|
|
1603
|
+
fail(
|
|
1604
|
+
functionName,
|
|
1605
|
+
'report.identity.annualization must carry a positive periodsPerYear and a finite riskFreeRate.',
|
|
1606
|
+
ErrorCode.InputOutOfRange,
|
|
1607
|
+
{ field: 'report.identity.annualization' },
|
|
1608
|
+
);
|
|
1609
|
+
}
|
|
1610
|
+
const models = identity['models'] as Record<string, unknown>;
|
|
1611
|
+
ensureKnownKeys(functionName, 'report.identity.models', models, [
|
|
1612
|
+
'execution',
|
|
1613
|
+
'commission',
|
|
1614
|
+
'slippage',
|
|
1615
|
+
]);
|
|
1616
|
+
for (const key of ['commission', 'slippage']) {
|
|
1617
|
+
const value = models[key];
|
|
1618
|
+
if (value !== null && (typeof value !== 'string' || value.length === 0))
|
|
1619
|
+
fail(
|
|
1620
|
+
functionName,
|
|
1621
|
+
`report.identity.models.${key} must be a label or null.`,
|
|
1622
|
+
ErrorCode.InputWrongType,
|
|
1623
|
+
{ field: `report.identity.models.${key}` },
|
|
1624
|
+
);
|
|
1625
|
+
}
|
|
1626
|
+
if (
|
|
1627
|
+
models['execution'] !== null &&
|
|
1628
|
+
(typeof models['execution'] !== 'object' || Array.isArray(models['execution']))
|
|
1629
|
+
)
|
|
1630
|
+
fail(
|
|
1631
|
+
functionName,
|
|
1632
|
+
'report.identity.models.execution must be an execution-policy description or null.',
|
|
1633
|
+
ErrorCode.InputWrongType,
|
|
1634
|
+
{ field: 'report.identity.models.execution' },
|
|
1635
|
+
);
|
|
1636
|
+
}
|
|
1637
|
+
|
|
1638
|
+
function requireReport(functionName: string, value: unknown): BacktestRunReport {
|
|
1639
|
+
requireArgumentObject(functionName, 'report', value);
|
|
1640
|
+
const record = value as Record<string, unknown>;
|
|
1641
|
+
ensureKnownKeys(functionName, 'report', record, REPORT_KEYS);
|
|
1642
|
+
for (const key of REPORT_KEYS) {
|
|
1643
|
+
if (!hasOwn(record, key))
|
|
1644
|
+
fail(
|
|
1645
|
+
functionName,
|
|
1646
|
+
`report.${key} is missing — not a backtest-run report.`,
|
|
1647
|
+
ErrorCode.InputMissingField,
|
|
1648
|
+
{ field: `report.${key}` },
|
|
1649
|
+
);
|
|
1650
|
+
}
|
|
1651
|
+
const kind = requireKind(functionName, record['kind']);
|
|
1652
|
+
const spec = specOf(kind);
|
|
1653
|
+
if (record['runVersion'] !== spec.descriptor.runVersion) {
|
|
1654
|
+
fail(
|
|
1655
|
+
functionName,
|
|
1656
|
+
`report.runVersion is ${String(record['runVersion'])}; this library reads '${kind}' runs at version ${spec.descriptor.runVersion} — register a migration.`,
|
|
1657
|
+
ErrorCode.InputOutOfRange,
|
|
1658
|
+
{ field: 'report.runVersion' },
|
|
1659
|
+
);
|
|
1660
|
+
}
|
|
1661
|
+
requireArgumentObject(functionName, 'report.run', record['run']);
|
|
1662
|
+
ensureKnownKeys(functionName, 'report.run', record['run'] as object, spec.runKeys);
|
|
1663
|
+
requireArgumentObject(functionName, 'report.inputs', record['inputs']);
|
|
1664
|
+
requireArgumentObject(functionName, 'report.referencedData', record['referencedData']);
|
|
1665
|
+
for (const [label, handle] of Object.entries(
|
|
1666
|
+
record['referencedData'] as Record<string, unknown>,
|
|
1667
|
+
)) {
|
|
1668
|
+
if (!isTableHandle(handle))
|
|
1669
|
+
fail(
|
|
1670
|
+
functionName,
|
|
1671
|
+
`report.referencedData.${label} is not a table handle.`,
|
|
1672
|
+
ErrorCode.InputWrongType,
|
|
1673
|
+
{ field: `report.referencedData.${label}` },
|
|
1674
|
+
);
|
|
1675
|
+
}
|
|
1676
|
+
if (typeof record['runHash'] !== 'string' || !record['runHash'].startsWith('sha256:')) {
|
|
1677
|
+
fail(
|
|
1678
|
+
functionName,
|
|
1679
|
+
'report.runHash must be a `sha256:` content hash.',
|
|
1680
|
+
ErrorCode.InputWrongType,
|
|
1681
|
+
{ field: 'report.runHash' },
|
|
1682
|
+
);
|
|
1683
|
+
}
|
|
1684
|
+
// The hash is the stored projection's: a report whose referenced result rows were restored by
|
|
1685
|
+
// the read door still verifies, because the handles stand in for the rows again here.
|
|
1686
|
+
let projection = record['run'] as Record<string, unknown>;
|
|
1687
|
+
for (const [label, handle] of Object.entries(
|
|
1688
|
+
record['referencedData'] as Record<string, TableHandle>,
|
|
1689
|
+
)) {
|
|
1690
|
+
const set = spec.resultRowSets.find((candidate) => candidate.label === label);
|
|
1691
|
+
if (set !== undefined && !isTableHandle(readPath(projection, set.path))) {
|
|
1692
|
+
projection = withPath(projection, set.path, handle) as Record<string, unknown>;
|
|
1693
|
+
}
|
|
1694
|
+
}
|
|
1695
|
+
const recomputedHash = contentHash(projection);
|
|
1696
|
+
if (recomputedHash !== record['runHash']) {
|
|
1697
|
+
fail(
|
|
1698
|
+
functionName,
|
|
1699
|
+
`report.runHash (${(record['runHash'] as string).slice(0, 18)}…) does not match the stored run (${recomputedHash.slice(0, 18)}…) — the report was altered after it was written.`,
|
|
1700
|
+
ErrorCode.ArtifactIdMismatch,
|
|
1701
|
+
{ field: 'report.runHash' },
|
|
1702
|
+
);
|
|
1703
|
+
}
|
|
1704
|
+
requireArgumentObject(functionName, 'report.identity', record['identity']);
|
|
1705
|
+
requireIdentity(functionName, record['identity'] as Record<string, unknown>);
|
|
1706
|
+
if (record['hygiene'] !== null)
|
|
1707
|
+
requireHygieneBlock(functionName, 'report.hygiene', record['hygiene']);
|
|
1708
|
+
requireArgumentObject(functionName, 'report.execution', record['execution']);
|
|
1709
|
+
ensureKnownKeys(functionName, 'report.execution', record['execution'] as object, ['completed']);
|
|
1710
|
+
if ((record['execution'] as { completed?: unknown }).completed !== true) {
|
|
1711
|
+
fail(
|
|
1712
|
+
functionName,
|
|
1713
|
+
'report.execution.completed must be true — a partial run is a Stage 7B format and cannot be read yet.',
|
|
1714
|
+
ErrorCode.InputOutOfRange,
|
|
1715
|
+
{ field: 'report.execution.completed' },
|
|
1716
|
+
);
|
|
1717
|
+
}
|
|
1718
|
+
requireArgumentObject(functionName, 'report.assumptions', record['assumptions']);
|
|
1719
|
+
ensureKnownKeys(
|
|
1720
|
+
functionName,
|
|
1721
|
+
'report.assumptions',
|
|
1722
|
+
record['assumptions'] as object,
|
|
1723
|
+
ASSUMPTION_KEYS,
|
|
1724
|
+
);
|
|
1725
|
+
const assumptions = record['assumptions'] as Record<string, unknown>;
|
|
1726
|
+
for (const key of ASSUMPTION_KEYS) {
|
|
1727
|
+
if (!hasOwn(assumptions, key))
|
|
1728
|
+
fail(functionName, `report.assumptions.${key} is missing.`, ErrorCode.InputMissingField, {
|
|
1729
|
+
field: `report.assumptions.${key}`,
|
|
1730
|
+
});
|
|
1731
|
+
}
|
|
1732
|
+
for (const key of ['conventionsVersion', 'operation', 'modelPolicy', 'projection'] as const) {
|
|
1733
|
+
if (typeof assumptions[key] !== 'string' || (assumptions[key] as string).length === 0) {
|
|
1734
|
+
fail(
|
|
1735
|
+
functionName,
|
|
1736
|
+
`report.assumptions.${key} must be a non-empty string. Received ${assumptions[key] === null ? 'null' : typeof assumptions[key]}.`,
|
|
1737
|
+
ErrorCode.InputWrongType,
|
|
1738
|
+
{ field: `report.assumptions.${key}` },
|
|
1739
|
+
);
|
|
1740
|
+
}
|
|
1741
|
+
}
|
|
1742
|
+
if (assumptions['kind'] !== kind)
|
|
1743
|
+
fail(
|
|
1744
|
+
functionName,
|
|
1745
|
+
`report.assumptions.kind must repeat report.kind ('${kind}').`,
|
|
1746
|
+
ErrorCode.InputOutOfRange,
|
|
1747
|
+
{ field: 'report.assumptions.kind' },
|
|
1748
|
+
);
|
|
1749
|
+
if (assumptions['runVersion'] !== record['runVersion'])
|
|
1750
|
+
fail(
|
|
1751
|
+
functionName,
|
|
1752
|
+
'report.assumptions.runVersion must repeat report.runVersion.',
|
|
1753
|
+
ErrorCode.InputOutOfRange,
|
|
1754
|
+
{ field: 'report.assumptions.runVersion' },
|
|
1755
|
+
);
|
|
1756
|
+
if (assumptions['operation'] !== spec.descriptor.operation)
|
|
1757
|
+
fail(
|
|
1758
|
+
functionName,
|
|
1759
|
+
`report.assumptions.operation must be '${spec.descriptor.operation}' for a '${kind}' run.`,
|
|
1760
|
+
ErrorCode.InputOutOfRange,
|
|
1761
|
+
{ field: 'report.assumptions.operation' },
|
|
1762
|
+
);
|
|
1763
|
+
if (typeof assumptions['replayable'] !== 'boolean')
|
|
1764
|
+
fail(
|
|
1765
|
+
functionName,
|
|
1766
|
+
'report.assumptions.replayable must be a boolean.',
|
|
1767
|
+
ErrorCode.InputWrongType,
|
|
1768
|
+
{ field: 'report.assumptions.replayable' },
|
|
1769
|
+
);
|
|
1770
|
+
if (
|
|
1771
|
+
assumptions['nonReplayableField'] !== null &&
|
|
1772
|
+
(typeof assumptions['nonReplayableField'] !== 'string' ||
|
|
1773
|
+
(assumptions['nonReplayableField'] as string).length === 0)
|
|
1774
|
+
) {
|
|
1775
|
+
fail(
|
|
1776
|
+
functionName,
|
|
1777
|
+
'report.assumptions.nonReplayableField must be a field path or null.',
|
|
1778
|
+
ErrorCode.InputWrongType,
|
|
1779
|
+
{ field: 'report.assumptions.nonReplayableField' },
|
|
1780
|
+
);
|
|
1781
|
+
}
|
|
1782
|
+
if ((assumptions['replayable'] === true) !== (assumptions['nonReplayableField'] === null)) {
|
|
1783
|
+
fail(
|
|
1784
|
+
functionName,
|
|
1785
|
+
'report.assumptions.replayable contradicts nonReplayableField — a run is replayable exactly when no callback field is recorded.',
|
|
1786
|
+
ErrorCode.InputOutOfRange,
|
|
1787
|
+
{ field: 'report.assumptions.replayable' },
|
|
1788
|
+
);
|
|
1789
|
+
}
|
|
1790
|
+
if (assumptions['inputPolicy'] !== 'embedded' && assumptions['inputPolicy'] !== 'referenced') {
|
|
1791
|
+
fail(
|
|
1792
|
+
functionName,
|
|
1793
|
+
`report.assumptions.inputPolicy must be 'embedded' | 'referenced'. Received ${JSON.stringify(assumptions['inputPolicy'])}.`,
|
|
1794
|
+
ErrorCode.InputInvalidEnum,
|
|
1795
|
+
{ field: 'report.assumptions.inputPolicy' },
|
|
1796
|
+
);
|
|
1797
|
+
}
|
|
1798
|
+
if (
|
|
1799
|
+
(assumptions['inputPolicy'] === 'referenced') !==
|
|
1800
|
+
Object.keys(record['referencedData'] as object).length > 0
|
|
1801
|
+
) {
|
|
1802
|
+
fail(
|
|
1803
|
+
functionName,
|
|
1804
|
+
'report.assumptions.inputPolicy contradicts referencedData — the policy is referenced exactly when a row set travels by handle.',
|
|
1805
|
+
ErrorCode.InputOutOfRange,
|
|
1806
|
+
{ field: 'report.assumptions.inputPolicy' },
|
|
1807
|
+
);
|
|
1808
|
+
}
|
|
1809
|
+
requireArgumentObject(functionName, 'report.diagnostics', record['diagnostics']);
|
|
1810
|
+
const diagnostics = record['diagnostics'] as Record<string, unknown>;
|
|
1811
|
+
ensureKnownKeys(functionName, 'report.diagnostics', diagnostics, DIAGNOSTIC_KEYS);
|
|
1812
|
+
for (const key of ['embeddedRows', 'referencedRows', 'runWarningCount'] as const) {
|
|
1813
|
+
const count = diagnostics[key];
|
|
1814
|
+
if (!Number.isSafeInteger(count) || (count as number) < 0) {
|
|
1815
|
+
fail(
|
|
1816
|
+
functionName,
|
|
1817
|
+
`report.diagnostics.${key} must be a non-negative safe integer. Received ${count === null ? 'null' : String(count)}.`,
|
|
1818
|
+
ErrorCode.InputOutOfRange,
|
|
1819
|
+
{ field: `report.diagnostics.${key}` },
|
|
1820
|
+
);
|
|
1821
|
+
}
|
|
1822
|
+
}
|
|
1823
|
+
if (!Array.isArray(diagnostics['warnings'])) {
|
|
1824
|
+
fail(functionName, 'report.diagnostics.warnings must be an array.', ErrorCode.InputWrongType, {
|
|
1825
|
+
field: 'report.diagnostics.warnings',
|
|
1826
|
+
});
|
|
1827
|
+
}
|
|
1828
|
+
const embeddedRowLimit = assumptions['embeddedRowLimit'];
|
|
1829
|
+
if (!Number.isSafeInteger(embeddedRowLimit) || (embeddedRowLimit as number) < 1) {
|
|
1830
|
+
fail(
|
|
1831
|
+
functionName,
|
|
1832
|
+
`report.assumptions.embeddedRowLimit must be a positive safe integer. Received ${embeddedRowLimit === null ? 'null' : String(embeddedRowLimit)}.`,
|
|
1833
|
+
ErrorCode.InputOutOfRange,
|
|
1834
|
+
{ field: 'report.assumptions.embeddedRowLimit' },
|
|
1835
|
+
);
|
|
1836
|
+
}
|
|
1837
|
+
return value as BacktestRunReport;
|
|
1838
|
+
}
|
|
1839
|
+
|
|
1840
|
+
// ─────────────────────────────────────────── the verbs ──────────────────────────────────────────
|
|
1841
|
+
|
|
1842
|
+
/**
|
|
1843
|
+
* Describe a run and save it as an identified, immutable artifact.
|
|
1844
|
+
*
|
|
1845
|
+
* @example
|
|
1846
|
+
* ```ts
|
|
1847
|
+
* const run = crossSectionalBacktest(request);
|
|
1848
|
+
* const artifact = backtestRunArtifact({
|
|
1849
|
+
* kind: 'cross-sectional',
|
|
1850
|
+
* run,
|
|
1851
|
+
* input: request,
|
|
1852
|
+
* referenceRowSets: ['dataset.returns', 'run.ledger.events'],
|
|
1853
|
+
* });
|
|
1854
|
+
* ```
|
|
1855
|
+
*/
|
|
1856
|
+
export function backtestRunArtifact<Kind extends BacktestRunKind>(
|
|
1857
|
+
input: BacktestRunArtifactInput<Kind>,
|
|
1858
|
+
): AnalysisArtifact {
|
|
1859
|
+
const functionName = 'backtestRunArtifact';
|
|
1860
|
+
requireArgumentObject(functionName, 'input', input);
|
|
1861
|
+
ensureKnownKeys(functionName, 'input', input, [
|
|
1862
|
+
'kind',
|
|
1863
|
+
'run',
|
|
1864
|
+
'input',
|
|
1865
|
+
'referenceRowSets',
|
|
1866
|
+
'locators',
|
|
1867
|
+
'hygiene',
|
|
1868
|
+
'snapshotHash',
|
|
1869
|
+
'libraryVersion',
|
|
1870
|
+
'createdFrom',
|
|
1871
|
+
'provenance',
|
|
1872
|
+
'limits',
|
|
1873
|
+
]);
|
|
1874
|
+
const kind = requireKind(functionName, input.kind);
|
|
1875
|
+
const spec = specOf(kind) as KindSpec<BacktestRunKind>;
|
|
1876
|
+
if (input.limits !== undefined) {
|
|
1877
|
+
requireArgumentObject(functionName, 'limits', input.limits);
|
|
1878
|
+
ensureKnownKeys(functionName, 'limits', input.limits, [
|
|
1879
|
+
'maximumEmbeddedBytes',
|
|
1880
|
+
'embeddedRowLimit',
|
|
1881
|
+
]);
|
|
1882
|
+
}
|
|
1883
|
+
const maximumEmbeddedBytes = requireWorkLimit({
|
|
1884
|
+
functionName,
|
|
1885
|
+
field: 'limits.maximumEmbeddedBytes',
|
|
1886
|
+
value: input.limits?.maximumEmbeddedBytes,
|
|
1887
|
+
law: BACKTEST_RUN_LIMITS.maximumEmbeddedBytes,
|
|
1888
|
+
});
|
|
1889
|
+
const embeddedRowLimit = requireWorkLimit({
|
|
1890
|
+
functionName,
|
|
1891
|
+
field: 'limits.embeddedRowLimit',
|
|
1892
|
+
value: input.limits?.embeddedRowLimit,
|
|
1893
|
+
law: BACKTEST_RUN_LIMITS.embeddedRowLimit,
|
|
1894
|
+
});
|
|
1895
|
+
const snapshotHash = requireSnapshotHash(functionName, input.snapshotHash);
|
|
1896
|
+
if (
|
|
1897
|
+
input.libraryVersion !== undefined &&
|
|
1898
|
+
(typeof input.libraryVersion !== 'string' || input.libraryVersion.length === 0)
|
|
1899
|
+
) {
|
|
1900
|
+
fail(
|
|
1901
|
+
functionName,
|
|
1902
|
+
'libraryVersion must be a non-empty version string when present.',
|
|
1903
|
+
ErrorCode.InputWrongType,
|
|
1904
|
+
{ field: 'libraryVersion' },
|
|
1905
|
+
);
|
|
1906
|
+
}
|
|
1907
|
+
if (input.createdFrom !== undefined)
|
|
1908
|
+
requireArgumentArray(functionName, 'createdFrom', input.createdFrom);
|
|
1909
|
+
if (input.referenceRowSets !== undefined)
|
|
1910
|
+
requireArgumentArray(functionName, 'referenceRowSets', input.referenceRowSets);
|
|
1911
|
+
const referenceRowSets = input.referenceRowSets ?? [];
|
|
1912
|
+
const knownLabels = [
|
|
1913
|
+
...spec.inputRowSets.map((s) => s.label),
|
|
1914
|
+
...spec.resultRowSets.map((s) => s.label),
|
|
1915
|
+
];
|
|
1916
|
+
for (const name of referenceRowSets) {
|
|
1917
|
+
if (typeof name !== 'string' || !knownLabels.includes(name)) {
|
|
1918
|
+
fail(
|
|
1919
|
+
functionName,
|
|
1920
|
+
`referenceRowSets names ${JSON.stringify(name)}, which is not a bulk row set of a '${kind}' run — its row sets are ${knownLabels.join(', ')}.`,
|
|
1921
|
+
ErrorCode.InputInvalidEnum,
|
|
1922
|
+
{ field: 'referenceRowSets', kind },
|
|
1923
|
+
);
|
|
1924
|
+
}
|
|
1925
|
+
}
|
|
1926
|
+
if (input.locators !== undefined) {
|
|
1927
|
+
requireArgumentObject(functionName, 'locators', input.locators);
|
|
1928
|
+
for (const [name, locator] of Object.entries(input.locators)) {
|
|
1929
|
+
if (!referenceRowSets.includes(name))
|
|
1930
|
+
fail(
|
|
1931
|
+
functionName,
|
|
1932
|
+
`locators.${name} names a row set that is not being referenced — list it in referenceRowSets.`,
|
|
1933
|
+
ErrorCode.InputUnknownField,
|
|
1934
|
+
{ field: `locators.${name}` },
|
|
1935
|
+
);
|
|
1936
|
+
if (typeof locator !== 'string' || locator.length === 0)
|
|
1937
|
+
fail(
|
|
1938
|
+
functionName,
|
|
1939
|
+
`locators.${name} must be a non-empty storage locator string.`,
|
|
1940
|
+
ErrorCode.InputWrongType,
|
|
1941
|
+
{ field: `locators.${name}` },
|
|
1942
|
+
);
|
|
1943
|
+
}
|
|
1944
|
+
}
|
|
1945
|
+
|
|
1946
|
+
// The run: the verb's result, a plain acyclic finite value.
|
|
1947
|
+
requireRunShape(functionName, 'run', spec, input.run);
|
|
1948
|
+
const projected = projectRun(
|
|
1949
|
+
input.run as unknown as Record<string, unknown>,
|
|
1950
|
+
spec,
|
|
1951
|
+
referenceRowSets,
|
|
1952
|
+
input.locators,
|
|
1953
|
+
);
|
|
1954
|
+
for (const [label, count] of Object.entries(projected.rowCounts)) {
|
|
1955
|
+
if (!referenceRowSets.includes(label) && count > embeddedRowLimit) {
|
|
1956
|
+
fail(
|
|
1957
|
+
functionName,
|
|
1958
|
+
`${label} has ${count} rows, above the embedded row limit ${embeddedRowLimit} — nothing is truncated silently. Reference the row set (referenceRowSets: ['${label}'], which stores its content hash and row count) or raise limits.embeddedRowLimit up to ${BACKTEST_RUN_LIMITS.embeddedRowLimit.maximum}.`,
|
|
1959
|
+
ErrorCode.ArtifactEmbeddedInputTooLarge,
|
|
1960
|
+
{ field: label, rows: count, embeddedRowLimit },
|
|
1961
|
+
);
|
|
1962
|
+
}
|
|
1963
|
+
}
|
|
1964
|
+
scanEmbedded(functionName, 'run', projected.stored, maximumEmbeddedBytes);
|
|
1965
|
+
const storedRun = detach(projected.stored);
|
|
1966
|
+
|
|
1967
|
+
// The request: the verb's own guard first (an artifact stores only a request the verb accepts),
|
|
1968
|
+
// then callbacks recorded and stripped, models by description, rows embedded or referenced.
|
|
1969
|
+
requireArgumentObject(functionName, 'input', input.input);
|
|
1970
|
+
spec.requireInput(functionName, 'input', input.input);
|
|
1971
|
+
let working = { ...(input.input as unknown as Record<string, unknown>) };
|
|
1972
|
+
let nonReplayableField: string | null = null;
|
|
1973
|
+
for (const callback of spec.callbacks) {
|
|
1974
|
+
const value = readPath(working, callback.path);
|
|
1975
|
+
if (value === undefined) continue;
|
|
1976
|
+
if (typeof value !== 'function') {
|
|
1977
|
+
fail(
|
|
1978
|
+
functionName,
|
|
1979
|
+
`input.${callback.field} is present but not a function — ${spec.descriptor.operation} would have refused this request, so it cannot be the request that produced the run.`,
|
|
1980
|
+
ErrorCode.InputWrongType,
|
|
1981
|
+
{ field: `input.${callback.field}` },
|
|
1982
|
+
);
|
|
1983
|
+
}
|
|
1984
|
+
nonReplayableField = nonReplayableField ?? callback.field;
|
|
1985
|
+
working = callback.strip(working);
|
|
1986
|
+
}
|
|
1987
|
+
for (const callback of spec.dynamicCallbacks(working)) {
|
|
1988
|
+
nonReplayableField = nonReplayableField ?? callback.field;
|
|
1989
|
+
working = callback.strip(working);
|
|
1990
|
+
}
|
|
1991
|
+
working = recordModels(functionName, working, spec.modelRoot);
|
|
1992
|
+
working = recordLabeledModels(functionName, working, spec.labeledModels);
|
|
1993
|
+
scanEmbedded(functionName, 'input', working, maximumEmbeddedBytes);
|
|
1994
|
+
let storedInput: Record<string, unknown> = detach(working);
|
|
1995
|
+
const referencedData: Record<string, TableHandle> = { ...projected.handles };
|
|
1996
|
+
let embeddedRows = projected.embeddedRows;
|
|
1997
|
+
for (const set of spec.inputRowSets) {
|
|
1998
|
+
const rows = readPath(storedInput, set.path);
|
|
1999
|
+
if (rows === undefined) {
|
|
2000
|
+
if (referenceRowSets.includes(set.label))
|
|
2001
|
+
fail(
|
|
2002
|
+
functionName,
|
|
2003
|
+
`referenceRowSets names '${set.label}', which this request does not carry.`,
|
|
2004
|
+
ErrorCode.InputInvalidEnum,
|
|
2005
|
+
{ field: 'referenceRowSets' },
|
|
2006
|
+
);
|
|
2007
|
+
continue;
|
|
2008
|
+
}
|
|
2009
|
+
if (!Array.isArray(rows))
|
|
2010
|
+
fail(
|
|
2011
|
+
functionName,
|
|
2012
|
+
`input.${set.label} must be the row array ${spec.descriptor.operation} consumed. Received ${rows === null ? 'null' : typeof rows}.`,
|
|
2013
|
+
ErrorCode.InputWrongType,
|
|
2014
|
+
{ field: `input.${set.label}` },
|
|
2015
|
+
);
|
|
2016
|
+
if (referenceRowSets.includes(set.label)) {
|
|
2017
|
+
const handle = tableHandleForRows({
|
|
2018
|
+
rows,
|
|
2019
|
+
...(input.locators?.[set.label] !== undefined
|
|
2020
|
+
? { locator: input.locators[set.label]! }
|
|
2021
|
+
: {}),
|
|
2022
|
+
});
|
|
2023
|
+
referencedData[set.label] = handle;
|
|
2024
|
+
storedInput = withPath(storedInput, set.path, handle) as Record<string, unknown>;
|
|
2025
|
+
} else if (rows.length > embeddedRowLimit) {
|
|
2026
|
+
fail(
|
|
2027
|
+
functionName,
|
|
2028
|
+
`input.${set.label} has ${rows.length} rows, above the embedded row limit ${embeddedRowLimit} — nothing is truncated silently. Reference the row set (referenceRowSets: ['${set.label}']) or raise limits.embeddedRowLimit up to ${BACKTEST_RUN_LIMITS.embeddedRowLimit.maximum}.`,
|
|
2029
|
+
ErrorCode.ArtifactEmbeddedInputTooLarge,
|
|
2030
|
+
{ field: `input.${set.label}`, rows: rows.length, embeddedRowLimit },
|
|
2031
|
+
);
|
|
2032
|
+
} else {
|
|
2033
|
+
embeddedRows += rows.length;
|
|
2034
|
+
}
|
|
2035
|
+
}
|
|
2036
|
+
const storedBytes = canonicalJsonOf(storedInput).length + canonicalJsonOf(storedRun).length;
|
|
2037
|
+
if (storedBytes > maximumEmbeddedBytes) {
|
|
2038
|
+
fail(
|
|
2039
|
+
functionName,
|
|
2040
|
+
`the embedded request and run are ${storedBytes.toLocaleString()} canonical bytes, above the limit ${maximumEmbeddedBytes.toLocaleString()} — reference the bulk row sets (referenceRowSets) or raise limits.maximumEmbeddedBytes up to ${BACKTEST_RUN_LIMITS.maximumEmbeddedBytes.maximum.toLocaleString()}.`,
|
|
2041
|
+
ErrorCode.ArtifactEmbeddedInputTooLarge,
|
|
2042
|
+
{ field: 'input', bytes: storedBytes, maximumEmbeddedBytes },
|
|
2043
|
+
);
|
|
2044
|
+
}
|
|
2045
|
+
|
|
2046
|
+
// Hygiene: a single run takes the caller's verdicts verbatim; a grid carries its own.
|
|
2047
|
+
let hygiene: BacktestHygieneBlock | null = null;
|
|
2048
|
+
if (kind === 'cross-sectional-grid') {
|
|
2049
|
+
if (input.hygiene !== undefined)
|
|
2050
|
+
fail(
|
|
2051
|
+
functionName,
|
|
2052
|
+
"a 'cross-sectional-grid' run carries its own hygiene at run.hygiene — omit input.hygiene.",
|
|
2053
|
+
ErrorCode.InputUnknownField,
|
|
2054
|
+
{ field: 'hygiene' },
|
|
2055
|
+
);
|
|
2056
|
+
const own = (input.run as unknown as CrossSectionalBacktestGridResult).hygiene;
|
|
2057
|
+
const block: BacktestHygieneBlock = {
|
|
2058
|
+
...(own.researchProtocol !== null
|
|
2059
|
+
? { researchProtocol: detach(own.researchProtocol) as unknown as Record<string, unknown> }
|
|
2060
|
+
: {}),
|
|
2061
|
+
...(own.deflatedSharpe !== null
|
|
2062
|
+
? { deflatedSharpe: detach(own.deflatedSharpe) as unknown as Record<string, unknown> }
|
|
2063
|
+
: {}),
|
|
2064
|
+
...(own.backtestOverfitting !== null
|
|
2065
|
+
? {
|
|
2066
|
+
backtestOverfitting: detach(own.backtestOverfitting) as unknown as Record<
|
|
2067
|
+
string,
|
|
2068
|
+
unknown
|
|
2069
|
+
>,
|
|
2070
|
+
}
|
|
2071
|
+
: {}),
|
|
2072
|
+
};
|
|
2073
|
+
hygiene = Object.keys(block).length > 0 ? block : null;
|
|
2074
|
+
} else if (input.hygiene !== undefined) {
|
|
2075
|
+
hygiene = detach(requireHygieneBlock(functionName, 'hygiene', input.hygiene));
|
|
2076
|
+
}
|
|
2077
|
+
|
|
2078
|
+
const report = buildReport({
|
|
2079
|
+
spec,
|
|
2080
|
+
run: input.run as unknown as Record<string, unknown>,
|
|
2081
|
+
storedRun,
|
|
2082
|
+
storedInput,
|
|
2083
|
+
referencedData,
|
|
2084
|
+
hygiene,
|
|
2085
|
+
nonReplayableField,
|
|
2086
|
+
embeddedRows,
|
|
2087
|
+
embeddedRowLimit,
|
|
2088
|
+
});
|
|
2089
|
+
const referenced = Object.fromEntries(
|
|
2090
|
+
Object.keys(referencedData)
|
|
2091
|
+
.sort()
|
|
2092
|
+
.map((label) => [label, referencedData[label]!.contentHash]),
|
|
2093
|
+
);
|
|
2094
|
+
return createAnalysisArtifact({
|
|
2095
|
+
artifactType: BACKTEST_RUN_ARTIFACT_TYPE,
|
|
2096
|
+
producedBy: {
|
|
2097
|
+
operation: spec.descriptor.operation,
|
|
2098
|
+
...(input.libraryVersion !== undefined ? { libraryVersion: input.libraryVersion } : {}),
|
|
2099
|
+
},
|
|
2100
|
+
inputs: {
|
|
2101
|
+
...(snapshotHash !== null ? { snapshotHash } : {}),
|
|
2102
|
+
parameters: {
|
|
2103
|
+
kind,
|
|
2104
|
+
runVersion: spec.descriptor.runVersion,
|
|
2105
|
+
runHash: report.runHash,
|
|
2106
|
+
runId: report.identity.runId,
|
|
2107
|
+
referenced,
|
|
2108
|
+
},
|
|
2109
|
+
},
|
|
2110
|
+
...(input.createdFrom !== undefined ? { createdFrom: input.createdFrom } : {}),
|
|
2111
|
+
result: report,
|
|
2112
|
+
...(Object.keys(referencedData).length > 0 ? { tables: referencedData } : {}),
|
|
2113
|
+
...(input.provenance !== undefined ? { provenance: input.provenance } : {}),
|
|
2114
|
+
});
|
|
2115
|
+
}
|
|
2116
|
+
|
|
2117
|
+
/** Restore referenced row sets into a report from supplied rows, each verified against its handle. */
|
|
2118
|
+
function restoreRows(
|
|
2119
|
+
functionName: string,
|
|
2120
|
+
report: BacktestRunReport,
|
|
2121
|
+
referencedData: Record<string, readonly unknown[]> | undefined,
|
|
2122
|
+
required: boolean,
|
|
2123
|
+
): { report: BacktestRunReport; restored: string[] } {
|
|
2124
|
+
const spec = specOf(report.kind);
|
|
2125
|
+
let run = report.run;
|
|
2126
|
+
let inputs = report.inputs;
|
|
2127
|
+
const restored: string[] = [];
|
|
2128
|
+
for (const label of Object.keys(report.referencedData).sort()) {
|
|
2129
|
+
const handle = report.referencedData[label]!;
|
|
2130
|
+
const rows = referencedData?.[label];
|
|
2131
|
+
if (rows === undefined) {
|
|
2132
|
+
if (required && !label.startsWith('run.'))
|
|
2133
|
+
fail(
|
|
2134
|
+
functionName,
|
|
2135
|
+
`the artifact references its '${label}' row set by table handle (${handle.rowCount} rows, ${handle.contentHash.slice(0, 18)}…) — supply the rows as referencedData['${label}'] to replay.`,
|
|
2136
|
+
ErrorCode.InputMissingField,
|
|
2137
|
+
{ field: `referencedData.${label}` },
|
|
2138
|
+
);
|
|
2139
|
+
continue;
|
|
2140
|
+
}
|
|
2141
|
+
const verified = detach(verifyReferencedRows({ functionName, label, handle, rows }));
|
|
2142
|
+
const resultSet = spec.resultRowSets.find((s) => s.label === label);
|
|
2143
|
+
if (resultSet !== undefined)
|
|
2144
|
+
run = withPath(run, resultSet.path, verified) as Record<string, unknown>;
|
|
2145
|
+
else {
|
|
2146
|
+
const inputSet = spec.inputRowSets.find((s) => s.label === label)!;
|
|
2147
|
+
inputs = withPath(inputs, inputSet.path, verified) as Record<string, unknown>;
|
|
2148
|
+
}
|
|
2149
|
+
restored.push(label);
|
|
2150
|
+
}
|
|
2151
|
+
if (referencedData !== undefined) {
|
|
2152
|
+
for (const label of Object.keys(referencedData)) {
|
|
2153
|
+
if (!(label in report.referencedData))
|
|
2154
|
+
fail(
|
|
2155
|
+
functionName,
|
|
2156
|
+
`referencedData['${label}'] names a row set the artifact does not reference — its referenced row sets are ${Object.keys(report.referencedData).sort().join(', ') || 'none'}.`,
|
|
2157
|
+
ErrorCode.InputUnknownField,
|
|
2158
|
+
{ field: `referencedData.${label}` },
|
|
2159
|
+
);
|
|
2160
|
+
}
|
|
2161
|
+
}
|
|
2162
|
+
return { report: { ...report, run, inputs }, restored };
|
|
2163
|
+
}
|
|
2164
|
+
|
|
2165
|
+
/**
|
|
2166
|
+
* Restore a run artifact: Gate B's read door, a foreign-type refusal, the run-level migration policy,
|
|
2167
|
+
* the report re-validated (its run hash recomputed), and any supplied referenced rows verified by
|
|
2168
|
+
* hash and restored into the report.
|
|
2169
|
+
*/
|
|
2170
|
+
export function readBacktestRun(input: {
|
|
2171
|
+
/** The artifact as held OR as restored from JSON (`fromCanonicalJson`) — validated at runtime, never trusted by declaration. */
|
|
2172
|
+
artifact: unknown;
|
|
2173
|
+
migrations?: ArtifactMigrationRegistry;
|
|
2174
|
+
/** Rows for referenced row sets, keyed by label; each is verified against its handle before it is restored. */
|
|
2175
|
+
referencedData?: Record<string, readonly unknown[]>;
|
|
2176
|
+
}): ReadBacktestRunResult {
|
|
2177
|
+
const functionName = 'readBacktestRun';
|
|
2178
|
+
requireArgumentObject(functionName, 'input', input);
|
|
2179
|
+
ensureKnownKeys(functionName, 'input', input, ['artifact', 'migrations', 'referencedData']);
|
|
2180
|
+
if (input.referencedData !== undefined)
|
|
2181
|
+
requireArgumentObject(functionName, 'referencedData', input.referencedData);
|
|
2182
|
+
const read = readAnalysisArtifact({
|
|
2183
|
+
artifact: input.artifact,
|
|
2184
|
+
...(input.migrations !== undefined ? { migrations: input.migrations } : {}),
|
|
2185
|
+
});
|
|
2186
|
+
const artifact = read.artifact;
|
|
2187
|
+
if (artifact.artifactType !== BACKTEST_RUN_ARTIFACT_TYPE) {
|
|
2188
|
+
fail(
|
|
2189
|
+
functionName,
|
|
2190
|
+
`the artifact's type is '${artifact.artifactType}', not '${BACKTEST_RUN_ARTIFACT_TYPE}' — this reader restores backtest runs only; ${artifact.artifactType.startsWith('research.') ? 'use @insiderfinance/totalfinance/research/artifacts' : artifact.artifactType.startsWith('volatility.') ? 'use @insiderfinance/totalfinance/volatility/artifacts' : artifact.artifactType.startsWith('fixed-income.') ? 'use @insiderfinance/totalfinance/fixed-income/artifacts' : 'read it with the package that owns that type'}.`,
|
|
2191
|
+
ErrorCode.ArtifactFamilyMismatch,
|
|
2192
|
+
{ artifactType: artifact.artifactType },
|
|
2193
|
+
);
|
|
2194
|
+
}
|
|
2195
|
+
const raw = artifact.result as Record<string, unknown>;
|
|
2196
|
+
const kind = requireKind(functionName, raw['kind']);
|
|
2197
|
+
const migrated = applyReportMigrations({
|
|
2198
|
+
functionName,
|
|
2199
|
+
kind: `${BACKTEST_RUN_ARTIFACT_TYPE}:${kind}`,
|
|
2200
|
+
report: raw,
|
|
2201
|
+
storedVersion: raw['runVersion'],
|
|
2202
|
+
currentVersion: specOf(kind).descriptor.runVersion,
|
|
2203
|
+
versionField: 'runVersion',
|
|
2204
|
+
subject: `'${kind}' run`,
|
|
2205
|
+
...(input.migrations !== undefined ? { migrations: input.migrations } : {}),
|
|
2206
|
+
});
|
|
2207
|
+
const validated = requireReport(functionName, migrated.report);
|
|
2208
|
+
const { report, restored } = restoreRows(
|
|
2209
|
+
functionName,
|
|
2210
|
+
detach(validated),
|
|
2211
|
+
input.referencedData,
|
|
2212
|
+
false,
|
|
2213
|
+
);
|
|
2214
|
+
return {
|
|
2215
|
+
report: deepFreeze(report),
|
|
2216
|
+
artifact,
|
|
2217
|
+
migrationsApplied: read.migrationsApplied,
|
|
2218
|
+
modelMigrationsApplied: migrated.modelMigrationsApplied,
|
|
2219
|
+
restoredRowSets: restored,
|
|
2220
|
+
};
|
|
2221
|
+
}
|
|
2222
|
+
|
|
2223
|
+
function liveModels(
|
|
2224
|
+
functionName: string,
|
|
2225
|
+
report: BacktestRunReport,
|
|
2226
|
+
models: ReplayModels | undefined,
|
|
2227
|
+
): {
|
|
2228
|
+
request: Record<string, unknown>;
|
|
2229
|
+
execution: 'recorded-default' | 'supplied' | 'none';
|
|
2230
|
+
transactionCostModel: 'supplied' | 'none';
|
|
2231
|
+
} {
|
|
2232
|
+
const spec = specOf(report.kind);
|
|
2233
|
+
let request = report.inputs;
|
|
2234
|
+
const recorded = readPath(request, spec.modelRoot) as Record<string, unknown>;
|
|
2235
|
+
let executionMode: 'recorded-default' | 'supplied' | 'none' = 'none';
|
|
2236
|
+
let costMode: 'supplied' | 'none' = 'none';
|
|
2237
|
+
if (models !== undefined) {
|
|
2238
|
+
requireArgumentObject(functionName, 'models', models);
|
|
2239
|
+
ensureKnownKeys(functionName, 'models', models, [
|
|
2240
|
+
'execution',
|
|
2241
|
+
'transactionCostModel',
|
|
2242
|
+
'labeled',
|
|
2243
|
+
]);
|
|
2244
|
+
}
|
|
2245
|
+
// The options kind's labeled models: each recorded label must be supplied by a model carrying it.
|
|
2246
|
+
const labeledSupplied = models?.labeled ?? {};
|
|
2247
|
+
if (models?.labeled !== undefined)
|
|
2248
|
+
requireArgumentObject(functionName, 'models.labeled', models.labeled);
|
|
2249
|
+
for (const dotted of spec.labeledModels) {
|
|
2250
|
+
const recordedLabel = (readPath(request, dotted.split('.')) as { label?: unknown } | undefined)
|
|
2251
|
+
?.label;
|
|
2252
|
+
const model = labeledSupplied[dotted];
|
|
2253
|
+
if (recordedLabel === undefined) {
|
|
2254
|
+
if (model !== undefined)
|
|
2255
|
+
fail(
|
|
2256
|
+
functionName,
|
|
2257
|
+
`models.labeled['${dotted}'] was supplied but the run recorded no model there — omit it.`,
|
|
2258
|
+
ErrorCode.InputUnknownField,
|
|
2259
|
+
{ field: `models.labeled.${dotted}` },
|
|
2260
|
+
);
|
|
2261
|
+
continue;
|
|
2262
|
+
}
|
|
2263
|
+
if (model === undefined)
|
|
2264
|
+
fail(
|
|
2265
|
+
functionName,
|
|
2266
|
+
`the run recorded the model '${String(recordedLabel)}' at ${dotted} that no artifact can carry — supply the live model as models.labeled['${dotted}']; its label is verified before the run.`,
|
|
2267
|
+
ErrorCode.InputMissingField,
|
|
2268
|
+
{ field: `models.labeled.${dotted}`, label: recordedLabel },
|
|
2269
|
+
);
|
|
2270
|
+
if (model.label !== recordedLabel)
|
|
2271
|
+
fail(
|
|
2272
|
+
functionName,
|
|
2273
|
+
`models.labeled['${dotted}'] is '${model.label}'; the run recorded '${String(recordedLabel)}'. A replay runs the models the run ran.`,
|
|
2274
|
+
ErrorCode.BacktestAdapterNonconformant,
|
|
2275
|
+
{ field: `models.labeled.${dotted}`, recorded: recordedLabel, supplied: model.label },
|
|
2276
|
+
);
|
|
2277
|
+
request = withPath(request, dotted.split('.'), model) as Record<string, unknown>;
|
|
2278
|
+
}
|
|
2279
|
+
for (const key of Object.keys(labeledSupplied)) {
|
|
2280
|
+
if (!spec.labeledModels.includes(key))
|
|
2281
|
+
fail(
|
|
2282
|
+
functionName,
|
|
2283
|
+
`models.labeled['${key}'] names no model path of a '${report.kind}' run — its model paths are ${spec.labeledModels.join(', ') || 'none'}.`,
|
|
2284
|
+
ErrorCode.InputUnknownField,
|
|
2285
|
+
{ field: `models.labeled.${key}` },
|
|
2286
|
+
);
|
|
2287
|
+
}
|
|
2288
|
+
const executionField = [...spec.modelRoot, 'execution'].join('.');
|
|
2289
|
+
if (recorded['execution'] !== undefined) {
|
|
2290
|
+
const description = recorded['execution'] as ExecutionPolicyDescription;
|
|
2291
|
+
let policy: ExecutionPolicy;
|
|
2292
|
+
if (models?.execution !== undefined) {
|
|
2293
|
+
policy = models.execution;
|
|
2294
|
+
executionMode = 'supplied';
|
|
2295
|
+
} else if (description.realism === 'simplified') {
|
|
2296
|
+
policy = executionPolicies.simplified();
|
|
2297
|
+
executionMode = 'recorded-default';
|
|
2298
|
+
} else {
|
|
2299
|
+
fail(
|
|
2300
|
+
functionName,
|
|
2301
|
+
`the run recorded a declared execution policy ('${description.label}') that no artifact can carry — supply the live policy as models.execution; it is verified against the recorded description before the run.`,
|
|
2302
|
+
ErrorCode.InputMissingField,
|
|
2303
|
+
{ field: 'models.execution', label: description.label },
|
|
2304
|
+
);
|
|
2305
|
+
}
|
|
2306
|
+
const supplied = describeExecutionPolicy(policy);
|
|
2307
|
+
if (canonicalJsonOf(supplied) !== canonicalJsonOf(description)) {
|
|
2308
|
+
fail(
|
|
2309
|
+
functionName,
|
|
2310
|
+
`models.execution does not match the recorded execution policy — recorded '${description.label}' (${description.realism}), supplied '${supplied.label}' (${supplied.realism}). A replay runs the policy the run ran.`,
|
|
2311
|
+
ErrorCode.BacktestAdapterNonconformant,
|
|
2312
|
+
{ field: 'models.execution', recorded: description.label, supplied: supplied.label },
|
|
2313
|
+
);
|
|
2314
|
+
}
|
|
2315
|
+
request = withPath(request, [...spec.modelRoot, 'execution'], policy) as Record<
|
|
2316
|
+
string,
|
|
2317
|
+
unknown
|
|
2318
|
+
>;
|
|
2319
|
+
} else if (models?.execution !== undefined) {
|
|
2320
|
+
fail(
|
|
2321
|
+
functionName,
|
|
2322
|
+
`models.execution was supplied but the run recorded no execution policy at ${executionField} (it ran the simplified default) — omit models.execution.`,
|
|
2323
|
+
ErrorCode.InputUnknownField,
|
|
2324
|
+
{ field: 'models.execution' },
|
|
2325
|
+
);
|
|
2326
|
+
}
|
|
2327
|
+
if (recorded['transactionCostModel'] !== undefined) {
|
|
2328
|
+
const labels = recorded['transactionCostModel'] as Record<string, string>;
|
|
2329
|
+
const supplied = models?.transactionCostModel;
|
|
2330
|
+
if (supplied === undefined) {
|
|
2331
|
+
fail(
|
|
2332
|
+
functionName,
|
|
2333
|
+
`the run recorded transaction-cost models by label (${Object.entries(labels)
|
|
2334
|
+
.map(([k, v]) => `${k}: ${v}`)
|
|
2335
|
+
.join(
|
|
2336
|
+
', ',
|
|
2337
|
+
)}) that no artifact can carry — supply the live models as models.transactionCostModel; each label is verified before the run.`,
|
|
2338
|
+
ErrorCode.InputMissingField,
|
|
2339
|
+
{ field: 'models.transactionCostModel', labels },
|
|
2340
|
+
);
|
|
2341
|
+
}
|
|
2342
|
+
requireArgumentObject(functionName, 'models.transactionCostModel', supplied);
|
|
2343
|
+
ensureKnownKeys(functionName, 'models.transactionCostModel', supplied as object, [
|
|
2344
|
+
'commission',
|
|
2345
|
+
'slippage',
|
|
2346
|
+
]);
|
|
2347
|
+
const live: Record<string, unknown> = {};
|
|
2348
|
+
for (const key of ['commission', 'slippage'] as const) {
|
|
2349
|
+
const recordedLabel = labels[key];
|
|
2350
|
+
const model = supplied[key];
|
|
2351
|
+
if (recordedLabel === undefined) {
|
|
2352
|
+
if (model !== undefined)
|
|
2353
|
+
fail(
|
|
2354
|
+
functionName,
|
|
2355
|
+
`models.transactionCostModel.${key} was supplied but the run recorded no ${key} model — omit it.`,
|
|
2356
|
+
ErrorCode.InputUnknownField,
|
|
2357
|
+
{ field: `models.transactionCostModel.${key}` },
|
|
2358
|
+
);
|
|
2359
|
+
continue;
|
|
2360
|
+
}
|
|
2361
|
+
if (model === undefined)
|
|
2362
|
+
fail(
|
|
2363
|
+
functionName,
|
|
2364
|
+
`models.transactionCostModel.${key} is missing — the run recorded '${recordedLabel}'.`,
|
|
2365
|
+
ErrorCode.InputMissingField,
|
|
2366
|
+
{ field: `models.transactionCostModel.${key}` },
|
|
2367
|
+
);
|
|
2368
|
+
if (model.label !== recordedLabel)
|
|
2369
|
+
fail(
|
|
2370
|
+
functionName,
|
|
2371
|
+
`models.transactionCostModel.${key} is '${model.label}'; the run recorded '${recordedLabel}'. A replay runs the models the run ran.`,
|
|
2372
|
+
ErrorCode.BacktestAdapterNonconformant,
|
|
2373
|
+
{
|
|
2374
|
+
field: `models.transactionCostModel.${key}`,
|
|
2375
|
+
recorded: recordedLabel,
|
|
2376
|
+
supplied: model.label,
|
|
2377
|
+
},
|
|
2378
|
+
);
|
|
2379
|
+
live[key] = model;
|
|
2380
|
+
}
|
|
2381
|
+
request = withPath(request, [...spec.modelRoot, 'transactionCostModel'], live) as Record<
|
|
2382
|
+
string,
|
|
2383
|
+
unknown
|
|
2384
|
+
>;
|
|
2385
|
+
costMode = 'supplied';
|
|
2386
|
+
} else if (models?.transactionCostModel !== undefined) {
|
|
2387
|
+
fail(
|
|
2388
|
+
functionName,
|
|
2389
|
+
'models.transactionCostModel was supplied but the run recorded no transaction-cost models — omit it.',
|
|
2390
|
+
ErrorCode.InputUnknownField,
|
|
2391
|
+
{ field: 'models.transactionCostModel' },
|
|
2392
|
+
);
|
|
2393
|
+
}
|
|
2394
|
+
return { request, execution: executionMode, transactionCostModel: costMode };
|
|
2395
|
+
}
|
|
2396
|
+
|
|
2397
|
+
/**
|
|
2398
|
+
* Re-issue the run's verb from the stored request (referenced rows supplied and re-verified, models
|
|
2399
|
+
* taken back and verified against their recorded descriptions) and compare the recomputed run hash
|
|
2400
|
+
* with the saved one. A run that recorded a caller function refuses by name.
|
|
2401
|
+
*/
|
|
2402
|
+
export function replayBacktestRun(input: {
|
|
2403
|
+
artifact: unknown;
|
|
2404
|
+
migrations?: ArtifactMigrationRegistry;
|
|
2405
|
+
referencedData?: Record<string, readonly unknown[]>;
|
|
2406
|
+
models?: ReplayModels;
|
|
2407
|
+
libraryVersion?: string;
|
|
2408
|
+
limits?: ComparisonLimits;
|
|
2409
|
+
}): BacktestRunReplay {
|
|
2410
|
+
const functionName = 'replayBacktestRun';
|
|
2411
|
+
requireArgumentObject(functionName, 'input', input);
|
|
2412
|
+
ensureKnownKeys(functionName, 'input', input, [
|
|
2413
|
+
'artifact',
|
|
2414
|
+
'migrations',
|
|
2415
|
+
'referencedData',
|
|
2416
|
+
'models',
|
|
2417
|
+
'libraryVersion',
|
|
2418
|
+
'limits',
|
|
2419
|
+
]);
|
|
2420
|
+
if (input.referencedData !== undefined)
|
|
2421
|
+
requireArgumentObject(functionName, 'referencedData', input.referencedData);
|
|
2422
|
+
const read = readBacktestRun({
|
|
2423
|
+
artifact: input.artifact,
|
|
2424
|
+
...(input.migrations !== undefined ? { migrations: input.migrations } : {}),
|
|
2425
|
+
});
|
|
2426
|
+
const report = read.report;
|
|
2427
|
+
const spec = specOf(report.kind) as KindSpec<BacktestRunKind>;
|
|
2428
|
+
if (!report.assumptions.replayable) {
|
|
2429
|
+
fail(
|
|
2430
|
+
functionName,
|
|
2431
|
+
`the '${report.kind}' run is not replayable: its request carried a caller function at ${report.assumptions.nonReplayableField ?? '(unrecorded)'} that no artifact can store — re-run ${spec.descriptor.operation} with the declarative form of that input and save that run.`,
|
|
2432
|
+
ErrorCode.ArtifactNotReplayable,
|
|
2433
|
+
{ kind: report.kind, field: report.assumptions.nonReplayableField },
|
|
2434
|
+
);
|
|
2435
|
+
}
|
|
2436
|
+
const restored = restoreRows(functionName, report, input.referencedData, true).report;
|
|
2437
|
+
const referencedResultSets = Object.keys(report.referencedData).filter((label) =>
|
|
2438
|
+
label.startsWith('run.'),
|
|
2439
|
+
);
|
|
2440
|
+
const models = liveModels(functionName, restored, input.models);
|
|
2441
|
+
const recomputedRun = spec.run(models.request as never) as unknown as Record<string, unknown>;
|
|
2442
|
+
const projected = projectRun(recomputedRun, spec, referencedResultSets, undefined);
|
|
2443
|
+
const recomputedReport = buildReport({
|
|
2444
|
+
spec,
|
|
2445
|
+
run: recomputedRun,
|
|
2446
|
+
storedRun: detach(projected.stored),
|
|
2447
|
+
storedInput: report.inputs,
|
|
2448
|
+
referencedData: { ...report.referencedData, ...projected.handles },
|
|
2449
|
+
hygiene: report.hygiene,
|
|
2450
|
+
nonReplayableField: report.assumptions.nonReplayableField,
|
|
2451
|
+
embeddedRows: report.diagnostics.embeddedRows,
|
|
2452
|
+
embeddedRowLimit: report.assumptions.embeddedRowLimit,
|
|
2453
|
+
});
|
|
2454
|
+
const parity = artifactReplayParity({
|
|
2455
|
+
saved: report.run,
|
|
2456
|
+
recomputed: recomputedReport.run,
|
|
2457
|
+
...(input.limits !== undefined ? { limits: input.limits } : {}),
|
|
2458
|
+
});
|
|
2459
|
+
const warnings: QuantWarning[] = [];
|
|
2460
|
+
const saved = read.artifact.producedBy.libraryVersion ?? null;
|
|
2461
|
+
const current = input.libraryVersion ?? null;
|
|
2462
|
+
if (saved !== null && current !== null && saved !== current) {
|
|
2463
|
+
warnings.push(
|
|
2464
|
+
warning(
|
|
2465
|
+
WarningCode.ArtifactLibraryVersionDiffers,
|
|
2466
|
+
`${functionName}: the artifact was produced by library version ${saved}; this replay runs ${current} — a parity difference may be a library change rather than a data change.`,
|
|
2467
|
+
'warn',
|
|
2468
|
+
{ saved, current },
|
|
2469
|
+
),
|
|
2470
|
+
);
|
|
2471
|
+
}
|
|
2472
|
+
if (!parity.identical) {
|
|
2473
|
+
warnings.push(
|
|
2474
|
+
warning(
|
|
2475
|
+
WarningCode.ArtifactLibraryVersionDiffers,
|
|
2476
|
+
`${functionName}: replay parity FAILED for '${report.kind}' — ${parity.differenceCount} difference${parity.differenceCount === 1 ? '' : 's'} between the saved run and the recomputation (first at ${parity.differences[0]?.path ?? parity.addedPaths[0] ?? parity.removedPaths[0] ?? '(unknown)'}). An engine is deterministic given its inputs, so this is a finding: a changed engine, dependency, model, or platform.`,
|
|
2477
|
+
'warn',
|
|
2478
|
+
{ differenceCount: parity.differenceCount },
|
|
2479
|
+
),
|
|
2480
|
+
);
|
|
2481
|
+
}
|
|
2482
|
+
return deepFreeze({
|
|
2483
|
+
kind: report.kind,
|
|
2484
|
+
artifactId: read.artifact.id,
|
|
2485
|
+
recomputed: deepFreeze(recomputedReport),
|
|
2486
|
+
runHash: { saved: report.runHash, recomputed: recomputedReport.runHash },
|
|
2487
|
+
matches: report.runHash === recomputedReport.runHash,
|
|
2488
|
+
parity,
|
|
2489
|
+
assumptions: {
|
|
2490
|
+
conventionsVersion: CONVENTIONS_VERSION,
|
|
2491
|
+
kind: report.kind,
|
|
2492
|
+
runVersion: report.runVersion,
|
|
2493
|
+
operation: spec.descriptor.operation,
|
|
2494
|
+
libraryVersion: { saved, current },
|
|
2495
|
+
referencedRowSets: Object.keys(report.referencedData).sort(),
|
|
2496
|
+
models: { execution: models.execution, transactionCostModel: models.transactionCostModel },
|
|
2497
|
+
},
|
|
2498
|
+
diagnostics: { warnings },
|
|
2499
|
+
});
|
|
2500
|
+
}
|
|
2501
|
+
|
|
2502
|
+
// ─────────────────────────────────────────── comparison ─────────────────────────────────────────
|
|
2503
|
+
|
|
2504
|
+
function resolveRun(
|
|
2505
|
+
functionName: string,
|
|
2506
|
+
value: unknown,
|
|
2507
|
+
field: string,
|
|
2508
|
+
): { report: BacktestRunReport; artifactId: string | null } {
|
|
2509
|
+
if (isArtifact(value)) {
|
|
2510
|
+
const read = readBacktestRun({ artifact: value });
|
|
2511
|
+
return { report: read.report, artifactId: read.artifact.id };
|
|
2512
|
+
}
|
|
2513
|
+
requireArgumentObject(functionName, field, value);
|
|
2514
|
+
return { report: requireReport(functionName, value), artifactId: null };
|
|
2515
|
+
}
|
|
2516
|
+
|
|
2517
|
+
/** The run as stored: referenced result row sets as their handles (a hydrated report projects back). */
|
|
2518
|
+
function storedProjection(report: BacktestRunReport): Record<string, unknown> {
|
|
2519
|
+
const spec = specOf(report.kind);
|
|
2520
|
+
let projection = report.run;
|
|
2521
|
+
for (const [label, handle] of Object.entries(report.referencedData)) {
|
|
2522
|
+
const set = spec.resultRowSets.find((candidate) => candidate.label === label);
|
|
2523
|
+
if (set !== undefined && !isTableHandle(readPath(projection, set.path))) {
|
|
2524
|
+
projection = withPath(projection, set.path, handle) as Record<string, unknown>;
|
|
2525
|
+
}
|
|
2526
|
+
}
|
|
2527
|
+
return projection;
|
|
2528
|
+
}
|
|
2529
|
+
|
|
2530
|
+
function idList(ids: readonly string[], listedIds: number): IdListSection {
|
|
2531
|
+
const sorted = [...ids].sort();
|
|
2532
|
+
return {
|
|
2533
|
+
count: sorted.length,
|
|
2534
|
+
ids: sorted.slice(0, listedIds),
|
|
2535
|
+
remainderCount: Math.max(0, sorted.length - listedIds),
|
|
2536
|
+
};
|
|
2537
|
+
}
|
|
2538
|
+
|
|
2539
|
+
function membership(
|
|
2540
|
+
baseline: readonly string[],
|
|
2541
|
+
candidate: readonly string[],
|
|
2542
|
+
listedIds: number,
|
|
2543
|
+
): MembershipSection {
|
|
2544
|
+
const left = new Set(baseline);
|
|
2545
|
+
const right = new Set(candidate);
|
|
2546
|
+
return {
|
|
2547
|
+
entered: idList(
|
|
2548
|
+
[...right].filter((id) => !left.has(id)),
|
|
2549
|
+
listedIds,
|
|
2550
|
+
),
|
|
2551
|
+
exited: idList(
|
|
2552
|
+
[...left].filter((id) => !right.has(id)),
|
|
2553
|
+
listedIds,
|
|
2554
|
+
),
|
|
2555
|
+
kept: idList(
|
|
2556
|
+
[...left].filter((id) => right.has(id)),
|
|
2557
|
+
listedIds,
|
|
2558
|
+
),
|
|
2559
|
+
};
|
|
2560
|
+
}
|
|
2561
|
+
|
|
2562
|
+
function finiteOrNull(value: unknown): number | null {
|
|
2563
|
+
return typeof value === 'number' && Number.isFinite(value) ? value : null;
|
|
2564
|
+
}
|
|
2565
|
+
|
|
2566
|
+
function metricsOf(report: BacktestRunReport): Record<string, number | null> {
|
|
2567
|
+
const run = report.run;
|
|
2568
|
+
if (report.kind === 'cross-sectional-grid') {
|
|
2569
|
+
const best = run['best'] as { index: number; value: number } | null;
|
|
2570
|
+
const variations = run['variations'];
|
|
2571
|
+
const row =
|
|
2572
|
+
best !== null && Array.isArray(variations)
|
|
2573
|
+
? (variations[best.index] as { metrics?: Record<string, unknown> } | undefined)
|
|
2574
|
+
: undefined;
|
|
2575
|
+
const metrics = row?.metrics ?? {};
|
|
2576
|
+
return Object.fromEntries(METRIC_NAMES.map((name) => [name, finiteOrNull(metrics[name])]));
|
|
2577
|
+
}
|
|
2578
|
+
// an environment episode carries the engine's own result under `result`
|
|
2579
|
+
const root =
|
|
2580
|
+
report.kind === 'environment' ? ((run['result'] ?? {}) as Record<string, unknown>) : run;
|
|
2581
|
+
const performance = (root['performance'] ?? {}) as Record<string, unknown>;
|
|
2582
|
+
const rebalances = root['rebalances'];
|
|
2583
|
+
let turnover: number | null = null;
|
|
2584
|
+
let costs: number | null = null;
|
|
2585
|
+
if (Array.isArray(rebalances)) {
|
|
2586
|
+
let t = 0;
|
|
2587
|
+
let c = 0;
|
|
2588
|
+
for (const r of rebalances as Array<{ turnover?: number; costs?: number }>) {
|
|
2589
|
+
t += finiteOrNull(r.turnover) ?? 0;
|
|
2590
|
+
c += finiteOrNull(r.costs) ?? 0;
|
|
2591
|
+
}
|
|
2592
|
+
turnover = rebalances.length > 0 ? t / rebalances.length : null;
|
|
2593
|
+
costs = c;
|
|
2594
|
+
}
|
|
2595
|
+
return {
|
|
2596
|
+
...Object.fromEntries(
|
|
2597
|
+
METRIC_NAMES.filter(
|
|
2598
|
+
(n) => n !== 'finalValue' && n !== 'meanTurnover' && n !== 'totalCosts',
|
|
2599
|
+
).map((name) => [name, finiteOrNull(performance[name])]),
|
|
2600
|
+
),
|
|
2601
|
+
finalValue: finiteOrNull(root['finalValue']),
|
|
2602
|
+
meanTurnover: turnover,
|
|
2603
|
+
totalCosts: costs,
|
|
2604
|
+
};
|
|
2605
|
+
}
|
|
2606
|
+
|
|
2607
|
+
function finalHoldings(report: BacktestRunReport): string[] | null {
|
|
2608
|
+
const holdings = report.run['holdings'];
|
|
2609
|
+
const rebalances = report.run['rebalances'];
|
|
2610
|
+
if (!Array.isArray(holdings) || !Array.isArray(rebalances) || rebalances.length === 0)
|
|
2611
|
+
return null;
|
|
2612
|
+
const last = rebalances.length - 1;
|
|
2613
|
+
return (holdings as Array<{ rebalanceIndex: number; instrumentId: string; quantity: number }>)
|
|
2614
|
+
.filter((h) => h.rebalanceIndex === last && h.quantity !== 0)
|
|
2615
|
+
.map((h) => h.instrumentId);
|
|
2616
|
+
}
|
|
2617
|
+
|
|
2618
|
+
function hygieneVerdict(report: BacktestRunReport): string | null {
|
|
2619
|
+
const verdict = report.hygiene?.researchProtocol?.['verdict'];
|
|
2620
|
+
return typeof verdict === 'string' ? verdict : null;
|
|
2621
|
+
}
|
|
2622
|
+
|
|
2623
|
+
/** Compare two runs of one kind: metric deltas, holdings membership, rebalance-by-rebalance turnover and cost deltas, grid variation deltas, the hygiene verdict, and the structural diff. */
|
|
2624
|
+
export function compareBacktestRuns<Kind extends BacktestRunKind>(input: {
|
|
2625
|
+
baseline: BacktestRunReport<Kind> | AnalysisArtifact;
|
|
2626
|
+
candidate: BacktestRunReport<Kind> | AnalysisArtifact;
|
|
2627
|
+
tolerance?: ComparisonTolerance;
|
|
2628
|
+
limits?: ComparisonLimits & { listedIds?: number };
|
|
2629
|
+
}): BacktestRunComparison<Kind> {
|
|
2630
|
+
const functionName = 'compareBacktestRuns';
|
|
2631
|
+
requireArgumentObject(functionName, 'input', input);
|
|
2632
|
+
ensureKnownKeys(functionName, 'input', input, ['baseline', 'candidate', 'tolerance', 'limits']);
|
|
2633
|
+
const tolerance = requireComparisonTolerance({ functionName, tolerance: input.tolerance });
|
|
2634
|
+
if (input.limits !== undefined) {
|
|
2635
|
+
requireArgumentObject(functionName, 'limits', input.limits);
|
|
2636
|
+
ensureKnownKeys(functionName, 'limits', input.limits, [
|
|
2637
|
+
'maximumDifferences',
|
|
2638
|
+
'maximumLeaves',
|
|
2639
|
+
'listedIds',
|
|
2640
|
+
]);
|
|
2641
|
+
}
|
|
2642
|
+
const listedIds = requireWorkLimit({
|
|
2643
|
+
functionName,
|
|
2644
|
+
field: 'limits.listedIds',
|
|
2645
|
+
value: input.limits?.listedIds,
|
|
2646
|
+
law: BACKTEST_RUN_LIMITS.listedIds,
|
|
2647
|
+
});
|
|
2648
|
+
const maximumDifferences = requireWorkLimit({
|
|
2649
|
+
functionName,
|
|
2650
|
+
field: 'limits.maximumDifferences',
|
|
2651
|
+
value: input.limits?.maximumDifferences,
|
|
2652
|
+
law: BACKTEST_RUN_LIMITS.maximumDifferences,
|
|
2653
|
+
});
|
|
2654
|
+
const maximumLeaves = requireWorkLimit({
|
|
2655
|
+
functionName,
|
|
2656
|
+
field: 'limits.maximumLeaves',
|
|
2657
|
+
value: input.limits?.maximumLeaves,
|
|
2658
|
+
law: BACKTEST_RUN_LIMITS.maximumLeaves,
|
|
2659
|
+
});
|
|
2660
|
+
const left = resolveRun(functionName, input.baseline, 'baseline');
|
|
2661
|
+
const right = resolveRun(functionName, input.candidate, 'candidate');
|
|
2662
|
+
if (left.report.kind !== right.report.kind) {
|
|
2663
|
+
fail(
|
|
2664
|
+
functionName,
|
|
2665
|
+
`baseline is a '${left.report.kind}' run and candidate a '${right.report.kind}' run — compare runs of one kind.`,
|
|
2666
|
+
ErrorCode.InputOutOfRange,
|
|
2667
|
+
{ baseline: left.report.kind, candidate: right.report.kind },
|
|
2668
|
+
);
|
|
2669
|
+
}
|
|
2670
|
+
const kind = left.report.kind as Kind;
|
|
2671
|
+
const warnings: QuantWarning[] = [];
|
|
2672
|
+
const within = (delta: number | null, base: number | null): boolean | null => {
|
|
2673
|
+
if (tolerance === null) return null;
|
|
2674
|
+
if (delta === null) return base === null;
|
|
2675
|
+
return Math.abs(delta) <= tolerance.absolute + tolerance.relative * Math.abs(base ?? 0);
|
|
2676
|
+
};
|
|
2677
|
+
const leftMetrics = metricsOf(left.report);
|
|
2678
|
+
const rightMetrics = metricsOf(right.report);
|
|
2679
|
+
const metrics: NamedDelta[] = METRIC_NAMES.map((name) => {
|
|
2680
|
+
const b = leftMetrics[name] ?? null;
|
|
2681
|
+
const c = rightMetrics[name] ?? null;
|
|
2682
|
+
const delta = b !== null && c !== null ? c - b : null;
|
|
2683
|
+
return {
|
|
2684
|
+
name,
|
|
2685
|
+
baselineValue: b,
|
|
2686
|
+
candidateValue: c,
|
|
2687
|
+
absoluteDelta: delta,
|
|
2688
|
+
withinTolerance:
|
|
2689
|
+
b === null && c === null ? (tolerance === null ? null : true) : within(delta, b),
|
|
2690
|
+
};
|
|
2691
|
+
});
|
|
2692
|
+
let holdings: MembershipSection | null = null;
|
|
2693
|
+
let rebalances: BacktestRunComparison['rebalances'] = null;
|
|
2694
|
+
let variations: BacktestRunComparison['variations'] = null;
|
|
2695
|
+
if (kind === 'cross-sectional') {
|
|
2696
|
+
const b = finalHoldings(left.report);
|
|
2697
|
+
const c = finalHoldings(right.report);
|
|
2698
|
+
holdings = b !== null && c !== null ? membership(b, c, listedIds) : null;
|
|
2699
|
+
const lb = left.report.run['rebalances'];
|
|
2700
|
+
const rb = right.report.run['rebalances'];
|
|
2701
|
+
if (Array.isArray(lb) && Array.isArray(rb)) {
|
|
2702
|
+
const compared = Math.min(lb.length, rb.length);
|
|
2703
|
+
const rows: RebalanceDelta[] = [];
|
|
2704
|
+
for (let i = 0; i < compared; i += 1) {
|
|
2705
|
+
const x = lb[i] as {
|
|
2706
|
+
sessionDate: string;
|
|
2707
|
+
turnover: number;
|
|
2708
|
+
costs: number;
|
|
2709
|
+
longCount: number;
|
|
2710
|
+
shortCount: number;
|
|
2711
|
+
};
|
|
2712
|
+
const y = rb[i] as {
|
|
2713
|
+
sessionDate: string;
|
|
2714
|
+
turnover: number;
|
|
2715
|
+
costs: number;
|
|
2716
|
+
longCount: number;
|
|
2717
|
+
shortCount: number;
|
|
2718
|
+
};
|
|
2719
|
+
rows.push({
|
|
2720
|
+
rebalanceIndex: i,
|
|
2721
|
+
sessionDate: { baseline: x.sessionDate, candidate: y.sessionDate },
|
|
2722
|
+
turnover: {
|
|
2723
|
+
baseline: x.turnover,
|
|
2724
|
+
candidate: y.turnover,
|
|
2725
|
+
absoluteDelta: y.turnover - x.turnover,
|
|
2726
|
+
},
|
|
2727
|
+
costs: { baseline: x.costs, candidate: y.costs, absoluteDelta: y.costs - x.costs },
|
|
2728
|
+
longCount: { baseline: x.longCount, candidate: y.longCount },
|
|
2729
|
+
shortCount: { baseline: x.shortCount, candidate: y.shortCount },
|
|
2730
|
+
});
|
|
2731
|
+
}
|
|
2732
|
+
rebalances = {
|
|
2733
|
+
compared,
|
|
2734
|
+
rows: rows.slice(0, listedIds),
|
|
2735
|
+
remainderCount: Math.max(0, rows.length - listedIds),
|
|
2736
|
+
};
|
|
2737
|
+
if (lb.length !== rb.length)
|
|
2738
|
+
warnings.push(
|
|
2739
|
+
warning(
|
|
2740
|
+
WarningCode.ArtifactLibraryVersionDiffers,
|
|
2741
|
+
`${functionName}: the runs have ${lb.length} and ${rb.length} rebalances; the first ${compared} were compared index by index.`,
|
|
2742
|
+
'info',
|
|
2743
|
+
{ baseline: lb.length, candidate: rb.length },
|
|
2744
|
+
),
|
|
2745
|
+
);
|
|
2746
|
+
} else {
|
|
2747
|
+
warnings.push(
|
|
2748
|
+
warning(
|
|
2749
|
+
WarningCode.ArtifactLibraryVersionDiffers,
|
|
2750
|
+
`${functionName}: a rebalance row set is referenced by table handle on at least one side — supply it through readBacktestRun's referencedData to compare rebalance by rebalance.`,
|
|
2751
|
+
'info',
|
|
2752
|
+
{},
|
|
2753
|
+
),
|
|
2754
|
+
);
|
|
2755
|
+
}
|
|
2756
|
+
} else {
|
|
2757
|
+
const lv = left.report.run['variations'];
|
|
2758
|
+
const rv = right.report.run['variations'];
|
|
2759
|
+
const metric = String(
|
|
2760
|
+
(left.report.run['assumptions'] as { selectionMetric?: string }).selectionMetric ?? 'sharpe',
|
|
2761
|
+
);
|
|
2762
|
+
if (Array.isArray(lv) && Array.isArray(rv)) {
|
|
2763
|
+
const key = (row: { parameters: Record<string, unknown> }): string =>
|
|
2764
|
+
canonicalJsonOf(row.parameters);
|
|
2765
|
+
const rightByKey = new Map(
|
|
2766
|
+
(
|
|
2767
|
+
rv as Array<{ parameters: Record<string, unknown>; metrics: Record<string, unknown> }>
|
|
2768
|
+
).map((row) => [key(row), row]),
|
|
2769
|
+
);
|
|
2770
|
+
const rows: VariationDelta[] = [];
|
|
2771
|
+
let matched = 0;
|
|
2772
|
+
for (const row of lv as Array<{
|
|
2773
|
+
parameters: Record<string, unknown>;
|
|
2774
|
+
metrics: Record<string, unknown>;
|
|
2775
|
+
}>) {
|
|
2776
|
+
const other = rightByKey.get(key(row));
|
|
2777
|
+
if (other === undefined) continue;
|
|
2778
|
+
matched += 1;
|
|
2779
|
+
const b = finiteOrNull(row.metrics[metric]);
|
|
2780
|
+
const c = finiteOrNull(other.metrics[metric]);
|
|
2781
|
+
rows.push({
|
|
2782
|
+
parameters: row.parameters,
|
|
2783
|
+
metric,
|
|
2784
|
+
baselineValue: b,
|
|
2785
|
+
candidateValue: c,
|
|
2786
|
+
absoluteDelta: b !== null && c !== null ? c - b : null,
|
|
2787
|
+
});
|
|
2788
|
+
}
|
|
2789
|
+
rows.sort(
|
|
2790
|
+
(x, y) =>
|
|
2791
|
+
Math.abs(y.absoluteDelta ?? 0) - Math.abs(x.absoluteDelta ?? 0) ||
|
|
2792
|
+
canonicalJsonOf(x.parameters).localeCompare(canonicalJsonOf(y.parameters)),
|
|
2793
|
+
);
|
|
2794
|
+
const lbest = left.report.run['best'] as { index: number } | null;
|
|
2795
|
+
const rbest = right.report.run['best'] as { index: number } | null;
|
|
2796
|
+
const lkey =
|
|
2797
|
+
lbest === null
|
|
2798
|
+
? null
|
|
2799
|
+
: key((lv as Array<{ parameters: Record<string, unknown> }>)[lbest.index]!);
|
|
2800
|
+
const rkey =
|
|
2801
|
+
rbest === null
|
|
2802
|
+
? null
|
|
2803
|
+
: key((rv as Array<{ parameters: Record<string, unknown> }>)[rbest.index]!);
|
|
2804
|
+
variations = {
|
|
2805
|
+
matched,
|
|
2806
|
+
baselineOnly: lv.length - matched,
|
|
2807
|
+
candidateOnly: rv.length - matched,
|
|
2808
|
+
rows: rows.slice(0, listedIds),
|
|
2809
|
+
remainderCount: Math.max(0, rows.length - listedIds),
|
|
2810
|
+
best: {
|
|
2811
|
+
baseline: lbest?.index ?? null,
|
|
2812
|
+
candidate: rbest?.index ?? null,
|
|
2813
|
+
moved: lkey !== rkey,
|
|
2814
|
+
},
|
|
2815
|
+
};
|
|
2816
|
+
} else {
|
|
2817
|
+
warnings.push(
|
|
2818
|
+
warning(
|
|
2819
|
+
WarningCode.ArtifactLibraryVersionDiffers,
|
|
2820
|
+
`${functionName}: the variations row set is referenced by table handle on at least one side — supply it through readBacktestRun's referencedData to compare variation by variation.`,
|
|
2821
|
+
'info',
|
|
2822
|
+
{},
|
|
2823
|
+
),
|
|
2824
|
+
);
|
|
2825
|
+
}
|
|
2826
|
+
}
|
|
2827
|
+
const lv = hygieneVerdict(left.report);
|
|
2828
|
+
const rv = hygieneVerdict(right.report);
|
|
2829
|
+
const hygiene =
|
|
2830
|
+
lv === null && rv === null ? null : { baseline: lv, candidate: rv, changed: lv !== rv };
|
|
2831
|
+
const parity = artifactReplayParity({
|
|
2832
|
+
saved: storedProjection(left.report),
|
|
2833
|
+
recomputed: storedProjection(right.report),
|
|
2834
|
+
limits: { maximumDifferences, maximumLeaves },
|
|
2835
|
+
});
|
|
2836
|
+
const li = left.report.identity;
|
|
2837
|
+
const ri = right.report.identity;
|
|
2838
|
+
const same = (a: unknown, b: unknown): boolean => canonicalJsonOf(a) === canonicalJsonOf(b);
|
|
2839
|
+
return deepFreeze({
|
|
2840
|
+
kind,
|
|
2841
|
+
artifactIds: { baseline: left.artifactId, candidate: right.artifactId },
|
|
2842
|
+
runHashes: { baseline: left.report.runHash, candidate: right.report.runHash },
|
|
2843
|
+
identical: left.report.runHash === right.report.runHash,
|
|
2844
|
+
sameInputs:
|
|
2845
|
+
same(left.report.inputs, right.report.inputs) &&
|
|
2846
|
+
same(left.report.referencedData, right.report.referencedData),
|
|
2847
|
+
sameUniverse:
|
|
2848
|
+
li.universeId === ri.universeId && li.universeHistoryHash === ri.universeHistoryHash,
|
|
2849
|
+
sameStrategy: same(li.strategy, ri.strategy),
|
|
2850
|
+
sameModels: same(li.models, ri.models),
|
|
2851
|
+
sameConventions: same(li.conventions, ri.conventions),
|
|
2852
|
+
metrics,
|
|
2853
|
+
holdings,
|
|
2854
|
+
rebalances,
|
|
2855
|
+
variations,
|
|
2856
|
+
hygiene,
|
|
2857
|
+
run: {
|
|
2858
|
+
differenceCount: parity.differenceCount,
|
|
2859
|
+
retainedDifferences: parity.differences.length,
|
|
2860
|
+
addedPaths: parity.addedPaths,
|
|
2861
|
+
removedPaths: parity.removedPaths,
|
|
2862
|
+
truncated: parity.truncated,
|
|
2863
|
+
},
|
|
2864
|
+
withinTolerance: tolerance === null ? null : metrics.every((m) => m.withinTolerance === true),
|
|
2865
|
+
assumptions: {
|
|
2866
|
+
conventionsVersion: CONVENTIONS_VERSION,
|
|
2867
|
+
kind,
|
|
2868
|
+
tolerance,
|
|
2869
|
+
limits: { maximumDifferences, maximumLeaves, listedIds },
|
|
2870
|
+
},
|
|
2871
|
+
diagnostics: { warnings },
|
|
2872
|
+
});
|
|
2873
|
+
}
|