openalgo-script 0.1.0-alpha.1 → 0.4.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/CHANGELOG.md +1469 -0
- package/README.md +85 -30
- package/dist/adapters/charts/alerts.d.ts +70 -0
- package/dist/adapters/charts/alerts.d.ts.map +1 -0
- package/dist/adapters/charts/alerts.js +52 -0
- package/dist/adapters/charts/alerts.js.map +1 -0
- package/dist/adapters/charts/bars.d.ts +39 -0
- package/dist/adapters/charts/bars.d.ts.map +1 -0
- package/dist/adapters/charts/bars.js +32 -0
- package/dist/adapters/charts/bars.js.map +1 -0
- package/dist/adapters/charts/candles.d.ts +40 -0
- package/dist/adapters/charts/candles.d.ts.map +1 -0
- package/dist/adapters/charts/candles.js +85 -0
- package/dist/adapters/charts/candles.js.map +1 -0
- package/dist/adapters/charts/colours.d.ts +47 -0
- package/dist/adapters/charts/colours.d.ts.map +1 -0
- package/dist/adapters/charts/colours.js +80 -0
- package/dist/adapters/charts/colours.js.map +1 -0
- package/dist/adapters/charts/columns.d.ts +37 -0
- package/dist/adapters/charts/columns.d.ts.map +1 -0
- package/dist/adapters/charts/columns.js +56 -0
- package/dist/adapters/charts/columns.js.map +1 -0
- package/dist/adapters/charts/contract.d.ts +278 -0
- package/dist/adapters/charts/contract.d.ts.map +1 -0
- package/dist/adapters/charts/contract.js +2 -0
- package/dist/adapters/charts/contract.js.map +1 -0
- package/dist/adapters/charts/descriptor.d.ts +48 -0
- package/dist/adapters/charts/descriptor.d.ts.map +1 -0
- package/dist/adapters/charts/descriptor.js +111 -0
- package/dist/adapters/charts/descriptor.js.map +1 -0
- package/dist/adapters/charts/drawings.d.ts +43 -0
- package/dist/adapters/charts/drawings.d.ts.map +1 -0
- package/dist/adapters/charts/drawings.js +172 -0
- package/dist/adapters/charts/drawings.js.map +1 -0
- package/dist/adapters/charts/errors.d.ts +28 -0
- package/dist/adapters/charts/errors.d.ts.map +1 -0
- package/dist/adapters/charts/errors.js +21 -0
- package/dist/adapters/charts/errors.js.map +1 -0
- package/dist/adapters/charts/fields.d.ts +33 -0
- package/dist/adapters/charts/fields.d.ts.map +1 -0
- package/dist/adapters/charts/fields.js +51 -0
- package/dist/adapters/charts/fields.js.map +1 -0
- package/dist/adapters/charts/fills.d.ts +23 -0
- package/dist/adapters/charts/fills.d.ts.map +1 -0
- package/dist/adapters/charts/fills.js +48 -0
- package/dist/adapters/charts/fills.js.map +1 -0
- package/dist/adapters/charts/index.d.ts +37 -0
- package/dist/adapters/charts/index.d.ts.map +1 -0
- package/dist/adapters/charts/index.js +33 -0
- package/dist/adapters/charts/index.js.map +1 -0
- package/dist/adapters/charts/levels.d.ts +39 -0
- package/dist/adapters/charts/levels.d.ts.map +1 -0
- package/dist/adapters/charts/levels.js +61 -0
- package/dist/adapters/charts/levels.js.map +1 -0
- package/dist/adapters/charts/markers.d.ts +41 -0
- package/dist/adapters/charts/markers.d.ts.map +1 -0
- package/dist/adapters/charts/markers.js +75 -0
- package/dist/adapters/charts/markers.js.map +1 -0
- package/dist/adapters/charts/paint.d.ts +61 -0
- package/dist/adapters/charts/paint.d.ts.map +1 -0
- package/dist/adapters/charts/paint.js +47 -0
- package/dist/adapters/charts/paint.js.map +1 -0
- package/dist/adapters/charts/plots.d.ts +39 -0
- package/dist/adapters/charts/plots.d.ts.map +1 -0
- package/dist/adapters/charts/plots.js +117 -0
- package/dist/adapters/charts/plots.js.map +1 -0
- package/dist/adapters/charts/produced.d.ts +57 -0
- package/dist/adapters/charts/produced.d.ts.map +1 -0
- package/dist/adapters/charts/produced.js +11 -0
- package/dist/adapters/charts/produced.js.map +1 -0
- package/dist/adapters/charts/requests.d.ts +114 -0
- package/dist/adapters/charts/requests.d.ts.map +1 -0
- package/dist/adapters/charts/requests.js +277 -0
- package/dist/adapters/charts/requests.js.map +1 -0
- package/dist/adapters/charts/run.d.ts +147 -0
- package/dist/adapters/charts/run.d.ts.map +1 -0
- package/dist/adapters/charts/run.js +148 -0
- package/dist/adapters/charts/run.js.map +1 -0
- package/dist/adapters/charts/settings.d.ts +78 -0
- package/dist/adapters/charts/settings.d.ts.map +1 -0
- package/dist/adapters/charts/settings.js +225 -0
- package/dist/adapters/charts/settings.js.map +1 -0
- package/dist/adapters/charts/surfaces.d.ts +221 -0
- package/dist/adapters/charts/surfaces.d.ts.map +1 -0
- package/dist/adapters/charts/surfaces.js +2 -0
- package/dist/adapters/charts/surfaces.js.map +1 -0
- package/dist/adapters/charts/tables.d.ts +65 -0
- package/dist/adapters/charts/tables.d.ts.map +1 -0
- package/dist/adapters/charts/tables.js +166 -0
- package/dist/adapters/charts/tables.js.map +1 -0
- package/dist/adapters/codemirror/commands.d.ts +14 -0
- package/dist/adapters/codemirror/commands.d.ts.map +1 -0
- package/dist/adapters/codemirror/commands.js +52 -0
- package/dist/adapters/codemirror/commands.js.map +1 -0
- package/dist/adapters/codemirror/completion.d.ts +15 -0
- package/dist/adapters/codemirror/completion.d.ts.map +1 -0
- package/dist/adapters/codemirror/completion.js +64 -0
- package/dist/adapters/codemirror/completion.js.map +1 -0
- package/dist/adapters/codemirror/contract.d.ts +156 -0
- package/dist/adapters/codemirror/contract.d.ts.map +1 -0
- package/dist/adapters/codemirror/contract.js +42 -0
- package/dist/adapters/codemirror/contract.js.map +1 -0
- package/dist/adapters/codemirror/index.d.ts +43 -0
- package/dist/adapters/codemirror/index.d.ts.map +1 -0
- package/dist/adapters/codemirror/index.js +8 -0
- package/dist/adapters/codemirror/index.js.map +1 -0
- package/dist/adapters/codemirror/lint.d.ts +17 -0
- package/dist/adapters/codemirror/lint.d.ts.map +1 -0
- package/dist/adapters/codemirror/lint.js +62 -0
- package/dist/adapters/codemirror/lint.js.map +1 -0
- package/dist/adapters/codemirror/positions.d.ts +16 -0
- package/dist/adapters/codemirror/positions.d.ts.map +1 -0
- package/dist/adapters/codemirror/positions.js +65 -0
- package/dist/adapters/codemirror/positions.js.map +1 -0
- package/dist/adapters/codemirror/stream.d.ts +23 -0
- package/dist/adapters/codemirror/stream.d.ts.map +1 -0
- package/dist/adapters/codemirror/stream.js +70 -0
- package/dist/adapters/codemirror/stream.js.map +1 -0
- package/dist/adapters/codemirror/tokens.d.ts +44 -0
- package/dist/adapters/codemirror/tokens.d.ts.map +1 -0
- package/dist/adapters/codemirror/tokens.js +34 -0
- package/dist/adapters/codemirror/tokens.js.map +1 -0
- package/dist/adapters/codemirror/tooltips.d.ts +35 -0
- package/dist/adapters/codemirror/tooltips.d.ts.map +1 -0
- package/dist/adapters/codemirror/tooltips.js +108 -0
- package/dist/adapters/codemirror/tooltips.js.map +1 -0
- package/dist/core/accounting/charges.d.ts +136 -0
- package/dist/core/accounting/charges.d.ts.map +1 -0
- package/dist/core/accounting/charges.js +362 -0
- package/dist/core/accounting/charges.js.map +1 -0
- package/dist/core/accounting/equity.d.ts +158 -0
- package/dist/core/accounting/equity.d.ts.map +1 -0
- package/dist/core/accounting/equity.js +155 -0
- package/dist/core/accounting/equity.js.map +1 -0
- package/dist/core/accounting/index.d.ts +44 -0
- package/dist/core/accounting/index.d.ts.map +1 -0
- package/dist/core/accounting/index.js +36 -0
- package/dist/core/accounting/index.js.map +1 -0
- package/dist/core/accounting/markers.d.ts +43 -0
- package/dist/core/accounting/markers.d.ts.map +1 -0
- package/dist/core/accounting/markers.js +64 -0
- package/dist/core/accounting/markers.js.map +1 -0
- package/dist/core/accounting/monthly.d.ts +52 -0
- package/dist/core/accounting/monthly.d.ts.map +1 -0
- package/dist/core/accounting/monthly.js +99 -0
- package/dist/core/accounting/monthly.js.map +1 -0
- package/dist/core/accounting/report.d.ts +38 -0
- package/dist/core/accounting/report.d.ts.map +1 -0
- package/dist/core/accounting/report.js +63 -0
- package/dist/core/accounting/report.js.map +1 -0
- package/dist/core/accounting/shapes.d.ts +70 -0
- package/dist/core/accounting/shapes.d.ts.map +1 -0
- package/dist/core/accounting/shapes.js +21 -0
- package/dist/core/accounting/shapes.js.map +1 -0
- package/dist/core/accounting/statistics.d.ts +75 -0
- package/dist/core/accounting/statistics.d.ts.map +1 -0
- package/dist/core/accounting/statistics.js +246 -0
- package/dist/core/accounting/statistics.js.map +1 -0
- package/dist/core/accounting/trades.d.ts +118 -0
- package/dist/core/accounting/trades.d.ts.map +1 -0
- package/dist/core/accounting/trades.js +186 -0
- package/dist/core/accounting/trades.js.map +1 -0
- package/dist/core/backtest/compare.d.ts +38 -0
- package/dist/core/backtest/compare.d.ts.map +1 -0
- package/dist/core/backtest/compare.js +189 -0
- package/dist/core/backtest/compare.js.map +1 -0
- package/dist/core/backtest/declaration.d.ts +52 -0
- package/dist/core/backtest/declaration.d.ts.map +1 -0
- package/dist/core/backtest/declaration.js +48 -0
- package/dist/core/backtest/declaration.js.map +1 -0
- package/dist/core/backtest/drive.d.ts +29 -0
- package/dist/core/backtest/drive.d.ts.map +1 -0
- package/dist/core/backtest/drive.js +262 -0
- package/dist/core/backtest/drive.js.map +1 -0
- package/dist/core/backtest/index.d.ts +46 -0
- package/dist/core/backtest/index.d.ts.map +1 -0
- package/dist/core/backtest/index.js +36 -0
- package/dist/core/backtest/index.js.map +1 -0
- package/dist/core/backtest/range.d.ts +84 -0
- package/dist/core/backtest/range.d.ts.map +1 -0
- package/dist/core/backtest/range.js +90 -0
- package/dist/core/backtest/range.js.map +1 -0
- package/dist/core/backtest/record.d.ts +238 -0
- package/dist/core/backtest/record.d.ts.map +1 -0
- package/dist/core/backtest/record.js +176 -0
- package/dist/core/backtest/record.js.map +1 -0
- package/dist/core/backtest/replay.d.ts +48 -0
- package/dist/core/backtest/replay.d.ts.map +1 -0
- package/dist/core/backtest/replay.js +127 -0
- package/dist/core/backtest/replay.js.map +1 -0
- package/dist/core/backtest/resting.d.ts +62 -0
- package/dist/core/backtest/resting.d.ts.map +1 -0
- package/dist/core/backtest/resting.js +59 -0
- package/dist/core/backtest/resting.js.map +1 -0
- package/dist/core/backtest/settings.d.ts +117 -0
- package/dist/core/backtest/settings.d.ts.map +1 -0
- package/dist/core/backtest/settings.js +207 -0
- package/dist/core/backtest/settings.js.map +1 -0
- package/dist/core/backtest/simulate.d.ts +146 -0
- package/dist/core/backtest/simulate.d.ts.map +1 -0
- package/dist/core/backtest/simulate.js +217 -0
- package/dist/core/backtest/simulate.js.map +1 -0
- package/dist/core/catalogue/catalogue.generated.d.ts +164 -10
- package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
- package/dist/core/catalogue/catalogue.generated.js +23 -9
- package/dist/core/catalogue/catalogue.generated.js.map +1 -1
- package/dist/core/catalogue/values.generated.d.ts +49 -0
- package/dist/core/catalogue/values.generated.d.ts.map +1 -1
- package/dist/core/check/arguments.d.ts +41 -0
- package/dist/core/check/arguments.d.ts.map +1 -0
- package/dist/core/check/arguments.js +84 -0
- package/dist/core/check/arguments.js.map +1 -0
- package/dist/core/check/call-sites.d.ts +22 -0
- package/dist/core/check/call-sites.d.ts.map +1 -0
- package/dist/core/check/call-sites.js +329 -0
- package/dist/core/check/call-sites.js.map +1 -0
- package/dist/core/check/call-warmup.d.ts +37 -0
- package/dist/core/check/call-warmup.d.ts.map +1 -0
- package/dist/core/check/call-warmup.js +97 -0
- package/dist/core/check/call-warmup.js.map +1 -0
- package/dist/core/check/calls.d.ts +33 -0
- package/dist/core/check/calls.d.ts.map +1 -0
- package/dist/core/check/calls.js +348 -0
- package/dist/core/check/calls.js.map +1 -0
- package/dist/core/check/check.d.ts +23 -0
- package/dist/core/check/check.d.ts.map +1 -0
- package/dist/core/check/check.js +163 -0
- package/dist/core/check/check.js.map +1 -0
- package/dist/core/check/checked.d.ts +198 -0
- package/dist/core/check/checked.d.ts.map +1 -0
- package/dist/core/check/checked.js +19 -0
- package/dist/core/check/checked.js.map +1 -0
- package/dist/core/check/checker.d.ts +182 -0
- package/dist/core/check/checker.d.ts.map +1 -0
- package/dist/core/check/checker.js +280 -0
- package/dist/core/check/checker.js.map +1 -0
- package/dist/core/check/conditional.d.ts +35 -0
- package/dist/core/check/conditional.d.ts.map +1 -0
- package/dist/core/check/conditional.js +100 -0
- package/dist/core/check/conditional.js.map +1 -0
- package/dist/core/check/constant.d.ts +47 -0
- package/dist/core/check/constant.d.ts.map +1 -0
- package/dist/core/check/constant.js +101 -0
- package/dist/core/check/constant.js.map +1 -0
- package/dist/core/check/declaration.d.ts +33 -0
- package/dist/core/check/declaration.d.ts.map +1 -0
- package/dist/core/check/declaration.js +181 -0
- package/dist/core/check/declaration.js.map +1 -0
- package/dist/core/check/expressions.d.ts +36 -0
- package/dist/core/check/expressions.d.ts.map +1 -0
- package/dist/core/check/expressions.js +398 -0
- package/dist/core/check/expressions.js.map +1 -0
- package/dist/core/check/functions.d.ts +31 -0
- package/dist/core/check/functions.d.ts.map +1 -0
- package/dist/core/check/functions.js +238 -0
- package/dist/core/check/functions.js.map +1 -0
- package/dist/core/check/handles.d.ts +48 -0
- package/dist/core/check/handles.d.ts.map +1 -0
- package/dist/core/check/handles.js +43 -0
- package/dist/core/check/handles.js.map +1 -0
- package/dist/core/check/index.d.ts +31 -0
- package/dist/core/check/index.d.ts.map +1 -0
- package/dist/core/check/index.js +26 -0
- package/dist/core/check/index.js.map +1 -0
- package/dist/core/check/library-bars.d.ts +7 -0
- package/dist/core/check/library-bars.d.ts.map +1 -0
- package/dist/core/check/library-bars.js +181 -0
- package/dist/core/check/library-bars.js.map +1 -0
- package/dist/core/check/library-orders.d.ts +5 -0
- package/dist/core/check/library-orders.d.ts.map +1 -0
- package/dist/core/check/library-orders.js +250 -0
- package/dist/core/check/library-orders.js.map +1 -0
- package/dist/core/check/library-output.d.ts +7 -0
- package/dist/core/check/library-output.d.ts.map +1 -0
- package/dist/core/check/library-output.js +195 -0
- package/dist/core/check/library-output.js.map +1 -0
- package/dist/core/check/library-prose.generated.d.ts +16 -0
- package/dist/core/check/library-prose.generated.d.ts.map +1 -0
- package/dist/core/check/library-prose.generated.js +353 -0
- package/dist/core/check/library-prose.generated.js.map +1 -0
- package/dist/core/check/library-series.d.ts +3 -0
- package/dist/core/check/library-series.d.ts.map +1 -0
- package/dist/core/check/library-series.js +415 -0
- package/dist/core/check/library-series.js.map +1 -0
- package/dist/core/check/library.d.ts +204 -0
- package/dist/core/check/library.d.ts.map +1 -0
- package/dist/core/check/library.js +198 -0
- package/dist/core/check/library.js.map +1 -0
- package/dist/core/check/literals.d.ts +19 -0
- package/dist/core/check/literals.d.ts.map +1 -0
- package/dist/core/check/literals.js +22 -0
- package/dist/core/check/literals.js.map +1 -0
- package/dist/core/check/outputs.d.ts +31 -0
- package/dist/core/check/outputs.d.ts.map +1 -0
- package/dist/core/check/outputs.js +113 -0
- package/dist/core/check/outputs.js.map +1 -0
- package/dist/core/check/statements.d.ts +25 -0
- package/dist/core/check/statements.d.ts.map +1 -0
- package/dist/core/check/statements.js +377 -0
- package/dist/core/check/statements.js.map +1 -0
- package/dist/core/check/suggest.d.ts +25 -0
- package/dist/core/check/suggest.d.ts.map +1 -0
- package/dist/core/check/suggest.js +61 -0
- package/dist/core/check/suggest.js.map +1 -0
- package/dist/core/check/surface.d.ts +62 -0
- package/dist/core/check/surface.d.ts.map +1 -0
- package/dist/core/check/surface.js +129 -0
- package/dist/core/check/surface.js.map +1 -0
- package/dist/core/check/tags.d.ts +4 -0
- package/dist/core/check/tags.d.ts.map +1 -0
- package/dist/core/check/tags.js +54 -0
- package/dist/core/check/tags.js.map +1 -0
- package/dist/core/check/types.d.ts +153 -0
- package/dist/core/check/types.d.ts.map +1 -0
- package/dist/core/check/types.js +221 -0
- package/dist/core/check/types.js.map +1 -0
- package/dist/core/check/warmup.d.ts +73 -0
- package/dist/core/check/warmup.d.ts.map +1 -0
- package/dist/core/check/warmup.js +62 -0
- package/dist/core/check/warmup.js.map +1 -0
- package/dist/core/diagnostics/collector.d.ts +12 -0
- package/dist/core/diagnostics/collector.d.ts.map +1 -1
- package/dist/core/diagnostics/collector.js +27 -1
- package/dist/core/diagnostics/collector.js.map +1 -1
- package/dist/core/emit/calls.d.ts +38 -0
- package/dist/core/emit/calls.d.ts.map +1 -0
- package/dist/core/emit/calls.js +347 -0
- package/dist/core/emit/calls.js.map +1 -0
- package/dist/core/emit/canonical.d.ts +39 -0
- package/dist/core/emit/canonical.d.ts.map +1 -0
- package/dist/core/emit/canonical.js +71 -0
- package/dist/core/emit/canonical.js.map +1 -0
- package/dist/core/emit/channels.d.ts +28 -0
- package/dist/core/emit/channels.d.ts.map +1 -0
- package/dist/core/emit/channels.js +110 -0
- package/dist/core/emit/channels.js.map +1 -0
- package/dist/core/emit/code.d.ts +75 -0
- package/dist/core/emit/code.d.ts.map +1 -0
- package/dist/core/emit/code.js +104 -0
- package/dist/core/emit/code.js.map +1 -0
- package/dist/core/emit/colours.d.ts +35 -0
- package/dist/core/emit/colours.d.ts.map +1 -0
- package/dist/core/emit/colours.js +50 -0
- package/dist/core/emit/colours.js.map +1 -0
- package/dist/core/emit/context.d.ts +271 -0
- package/dist/core/emit/context.d.ts.map +1 -0
- package/dist/core/emit/context.js +358 -0
- package/dist/core/emit/context.js.map +1 -0
- package/dist/core/emit/defaults.d.ts +64 -0
- package/dist/core/emit/defaults.d.ts.map +1 -0
- package/dist/core/emit/defaults.js +182 -0
- package/dist/core/emit/defaults.js.map +1 -0
- package/dist/core/emit/emit.d.ts +13 -0
- package/dist/core/emit/emit.d.ts.map +1 -0
- package/dist/core/emit/emit.js +281 -0
- package/dist/core/emit/emit.js.map +1 -0
- package/dist/core/emit/events.d.ts +21 -0
- package/dist/core/emit/events.d.ts.map +1 -0
- package/dist/core/emit/events.js +112 -0
- package/dist/core/emit/events.js.map +1 -0
- package/dist/core/emit/expressions.d.ts +23 -0
- package/dist/core/emit/expressions.d.ts.map +1 -0
- package/dist/core/emit/expressions.js +253 -0
- package/dist/core/emit/expressions.js.map +1 -0
- package/dist/core/emit/functions.d.ts +30 -0
- package/dist/core/emit/functions.d.ts.map +1 -0
- package/dist/core/emit/functions.js +171 -0
- package/dist/core/emit/functions.js.map +1 -0
- package/dist/core/emit/gaps.d.ts +34 -0
- package/dist/core/emit/gaps.d.ts.map +1 -0
- package/dist/core/emit/gaps.js +16 -0
- package/dist/core/emit/gaps.js.map +1 -0
- package/dist/core/emit/index.d.ts +31 -0
- package/dist/core/emit/index.d.ts.map +1 -0
- package/dist/core/emit/index.js +25 -0
- package/dist/core/emit/index.js.map +1 -0
- package/dist/core/emit/inputs.d.ts +47 -0
- package/dist/core/emit/inputs.d.ts.map +1 -0
- package/dist/core/emit/inputs.js +150 -0
- package/dist/core/emit/inputs.js.map +1 -0
- package/dist/core/emit/layout.d.ts +73 -0
- package/dist/core/emit/layout.d.ts.map +1 -0
- package/dist/core/emit/layout.js +126 -0
- package/dist/core/emit/layout.js.map +1 -0
- package/dist/core/emit/meta.d.ts +14 -0
- package/dist/core/emit/meta.d.ts.map +1 -0
- package/dist/core/emit/meta.js +68 -0
- package/dist/core/emit/meta.js.map +1 -0
- package/dist/core/emit/opcodes.d.ts +28 -0
- package/dist/core/emit/opcodes.d.ts.map +1 -0
- package/dist/core/emit/opcodes.js +137 -0
- package/dist/core/emit/opcodes.js.map +1 -0
- package/dist/core/emit/outputs.d.ts +67 -0
- package/dist/core/emit/outputs.d.ts.map +1 -0
- package/dist/core/emit/outputs.js +293 -0
- package/dist/core/emit/outputs.js.map +1 -0
- package/dist/core/emit/pool.d.ts +33 -0
- package/dist/core/emit/pool.d.ts.map +1 -0
- package/dist/core/emit/pool.js +79 -0
- package/dist/core/emit/pool.js.map +1 -0
- package/dist/core/emit/program.d.ts +333 -0
- package/dist/core/emit/program.d.ts.map +1 -0
- package/dist/core/emit/program.js +15 -0
- package/dist/core/emit/program.js.map +1 -0
- package/dist/core/emit/registers.d.ts +35 -0
- package/dist/core/emit/registers.d.ts.map +1 -0
- package/dist/core/emit/registers.js +170 -0
- package/dist/core/emit/registers.js.map +1 -0
- package/dist/core/emit/request-scope.d.ts +36 -0
- package/dist/core/emit/request-scope.d.ts.map +1 -0
- package/dist/core/emit/request-scope.js +41 -0
- package/dist/core/emit/request-scope.js.map +1 -0
- package/dist/core/emit/requests.d.ts +69 -0
- package/dist/core/emit/requests.d.ts.map +1 -0
- package/dist/core/emit/requests.js +230 -0
- package/dist/core/emit/requests.js.map +1 -0
- package/dist/core/emit/requires.d.ts +4 -0
- package/dist/core/emit/requires.d.ts.map +1 -0
- package/dist/core/emit/requires.js +71 -0
- package/dist/core/emit/requires.js.map +1 -0
- package/dist/core/emit/sha256.d.ts +24 -0
- package/dist/core/emit/sha256.d.ts.map +1 -0
- package/dist/core/emit/sha256.js +109 -0
- package/dist/core/emit/sha256.js.map +1 -0
- package/dist/core/emit/statements.d.ts +20 -0
- package/dist/core/emit/statements.d.ts.map +1 -0
- package/dist/core/emit/statements.js +393 -0
- package/dist/core/emit/statements.js.map +1 -0
- package/dist/core/emit/values.d.ts +80 -0
- package/dist/core/emit/values.d.ts.map +1 -0
- package/dist/core/emit/values.js +242 -0
- package/dist/core/emit/values.js.map +1 -0
- package/dist/core/engine/alerts.d.ts +66 -0
- package/dist/core/engine/alerts.d.ts.map +1 -0
- package/dist/core/engine/alerts.js +119 -0
- package/dist/core/engine/alerts.js.map +1 -0
- package/dist/core/engine/arithmetic.d.ts +82 -0
- package/dist/core/engine/arithmetic.d.ts.map +1 -0
- package/dist/core/engine/arithmetic.js +141 -0
- package/dist/core/engine/arithmetic.js.map +1 -0
- package/dist/core/engine/bars.d.ts +95 -0
- package/dist/core/engine/bars.d.ts.map +1 -0
- package/dist/core/engine/bars.js +133 -0
- package/dist/core/engine/bars.js.map +1 -0
- package/dist/core/engine/budget.d.ts +162 -0
- package/dist/core/engine/budget.d.ts.map +1 -0
- package/dist/core/engine/budget.js +188 -0
- package/dist/core/engine/budget.js.map +1 -0
- package/dist/core/engine/channels.d.ts +106 -0
- package/dist/core/engine/channels.d.ts.map +1 -0
- package/dist/core/engine/channels.js +99 -0
- package/dist/core/engine/channels.js.map +1 -0
- package/dist/core/engine/drawings.d.ts +64 -0
- package/dist/core/engine/drawings.d.ts.map +1 -0
- package/dist/core/engine/drawings.js +67 -0
- package/dist/core/engine/drawings.js.map +1 -0
- package/dist/core/engine/engine.d.ts +140 -0
- package/dist/core/engine/engine.d.ts.map +1 -0
- package/dist/core/engine/engine.js +405 -0
- package/dist/core/engine/engine.js.map +1 -0
- package/dist/core/engine/errors.d.ts +64 -0
- package/dist/core/engine/errors.d.ts.map +1 -0
- package/dist/core/engine/errors.js +63 -0
- package/dist/core/engine/errors.js.map +1 -0
- package/dist/core/engine/frames.d.ts +48 -0
- package/dist/core/engine/frames.d.ts.map +1 -0
- package/dist/core/engine/frames.js +41 -0
- package/dist/core/engine/frames.js.map +1 -0
- package/dist/core/engine/grids.d.ts +25 -0
- package/dist/core/engine/grids.d.ts.map +1 -0
- package/dist/core/engine/grids.js +77 -0
- package/dist/core/engine/grids.js.map +1 -0
- package/dist/core/engine/guard.d.ts +4 -0
- package/dist/core/engine/guard.d.ts.map +1 -0
- package/dist/core/engine/guard.js +46 -0
- package/dist/core/engine/guard.js.map +1 -0
- package/dist/core/engine/host.d.ts +219 -0
- package/dist/core/engine/host.d.ts.map +1 -0
- package/dist/core/engine/host.js +38 -0
- package/dist/core/engine/host.js.map +1 -0
- package/dist/core/engine/index.d.ts +49 -0
- package/dist/core/engine/index.d.ts.map +1 -0
- package/dist/core/engine/index.js +33 -0
- package/dist/core/engine/index.js.map +1 -0
- package/dist/core/engine/inputs.d.ts +77 -0
- package/dist/core/engine/inputs.d.ts.map +1 -0
- package/dist/core/engine/inputs.js +205 -0
- package/dist/core/engine/inputs.js.map +1 -0
- package/dist/core/engine/ledger/call.d.ts +63 -0
- package/dist/core/engine/ledger/call.d.ts.map +1 -0
- package/dist/core/engine/ledger/call.js +136 -0
- package/dist/core/engine/ledger/call.js.map +1 -0
- package/dist/core/engine/ledger/closable.d.ts +155 -0
- package/dist/core/engine/ledger/closable.d.ts.map +1 -0
- package/dist/core/engine/ledger/closable.js +173 -0
- package/dist/core/engine/ledger/closable.js.map +1 -0
- package/dist/core/engine/ledger/holdings.d.ts +194 -0
- package/dist/core/engine/ledger/holdings.d.ts.map +1 -0
- package/dist/core/engine/ledger/holdings.js +237 -0
- package/dist/core/engine/ledger/holdings.js.map +1 -0
- package/dist/core/engine/ledger/index.d.ts +19 -0
- package/dist/core/engine/ledger/index.d.ts.map +1 -0
- package/dist/core/engine/ledger/index.js +2 -0
- package/dist/core/engine/ledger/index.js.map +1 -0
- package/dist/core/engine/ledger/intent.d.ts +106 -0
- package/dist/core/engine/ledger/intent.d.ts.map +1 -0
- package/dist/core/engine/ledger/intent.js +21 -0
- package/dist/core/engine/ledger/intent.js.map +1 -0
- package/dist/core/engine/ledger/ledger.d.ts +143 -0
- package/dist/core/engine/ledger/ledger.d.ts.map +1 -0
- package/dist/core/engine/ledger/ledger.js +237 -0
- package/dist/core/engine/ledger/ledger.js.map +1 -0
- package/dist/core/engine/ledger/place.d.ts +75 -0
- package/dist/core/engine/ledger/place.d.ts.map +1 -0
- package/dist/core/engine/ledger/place.js +174 -0
- package/dist/core/engine/ledger/place.js.map +1 -0
- package/dist/core/engine/ledger/positions.d.ts +68 -0
- package/dist/core/engine/ledger/positions.d.ts.map +1 -0
- package/dist/core/engine/ledger/positions.js +114 -0
- package/dist/core/engine/ledger/positions.js.map +1 -0
- package/dist/core/engine/ledger/refuse.d.ts +43 -0
- package/dist/core/engine/ledger/refuse.d.ts.map +1 -0
- package/dist/core/engine/ledger/refuse.js +329 -0
- package/dist/core/engine/ledger/refuse.js.map +1 -0
- package/dist/core/engine/ledger/row.d.ts +176 -0
- package/dist/core/engine/ledger/row.d.ts.map +1 -0
- package/dist/core/engine/ledger/row.js +169 -0
- package/dist/core/engine/ledger/row.js.map +1 -0
- package/dist/core/engine/ledger/sizing.d.ts +142 -0
- package/dist/core/engine/ledger/sizing.d.ts.map +1 -0
- package/dist/core/engine/ledger/sizing.js +223 -0
- package/dist/core/engine/ledger/sizing.js.map +1 -0
- package/dist/core/engine/library/arrays.d.ts +14 -0
- package/dist/core/engine/library/arrays.d.ts.map +1 -0
- package/dist/core/engine/library/arrays.js +285 -0
- package/dist/core/engine/library/arrays.js.map +1 -0
- package/dist/core/engine/library/averages.d.ts +9 -0
- package/dist/core/engine/library/averages.d.ts.map +1 -0
- package/dist/core/engine/library/averages.js +41 -0
- package/dist/core/engine/library/averages.js.map +1 -0
- package/dist/core/engine/library/binding.d.ts +230 -0
- package/dist/core/engine/library/binding.d.ts.map +1 -0
- package/dist/core/engine/library/binding.js +109 -0
- package/dist/core/engine/library/binding.js.map +1 -0
- package/dist/core/engine/library/chart.d.ts +3 -0
- package/dist/core/engine/library/chart.d.ts.map +1 -0
- package/dist/core/engine/library/chart.js +83 -0
- package/dist/core/engine/library/chart.js.map +1 -0
- package/dist/core/engine/library/colours.d.ts +26 -0
- package/dist/core/engine/library/colours.d.ts.map +1 -0
- package/dist/core/engine/library/colours.js +81 -0
- package/dist/core/engine/library/colours.js.map +1 -0
- package/dist/core/engine/library/dates.d.ts +3 -0
- package/dist/core/engine/library/dates.d.ts.map +1 -0
- package/dist/core/engine/library/dates.js +75 -0
- package/dist/core/engine/library/dates.js.map +1 -0
- package/dist/core/engine/library/index.d.ts +13 -0
- package/dist/core/engine/library/index.d.ts.map +1 -0
- package/dist/core/engine/library/index.js +86 -0
- package/dist/core/engine/library/index.js.map +1 -0
- package/dist/core/engine/library/maths.d.ts +3 -0
- package/dist/core/engine/library/maths.d.ts.map +1 -0
- package/dist/core/engine/library/maths.js +89 -0
- package/dist/core/engine/library/maths.js.map +1 -0
- package/dist/core/engine/library/objects.d.ts +3 -0
- package/dist/core/engine/library/objects.d.ts.map +1 -0
- package/dist/core/engine/library/objects.js +199 -0
- package/dist/core/engine/library/objects.js.map +1 -0
- package/dist/core/engine/library/oscillators.d.ts +3 -0
- package/dist/core/engine/library/oscillators.d.ts.map +1 -0
- package/dist/core/engine/library/oscillators.js +29 -0
- package/dist/core/engine/library/oscillators.js.map +1 -0
- package/dist/core/engine/library/ranges.d.ts +3 -0
- package/dist/core/engine/library/ranges.d.ts.map +1 -0
- package/dist/core/engine/library/ranges.js +23 -0
- package/dist/core/engine/library/ranges.js.map +1 -0
- package/dist/core/engine/library/series.d.ts +3 -0
- package/dist/core/engine/library/series.d.ts.map +1 -0
- package/dist/core/engine/library/series.js +46 -0
- package/dist/core/engine/library/series.js.map +1 -0
- package/dist/core/engine/library/state.d.ts +35 -0
- package/dist/core/engine/library/state.d.ts.map +1 -0
- package/dist/core/engine/library/state.js +19 -0
- package/dist/core/engine/library/state.js.map +1 -0
- package/dist/core/engine/library/studies.d.ts +3 -0
- package/dist/core/engine/library/studies.d.ts.map +1 -0
- package/dist/core/engine/library/studies.js +35 -0
- package/dist/core/engine/library/studies.js.map +1 -0
- package/dist/core/engine/library/text.d.ts +6 -0
- package/dist/core/engine/library/text.d.ts.map +1 -0
- package/dist/core/engine/library/text.js +280 -0
- package/dist/core/engine/library/text.js.map +1 -0
- package/dist/core/engine/library/trend.d.ts +3 -0
- package/dist/core/engine/library/trend.d.ts.map +1 -0
- package/dist/core/engine/library/trend.js +29 -0
- package/dist/core/engine/library/trend.js.map +1 -0
- package/dist/core/engine/library/volume.d.ts +3 -0
- package/dist/core/engine/library/volume.d.ts.map +1 -0
- package/dist/core/engine/library/volume.js +51 -0
- package/dist/core/engine/library/volume.js.map +1 -0
- package/dist/core/engine/load.d.ts +59 -0
- package/dist/core/engine/load.d.ts.map +1 -0
- package/dist/core/engine/load.js +61 -0
- package/dist/core/engine/load.js.map +1 -0
- package/dist/core/engine/machine.d.ts +107 -0
- package/dist/core/engine/machine.d.ts.map +1 -0
- package/dist/core/engine/machine.js +337 -0
- package/dist/core/engine/machine.js.map +1 -0
- package/dist/core/engine/memory.d.ts +60 -0
- package/dist/core/engine/memory.d.ts.map +1 -0
- package/dist/core/engine/memory.js +92 -0
- package/dist/core/engine/memory.js.map +1 -0
- package/dist/core/engine/operations.d.ts +62 -0
- package/dist/core/engine/operations.d.ts.map +1 -0
- package/dist/core/engine/operations.js +149 -0
- package/dist/core/engine/operations.js.map +1 -0
- package/dist/core/engine/orders.d.ts +56 -0
- package/dist/core/engine/orders.d.ts.map +1 -0
- package/dist/core/engine/orders.js +83 -0
- package/dist/core/engine/orders.js.map +1 -0
- package/dist/core/engine/registers.d.ts +50 -0
- package/dist/core/engine/registers.d.ts.map +1 -0
- package/dist/core/engine/registers.js +85 -0
- package/dist/core/engine/registers.js.map +1 -0
- package/dist/core/engine/request-body.d.ts +138 -0
- package/dist/core/engine/request-body.d.ts.map +1 -0
- package/dist/core/engine/request-body.js +227 -0
- package/dist/core/engine/request-body.js.map +1 -0
- package/dist/core/engine/request-plan.d.ts +79 -0
- package/dist/core/engine/request-plan.d.ts.map +1 -0
- package/dist/core/engine/request-plan.js +228 -0
- package/dist/core/engine/request-plan.js.map +1 -0
- package/dist/core/engine/requests.d.ts +105 -0
- package/dist/core/engine/requests.d.ts.map +1 -0
- package/dist/core/engine/requests.js +260 -0
- package/dist/core/engine/requests.js.map +1 -0
- package/dist/core/engine/results.d.ts +40 -0
- package/dist/core/engine/results.d.ts.map +1 -0
- package/dist/core/engine/results.js +2 -0
- package/dist/core/engine/results.js.map +1 -0
- package/dist/core/engine/series.d.ts +61 -0
- package/dist/core/engine/series.d.ts.map +1 -0
- package/dist/core/engine/series.js +41 -0
- package/dist/core/engine/series.js.map +1 -0
- package/dist/core/engine/session/hours.d.ts +49 -0
- package/dist/core/engine/session/hours.d.ts.map +1 -0
- package/dist/core/engine/session/hours.js +31 -0
- package/dist/core/engine/session/hours.js.map +1 -0
- package/dist/core/engine/session/index.d.ts +17 -0
- package/dist/core/engine/session/index.d.ts.map +1 -0
- package/dist/core/engine/session/index.js +3 -0
- package/dist/core/engine/session/index.js.map +1 -0
- package/dist/core/engine/session/record.d.ts +56 -0
- package/dist/core/engine/session/record.d.ts.map +1 -0
- package/dist/core/engine/session/record.js +165 -0
- package/dist/core/engine/session/record.js.map +1 -0
- package/dist/core/engine/session/spec.d.ts +19 -0
- package/dist/core/engine/session/spec.d.ts.map +1 -0
- package/dist/core/engine/session/spec.js +31 -0
- package/dist/core/engine/session/spec.js.map +1 -0
- package/dist/core/engine/timeframe.d.ts +59 -0
- package/dist/core/engine/timeframe.d.ts.map +1 -0
- package/dist/core/engine/timeframe.js +140 -0
- package/dist/core/engine/timeframe.js.map +1 -0
- package/dist/core/engine/types.d.ts +15 -0
- package/dist/core/engine/types.d.ts.map +1 -0
- package/dist/core/engine/types.js +2 -0
- package/dist/core/engine/types.js.map +1 -0
- package/dist/core/engine/values/heap.d.ts +134 -0
- package/dist/core/engine/values/heap.d.ts.map +1 -0
- package/dist/core/engine/values/heap.js +230 -0
- package/dist/core/engine/values/heap.js.map +1 -0
- package/dist/core/engine/values/index.d.ts +13 -0
- package/dist/core/engine/values/index.d.ts.map +1 -0
- package/dist/core/engine/values/index.js +3 -0
- package/dist/core/engine/values/index.js.map +1 -0
- package/dist/core/engine/values/value.d.ts +82 -0
- package/dist/core/engine/values/value.d.ts.map +1 -0
- package/dist/core/engine/values/value.js +134 -0
- package/dist/core/engine/values/value.js.map +1 -0
- package/dist/core/engine/verify-budgets.d.ts +35 -0
- package/dist/core/engine/verify-budgets.d.ts.map +1 -0
- package/dist/core/engine/verify-budgets.js +172 -0
- package/dist/core/engine/verify-budgets.js.map +1 -0
- package/dist/core/engine/verify-code.d.ts +32 -0
- package/dist/core/engine/verify-code.d.ts.map +1 -0
- package/dist/core/engine/verify-code.js +278 -0
- package/dist/core/engine/verify-code.js.map +1 -0
- package/dist/core/engine/verify-requests.d.ts +44 -0
- package/dist/core/engine/verify-requests.d.ts.map +1 -0
- package/dist/core/engine/verify-requests.js +220 -0
- package/dist/core/engine/verify-requests.js.map +1 -0
- package/dist/core/engine/verify-shape.d.ts +46 -0
- package/dist/core/engine/verify-shape.d.ts.map +1 -0
- package/dist/core/engine/verify-shape.js +147 -0
- package/dist/core/engine/verify-shape.js.map +1 -0
- package/dist/core/engine/verify-tables.d.ts +19 -0
- package/dist/core/engine/verify-tables.d.ts.map +1 -0
- package/dist/core/engine/verify-tables.js +171 -0
- package/dist/core/engine/verify-tables.js.map +1 -0
- package/dist/core/engine/verify.d.ts +19 -0
- package/dist/core/engine/verify.d.ts.map +1 -0
- package/dist/core/engine/verify.js +309 -0
- package/dist/core/engine/verify.js.map +1 -0
- package/dist/core/index.d.ts +95 -6
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +64 -6
- package/dist/core/index.js.map +1 -1
- package/dist/core/parse/expressions.js +1 -1
- package/dist/core/parse/expressions.js.map +1 -1
- package/dist/core/parse/names.d.ts +7 -1
- package/dist/core/parse/names.d.ts.map +1 -1
- package/dist/core/parse/names.js +28 -2
- package/dist/core/parse/names.js.map +1 -1
- package/dist/core/stdlib/averages/exponential.d.ts +51 -0
- package/dist/core/stdlib/averages/exponential.d.ts.map +1 -0
- package/dist/core/stdlib/averages/exponential.js +72 -0
- package/dist/core/stdlib/averages/exponential.js.map +1 -0
- package/dist/core/stdlib/averages/index.d.ts +7 -0
- package/dist/core/stdlib/averages/index.d.ts.map +1 -0
- package/dist/core/stdlib/averages/index.js +5 -0
- package/dist/core/stdlib/averages/index.js.map +1 -0
- package/dist/core/stdlib/averages/select.d.ts +35 -0
- package/dist/core/stdlib/averages/select.d.ts.map +1 -0
- package/dist/core/stdlib/averages/select.js +43 -0
- package/dist/core/stdlib/averages/select.js.map +1 -0
- package/dist/core/stdlib/averages/shaped.d.ts +61 -0
- package/dist/core/stdlib/averages/shaped.d.ts.map +1 -0
- package/dist/core/stdlib/averages/shaped.js +126 -0
- package/dist/core/stdlib/averages/shaped.js.map +1 -0
- package/dist/core/stdlib/averages/simple.d.ts +58 -0
- package/dist/core/stdlib/averages/simple.d.ts.map +1 -0
- package/dist/core/stdlib/averages/simple.js +92 -0
- package/dist/core/stdlib/averages/simple.js.map +1 -0
- package/dist/core/stdlib/calendar/civil.d.ts +56 -0
- package/dist/core/stdlib/calendar/civil.d.ts.map +1 -0
- package/dist/core/stdlib/calendar/civil.js +70 -0
- package/dist/core/stdlib/calendar/civil.js.map +1 -0
- package/dist/core/stdlib/calendar/fields.d.ts +36 -0
- package/dist/core/stdlib/calendar/fields.d.ts.map +1 -0
- package/dist/core/stdlib/calendar/fields.js +93 -0
- package/dist/core/stdlib/calendar/fields.js.map +1 -0
- package/dist/core/stdlib/calendar/format.d.ts +19 -0
- package/dist/core/stdlib/calendar/format.d.ts.map +1 -0
- package/dist/core/stdlib/calendar/format.js +51 -0
- package/dist/core/stdlib/calendar/format.js.map +1 -0
- package/dist/core/stdlib/calendar/index.d.ts +7 -0
- package/dist/core/stdlib/calendar/index.d.ts.map +1 -0
- package/dist/core/stdlib/calendar/index.js +5 -0
- package/dist/core/stdlib/calendar/index.js.map +1 -0
- package/dist/core/stdlib/calendar/zone.d.ts +53 -0
- package/dist/core/stdlib/calendar/zone.d.ts.map +1 -0
- package/dist/core/stdlib/calendar/zone.js +138 -0
- package/dist/core/stdlib/calendar/zone.js.map +1 -0
- package/dist/core/stdlib/index.d.ts +57 -0
- package/dist/core/stdlib/index.d.ts.map +1 -0
- package/dist/core/stdlib/index.js +51 -0
- package/dist/core/stdlib/index.js.map +1 -0
- package/dist/core/stdlib/maths/arithmetic.d.ts +38 -0
- package/dist/core/stdlib/maths/arithmetic.d.ts.map +1 -0
- package/dist/core/stdlib/maths/arithmetic.js +66 -0
- package/dist/core/stdlib/maths/arithmetic.js.map +1 -0
- package/dist/core/stdlib/maths/elementary.d.ts +65 -0
- package/dist/core/stdlib/maths/elementary.d.ts.map +1 -0
- package/dist/core/stdlib/maths/elementary.js +93 -0
- package/dist/core/stdlib/maths/elementary.js.map +1 -0
- package/dist/core/stdlib/maths/index.d.ts +4 -0
- package/dist/core/stdlib/maths/index.d.ts.map +1 -0
- package/dist/core/stdlib/maths/index.js +4 -0
- package/dist/core/stdlib/maths/index.js.map +1 -0
- package/dist/core/stdlib/maths/rounding.d.ts +43 -0
- package/dist/core/stdlib/maths/rounding.d.ts.map +1 -0
- package/dist/core/stdlib/maths/rounding.js +62 -0
- package/dist/core/stdlib/maths/rounding.js.map +1 -0
- package/dist/core/stdlib/momentum/convergence.d.ts +36 -0
- package/dist/core/stdlib/momentum/convergence.d.ts.map +1 -0
- package/dist/core/stdlib/momentum/convergence.js +48 -0
- package/dist/core/stdlib/momentum/convergence.js.map +1 -0
- package/dist/core/stdlib/momentum/index.d.ts +6 -0
- package/dist/core/stdlib/momentum/index.d.ts.map +1 -0
- package/dist/core/stdlib/momentum/index.js +6 -0
- package/dist/core/stdlib/momentum/index.js.map +1 -0
- package/dist/core/stdlib/momentum/pressure.d.ts +43 -0
- package/dist/core/stdlib/momentum/pressure.d.ts.map +1 -0
- package/dist/core/stdlib/momentum/pressure.js +103 -0
- package/dist/core/stdlib/momentum/pressure.js.map +1 -0
- package/dist/core/stdlib/momentum/rates.d.ts +74 -0
- package/dist/core/stdlib/momentum/rates.d.ts.map +1 -0
- package/dist/core/stdlib/momentum/rates.js +134 -0
- package/dist/core/stdlib/momentum/rates.js.map +1 -0
- package/dist/core/stdlib/momentum/rsi.d.ts +21 -0
- package/dist/core/stdlib/momentum/rsi.d.ts.map +1 -0
- package/dist/core/stdlib/momentum/rsi.js +30 -0
- package/dist/core/stdlib/momentum/rsi.js.map +1 -0
- package/dist/core/stdlib/momentum/stochastic.d.ts +44 -0
- package/dist/core/stdlib/momentum/stochastic.d.ts.map +1 -0
- package/dist/core/stdlib/momentum/stochastic.js +97 -0
- package/dist/core/stdlib/momentum/stochastic.js.map +1 -0
- package/dist/core/stdlib/series/changes.d.ts +59 -0
- package/dist/core/stdlib/series/changes.d.ts.map +1 -0
- package/dist/core/stdlib/series/changes.js +129 -0
- package/dist/core/stdlib/series/changes.js.map +1 -0
- package/dist/core/stdlib/series/conditions.d.ts +34 -0
- package/dist/core/stdlib/series/conditions.d.ts.map +1 -0
- package/dist/core/stdlib/series/conditions.js +52 -0
- package/dist/core/stdlib/series/conditions.js.map +1 -0
- package/dist/core/stdlib/series/extremes.d.ts +29 -0
- package/dist/core/stdlib/series/extremes.d.ts.map +1 -0
- package/dist/core/stdlib/series/extremes.js +62 -0
- package/dist/core/stdlib/series/extremes.js.map +1 -0
- package/dist/core/stdlib/series/index.d.ts +9 -0
- package/dist/core/stdlib/series/index.d.ts.map +1 -0
- package/dist/core/stdlib/series/index.js +7 -0
- package/dist/core/stdlib/series/index.js.map +1 -0
- package/dist/core/stdlib/series/pivots.d.ts +25 -0
- package/dist/core/stdlib/series/pivots.d.ts.map +1 -0
- package/dist/core/stdlib/series/pivots.js +42 -0
- package/dist/core/stdlib/series/pivots.js.map +1 -0
- package/dist/core/stdlib/series/statistics.d.ts +64 -0
- package/dist/core/stdlib/series/statistics.d.ts.map +1 -0
- package/dist/core/stdlib/series/statistics.js +148 -0
- package/dist/core/stdlib/series/statistics.js.map +1 -0
- package/dist/core/stdlib/series/totals.d.ts +68 -0
- package/dist/core/stdlib/series/totals.d.ts.map +1 -0
- package/dist/core/stdlib/series/totals.js +115 -0
- package/dist/core/stdlib/series/totals.js.map +1 -0
- package/dist/core/stdlib/trend/directional.d.ts +69 -0
- package/dist/core/stdlib/trend/directional.d.ts.map +1 -0
- package/dist/core/stdlib/trend/directional.js +151 -0
- package/dist/core/stdlib/trend/directional.js.map +1 -0
- package/dist/core/stdlib/trend/index.d.ts +4 -0
- package/dist/core/stdlib/trend/index.d.ts.map +1 -0
- package/dist/core/stdlib/trend/index.js +4 -0
- package/dist/core/stdlib/trend/index.js.map +1 -0
- package/dist/core/stdlib/trend/psar.d.ts +33 -0
- package/dist/core/stdlib/trend/psar.d.ts.map +1 -0
- package/dist/core/stdlib/trend/psar.js +86 -0
- package/dist/core/stdlib/trend/psar.js.map +1 -0
- package/dist/core/stdlib/trend/supertrend.d.ts +30 -0
- package/dist/core/stdlib/trend/supertrend.d.ts.map +1 -0
- package/dist/core/stdlib/trend/supertrend.js +65 -0
- package/dist/core/stdlib/trend/supertrend.js.map +1 -0
- package/dist/core/stdlib/values/bar.d.ts +39 -0
- package/dist/core/stdlib/values/bar.d.ts.map +1 -0
- package/dist/core/stdlib/values/bar.js +33 -0
- package/dist/core/stdlib/values/bar.js.map +1 -0
- package/dist/core/stdlib/values/index.d.ts +11 -0
- package/dist/core/stdlib/values/index.d.ts.map +1 -0
- package/dist/core/stdlib/values/index.js +6 -0
- package/dist/core/stdlib/values/index.js.map +1 -0
- package/dist/core/stdlib/values/lookback.d.ts +83 -0
- package/dist/core/stdlib/values/lookback.d.ts.map +1 -0
- package/dist/core/stdlib/values/lookback.js +134 -0
- package/dist/core/stdlib/values/lookback.js.map +1 -0
- package/dist/core/stdlib/values/region.d.ts +55 -0
- package/dist/core/stdlib/values/region.d.ts.map +1 -0
- package/dist/core/stdlib/values/region.js +73 -0
- package/dist/core/stdlib/values/region.js.map +1 -0
- package/dist/core/stdlib/values/tail.d.ts +44 -0
- package/dist/core/stdlib/values/tail.d.ts.map +1 -0
- package/dist/core/stdlib/values/tail.js +23 -0
- package/dist/core/stdlib/values/tail.js.map +1 -0
- package/dist/core/stdlib/values/value.d.ts +64 -0
- package/dist/core/stdlib/values/value.d.ts.map +1 -0
- package/dist/core/stdlib/values/value.js +61 -0
- package/dist/core/stdlib/values/value.js.map +1 -0
- package/dist/core/stdlib/volatility/bands.d.ts +50 -0
- package/dist/core/stdlib/volatility/bands.d.ts.map +1 -0
- package/dist/core/stdlib/volatility/bands.js +101 -0
- package/dist/core/stdlib/volatility/bands.js.map +1 -0
- package/dist/core/stdlib/volatility/deviation.d.ts +43 -0
- package/dist/core/stdlib/volatility/deviation.d.ts.map +1 -0
- package/dist/core/stdlib/volatility/deviation.js +75 -0
- package/dist/core/stdlib/volatility/deviation.js.map +1 -0
- package/dist/core/stdlib/volatility/index.d.ts +6 -0
- package/dist/core/stdlib/volatility/index.d.ts.map +1 -0
- package/dist/core/stdlib/volatility/index.js +5 -0
- package/dist/core/stdlib/volatility/index.js.map +1 -0
- package/dist/core/stdlib/volatility/measures.d.ts +48 -0
- package/dist/core/stdlib/volatility/measures.d.ts.map +1 -0
- package/dist/core/stdlib/volatility/measures.js +73 -0
- package/dist/core/stdlib/volatility/measures.js.map +1 -0
- package/dist/core/stdlib/volatility/range.d.ts +69 -0
- package/dist/core/stdlib/volatility/range.d.ts.map +1 -0
- package/dist/core/stdlib/volatility/range.js +86 -0
- package/dist/core/stdlib/volatility/range.js.map +1 -0
- package/dist/core/stdlib/volume/accumulation.d.ts +61 -0
- package/dist/core/stdlib/volume/accumulation.d.ts.map +1 -0
- package/dist/core/stdlib/volume/accumulation.js +127 -0
- package/dist/core/stdlib/volume/accumulation.js.map +1 -0
- package/dist/core/stdlib/volume/flow.d.ts +60 -0
- package/dist/core/stdlib/volume/flow.d.ts.map +1 -0
- package/dist/core/stdlib/volume/flow.js +125 -0
- package/dist/core/stdlib/volume/flow.js.map +1 -0
- package/dist/core/stdlib/volume/index.d.ts +5 -0
- package/dist/core/stdlib/volume/index.d.ts.map +1 -0
- package/dist/core/stdlib/volume/index.js +4 -0
- package/dist/core/stdlib/volume/index.js.map +1 -0
- package/dist/core/stdlib/volume/weighted.d.ts +52 -0
- package/dist/core/stdlib/volume/weighted.d.ts.map +1 -0
- package/dist/core/stdlib/volume/weighted.js +64 -0
- package/dist/core/stdlib/volume/weighted.js.map +1 -0
- package/dist/core/version/version.generated.d.ts +2 -2
- package/dist/core/version/version.generated.d.ts.map +1 -1
- package/dist/core/version/version.generated.js +2 -2
- package/dist/core/version/version.generated.js.map +1 -1
- package/dist/editor/complete.d.ts +40 -0
- package/dist/editor/complete.d.ts.map +1 -0
- package/dist/editor/complete.js +206 -0
- package/dist/editor/complete.js.map +1 -0
- package/dist/editor/diagnose.d.ts +18 -0
- package/dist/editor/diagnose.d.ts.map +1 -0
- package/dist/editor/diagnose.js +70 -0
- package/dist/editor/diagnose.js.map +1 -0
- package/dist/editor/format.d.ts +11 -0
- package/dist/editor/format.d.ts.map +1 -0
- package/dist/editor/format.js +50 -0
- package/dist/editor/format.js.map +1 -0
- package/dist/editor/highlight.d.ts +28 -0
- package/dist/editor/highlight.d.ts.map +1 -0
- package/dist/editor/highlight.js +65 -0
- package/dist/editor/highlight.js.map +1 -0
- package/dist/editor/hover.d.ts +40 -0
- package/dist/editor/hover.d.ts.map +1 -0
- package/dist/editor/hover.js +147 -0
- package/dist/editor/hover.js.map +1 -0
- package/dist/editor/index.d.ts +60 -0
- package/dist/editor/index.d.ts.map +1 -0
- package/dist/editor/index.js +7 -0
- package/dist/editor/index.js.map +1 -0
- package/dist/editor/kinds.d.ts +27 -0
- package/dist/editor/kinds.d.ts.map +1 -0
- package/dist/editor/kinds.js +118 -0
- package/dist/editor/kinds.js.map +1 -0
- package/dist/editor/layout.d.ts +47 -0
- package/dist/editor/layout.d.ts.map +1 -0
- package/dist/editor/layout.js +135 -0
- package/dist/editor/layout.js.map +1 -0
- package/dist/editor/manifest.d.ts +47 -0
- package/dist/editor/manifest.d.ts.map +1 -0
- package/dist/editor/manifest.js +93 -0
- package/dist/editor/manifest.js.map +1 -0
- package/dist/editor/reading.d.ts +41 -0
- package/dist/editor/reading.d.ts.map +1 -0
- package/dist/editor/reading.js +51 -0
- package/dist/editor/reading.js.map +1 -0
- package/dist/editor/scan.d.ts +26 -0
- package/dist/editor/scan.d.ts.map +1 -0
- package/dist/editor/scan.js +139 -0
- package/dist/editor/scan.js.map +1 -0
- package/dist/editor/scope.d.ts +19 -0
- package/dist/editor/scope.d.ts.map +1 -0
- package/dist/editor/scope.js +99 -0
- package/dist/editor/scope.js.map +1 -0
- package/dist/editor/signature.d.ts +38 -0
- package/dist/editor/signature.d.ts.map +1 -0
- package/dist/editor/signature.js +112 -0
- package/dist/editor/signature.js.map +1 -0
- package/dist/editor/site.d.ts +46 -0
- package/dist/editor/site.d.ts.map +1 -0
- package/dist/editor/site.js +184 -0
- package/dist/editor/site.js.map +1 -0
- package/dist/editor/spacing.d.ts +29 -0
- package/dist/editor/spacing.d.ts.map +1 -0
- package/dist/editor/spacing.js +116 -0
- package/dist/editor/spacing.js.map +1 -0
- package/package.json +66 -15
- package/spec/errors.json +522 -183
- package/src/adapters/charts/alerts.ts +116 -0
- package/src/adapters/charts/bars.ts +63 -0
- package/src/adapters/charts/candles.ts +137 -0
- package/src/adapters/charts/colours.ts +113 -0
- package/src/adapters/charts/columns.ts +99 -0
- package/src/adapters/charts/contract.ts +320 -0
- package/src/adapters/charts/descriptor.ts +199 -0
- package/src/adapters/charts/drawings.ts +213 -0
- package/src/adapters/charts/errors.ts +45 -0
- package/src/adapters/charts/fields.ts +74 -0
- package/src/adapters/charts/fills.ts +71 -0
- package/src/adapters/charts/index.ts +78 -0
- package/src/adapters/charts/levels.ts +92 -0
- package/src/adapters/charts/markers.ts +119 -0
- package/src/adapters/charts/paint.ts +101 -0
- package/src/adapters/charts/plots.ts +185 -0
- package/src/adapters/charts/produced.ts +68 -0
- package/src/adapters/charts/requests.ts +357 -0
- package/src/adapters/charts/run.ts +327 -0
- package/src/adapters/charts/settings.ts +273 -0
- package/src/adapters/charts/surfaces.ts +255 -0
- package/src/adapters/charts/tables.ts +243 -0
- package/src/adapters/codemirror/commands.ts +53 -0
- package/src/adapters/codemirror/completion.ts +74 -0
- package/src/adapters/codemirror/contract.ts +156 -0
- package/src/adapters/codemirror/index.ts +66 -0
- package/src/adapters/codemirror/lint.ts +66 -0
- package/src/adapters/codemirror/positions.ts +79 -0
- package/src/adapters/codemirror/stream.ts +87 -0
- package/src/adapters/codemirror/tokens.ts +64 -0
- package/src/adapters/codemirror/tooltips.ts +113 -0
- package/src/core/accounting/charges.ts +452 -0
- package/src/core/accounting/equity.ts +276 -0
- package/src/core/accounting/index.ts +49 -0
- package/src/core/accounting/markers.ts +95 -0
- package/src/core/accounting/monthly.ts +137 -0
- package/src/core/accounting/report.ts +89 -0
- package/src/core/accounting/shapes.ts +73 -0
- package/src/core/accounting/statistics.ts +350 -0
- package/src/core/accounting/trades.ts +313 -0
- package/src/core/backtest/compare.ts +244 -0
- package/src/core/backtest/declaration.ts +97 -0
- package/src/core/backtest/drive.ts +364 -0
- package/src/core/backtest/index.ts +52 -0
- package/src/core/backtest/range.ts +137 -0
- package/src/core/backtest/record.ts +341 -0
- package/src/core/backtest/replay.ts +158 -0
- package/src/core/backtest/resting.ts +125 -0
- package/src/core/backtest/settings.ts +280 -0
- package/src/core/backtest/simulate.ts +304 -0
- package/src/core/catalogue/catalogue.generated.ts +23 -9
- package/src/core/catalogue/values.generated.ts +14 -0
- package/src/core/check/arguments.ts +126 -0
- package/src/core/check/call-sites.ts +385 -0
- package/src/core/check/call-warmup.ts +121 -0
- package/src/core/check/calls.ts +412 -0
- package/src/core/check/check.ts +183 -0
- package/src/core/check/checked.ts +228 -0
- package/src/core/check/checker.ts +393 -0
- package/src/core/check/conditional.ts +143 -0
- package/src/core/check/constant.ts +127 -0
- package/src/core/check/declaration.ts +230 -0
- package/src/core/check/expressions.ts +471 -0
- package/src/core/check/functions.ts +283 -0
- package/src/core/check/handles.ts +75 -0
- package/src/core/check/index.ts +70 -0
- package/src/core/check/library-bars.ts +194 -0
- package/src/core/check/library-orders.ts +290 -0
- package/src/core/check/library-output.ts +241 -0
- package/src/core/check/library-prose.generated.ts +367 -0
- package/src/core/check/library-series.ts +457 -0
- package/src/core/check/library.ts +374 -0
- package/src/core/check/literals.ts +35 -0
- package/src/core/check/outputs.ts +152 -0
- package/src/core/check/statements.ts +465 -0
- package/src/core/check/suggest.ts +63 -0
- package/src/core/check/surface.ts +149 -0
- package/src/core/check/tags.ts +94 -0
- package/src/core/check/types.ts +260 -0
- package/src/core/check/warmup.ts +100 -0
- package/src/core/diagnostics/collector.ts +27 -1
- package/src/core/emit/calls.ts +415 -0
- package/src/core/emit/canonical.ts +81 -0
- package/src/core/emit/channels.ts +144 -0
- package/src/core/emit/code.ts +155 -0
- package/src/core/emit/colours.ts +75 -0
- package/src/core/emit/context.ts +461 -0
- package/src/core/emit/defaults.ts +220 -0
- package/src/core/emit/emit.ts +313 -0
- package/src/core/emit/events.ts +141 -0
- package/src/core/emit/expressions.ts +292 -0
- package/src/core/emit/functions.ts +195 -0
- package/src/core/emit/gaps.ts +44 -0
- package/src/core/emit/index.ts +76 -0
- package/src/core/emit/inputs.ts +179 -0
- package/src/core/emit/layout.ts +165 -0
- package/src/core/emit/meta.ts +104 -0
- package/src/core/emit/opcodes.ts +160 -0
- package/src/core/emit/outputs.ts +357 -0
- package/src/core/emit/pool.ts +102 -0
- package/src/core/emit/program.ts +385 -0
- package/src/core/emit/registers.ts +179 -0
- package/src/core/emit/request-scope.ts +52 -0
- package/src/core/emit/requests.ts +258 -0
- package/src/core/emit/requires.ts +91 -0
- package/src/core/emit/sha256.ts +119 -0
- package/src/core/emit/statements.ts +438 -0
- package/src/core/emit/values.ts +284 -0
- package/src/core/engine/alerts.ts +152 -0
- package/src/core/engine/arithmetic.ts +165 -0
- package/src/core/engine/bars.ts +224 -0
- package/src/core/engine/budget.ts +284 -0
- package/src/core/engine/channels.ts +171 -0
- package/src/core/engine/drawings.ts +127 -0
- package/src/core/engine/engine.ts +498 -0
- package/src/core/engine/errors.ts +100 -0
- package/src/core/engine/frames.ts +85 -0
- package/src/core/engine/grids.ts +98 -0
- package/src/core/engine/guard.ts +71 -0
- package/src/core/engine/host.ts +251 -0
- package/src/core/engine/index.ts +93 -0
- package/src/core/engine/inputs.ts +263 -0
- package/src/core/engine/ledger/call.ts +218 -0
- package/src/core/engine/ledger/closable.ts +269 -0
- package/src/core/engine/ledger/holdings.ts +354 -0
- package/src/core/engine/ledger/index.ts +28 -0
- package/src/core/engine/ledger/intent.ts +112 -0
- package/src/core/engine/ledger/ledger.ts +314 -0
- package/src/core/engine/ledger/place.ts +277 -0
- package/src/core/engine/ledger/positions.ts +123 -0
- package/src/core/engine/ledger/refuse.ts +378 -0
- package/src/core/engine/ledger/row.ts +318 -0
- package/src/core/engine/ledger/sizing.ts +292 -0
- package/src/core/engine/library/arrays.ts +316 -0
- package/src/core/engine/library/averages.ts +97 -0
- package/src/core/engine/library/binding.ts +325 -0
- package/src/core/engine/library/chart.ts +115 -0
- package/src/core/engine/library/colours.ts +111 -0
- package/src/core/engine/library/dates.ts +109 -0
- package/src/core/engine/library/index.ts +103 -0
- package/src/core/engine/library/maths.ts +134 -0
- package/src/core/engine/library/objects.ts +265 -0
- package/src/core/engine/library/oscillators.ts +124 -0
- package/src/core/engine/library/ranges.ts +51 -0
- package/src/core/engine/library/series.ts +236 -0
- package/src/core/engine/library/state.ts +47 -0
- package/src/core/engine/library/studies.ts +150 -0
- package/src/core/engine/library/text.ts +303 -0
- package/src/core/engine/library/trend.ts +79 -0
- package/src/core/engine/library/volume.ts +101 -0
- package/src/core/engine/load.ts +118 -0
- package/src/core/engine/machine.ts +446 -0
- package/src/core/engine/memory.ts +129 -0
- package/src/core/engine/operations.ts +171 -0
- package/src/core/engine/orders.ts +121 -0
- package/src/core/engine/registers.ts +104 -0
- package/src/core/engine/request-body.ts +328 -0
- package/src/core/engine/request-plan.ts +270 -0
- package/src/core/engine/requests.ts +382 -0
- package/src/core/engine/results.ts +41 -0
- package/src/core/engine/series.ts +82 -0
- package/src/core/engine/session/hours.ts +86 -0
- package/src/core/engine/session/index.ts +17 -0
- package/src/core/engine/session/record.ts +191 -0
- package/src/core/engine/session/spec.ts +45 -0
- package/src/core/engine/timeframe.ts +161 -0
- package/src/core/engine/types.ts +47 -0
- package/src/core/engine/values/heap.ts +295 -0
- package/src/core/engine/values/index.ts +34 -0
- package/src/core/engine/values/value.ts +158 -0
- package/src/core/engine/verify-budgets.ts +202 -0
- package/src/core/engine/verify-code.ts +332 -0
- package/src/core/engine/verify-requests.ts +255 -0
- package/src/core/engine/verify-shape.ts +164 -0
- package/src/core/engine/verify-tables.ts +176 -0
- package/src/core/engine/verify.ts +341 -0
- package/src/core/index.ts +212 -6
- package/src/core/parse/expressions.ts +1 -1
- package/src/core/parse/names.ts +29 -2
- package/src/core/stdlib/averages/exponential.ts +119 -0
- package/src/core/stdlib/averages/index.ts +45 -0
- package/src/core/stdlib/averages/select.ts +71 -0
- package/src/core/stdlib/averages/shaped.ts +161 -0
- package/src/core/stdlib/averages/simple.ts +139 -0
- package/src/core/stdlib/calendar/civil.ts +89 -0
- package/src/core/stdlib/calendar/fields.ts +124 -0
- package/src/core/stdlib/calendar/format.ts +71 -0
- package/src/core/stdlib/calendar/index.ts +15 -0
- package/src/core/stdlib/calendar/zone.ts +161 -0
- package/src/core/stdlib/index.ts +400 -0
- package/src/core/stdlib/maths/arithmetic.ts +74 -0
- package/src/core/stdlib/maths/elementary.ts +124 -0
- package/src/core/stdlib/maths/index.ts +43 -0
- package/src/core/stdlib/maths/rounding.ts +78 -0
- package/src/core/stdlib/momentum/convergence.ts +82 -0
- package/src/core/stdlib/momentum/index.ts +47 -0
- package/src/core/stdlib/momentum/pressure.ts +141 -0
- package/src/core/stdlib/momentum/rates.ts +188 -0
- package/src/core/stdlib/momentum/rsi.ts +49 -0
- package/src/core/stdlib/momentum/stochastic.ts +147 -0
- package/src/core/stdlib/series/changes.ts +177 -0
- package/src/core/stdlib/series/conditions.ts +74 -0
- package/src/core/stdlib/series/extremes.ts +92 -0
- package/src/core/stdlib/series/index.ts +83 -0
- package/src/core/stdlib/series/pivots.ts +63 -0
- package/src/core/stdlib/series/statistics.ts +207 -0
- package/src/core/stdlib/series/totals.ts +164 -0
- package/src/core/stdlib/trend/directional.ts +196 -0
- package/src/core/stdlib/trend/index.ts +13 -0
- package/src/core/stdlib/trend/psar.ts +131 -0
- package/src/core/stdlib/trend/supertrend.ts +100 -0
- package/src/core/stdlib/values/bar.ts +54 -0
- package/src/core/stdlib/values/index.ts +14 -0
- package/src/core/stdlib/values/lookback.ts +198 -0
- package/src/core/stdlib/values/region.ts +86 -0
- package/src/core/stdlib/values/tail.ts +58 -0
- package/src/core/stdlib/values/value.ts +82 -0
- package/src/core/stdlib/volatility/bands.ts +178 -0
- package/src/core/stdlib/volatility/deviation.ts +111 -0
- package/src/core/stdlib/volatility/index.ts +48 -0
- package/src/core/stdlib/volatility/measures.ts +96 -0
- package/src/core/stdlib/volatility/range.ts +143 -0
- package/src/core/stdlib/volume/accumulation.ts +152 -0
- package/src/core/stdlib/volume/flow.ts +173 -0
- package/src/core/stdlib/volume/index.ts +43 -0
- package/src/core/stdlib/volume/weighted.ts +101 -0
- package/src/core/version/version.generated.ts +2 -2
- package/src/editor/complete.ts +266 -0
- package/src/editor/diagnose.ts +71 -0
- package/src/editor/format.ts +85 -0
- package/src/editor/highlight.ts +110 -0
- package/src/editor/hover.ts +199 -0
- package/src/editor/index.ts +65 -0
- package/src/editor/kinds.ts +157 -0
- package/src/editor/layout.ts +189 -0
- package/src/editor/manifest.ts +119 -0
- package/src/editor/reading.ts +69 -0
- package/src/editor/scan.ts +162 -0
- package/src/editor/scope.ts +122 -0
- package/src/editor/signature.ts +150 -0
- package/src/editor/site.ts +233 -0
- package/src/editor/spacing.ts +132 -0
|
@@ -0,0 +1,284 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Values the compiler can work out before bar 0, and the folding that gets
|
|
3
|
+
* there.
|
|
4
|
+
*
|
|
5
|
+
* Two parts of the format need this and nothing else does. A constant pool
|
|
6
|
+
* entry is a value (`compiled-program.md` 2.9), and every declaration field is
|
|
7
|
+
* written with the value its option resolved to, defaults included (2.3). So a
|
|
8
|
+
* plot's colour, a study's precision and a table's corner all have to be a
|
|
9
|
+
* value here or they cannot be carried at all.
|
|
10
|
+
*
|
|
11
|
+
* The one thing that is a field and is not a value is the reference form
|
|
12
|
+
* `{ "input": "<key>" }`, which is why it is a member of this union rather than
|
|
13
|
+
* something a later stage substitutes. It may stand **in place of** a value and
|
|
14
|
+
* may not take part in one: `opacity = dim` is carried, `opacity = dim * 2` has
|
|
15
|
+
* nowhere in the format to live, and folding says so by refusing rather than by
|
|
16
|
+
* inventing a number from the input's default.
|
|
17
|
+
*
|
|
18
|
+
* The colour arithmetic is here because `stdlib.md` 11.2 defines it exactly:
|
|
19
|
+
* `fade(c, p)` is `withAlpha(c, (100 - p) / 100)`, and every call that computes
|
|
20
|
+
* a colour rounds the three channels with the language's own rounding, halves
|
|
21
|
+
* away from zero. Both are written out rather than approximated, because a
|
|
22
|
+
* colour folded here and the same colour computed by an engine have to be the
|
|
23
|
+
* same bits.
|
|
24
|
+
*/
|
|
25
|
+
import type { Argument, Call, Expression, NameReference } from '../ast/index.js';
|
|
26
|
+
import { withoutGrouping } from '../ast/index.js';
|
|
27
|
+
import { FOLDABLE_CALLS } from '../check/index.js';
|
|
28
|
+
import type { Colour, Field } from './program.js';
|
|
29
|
+
import { hexColour, namedColour } from './colours.js';
|
|
30
|
+
|
|
31
|
+
export type Value =
|
|
32
|
+
| { readonly kind: 'absent' }
|
|
33
|
+
| { readonly kind: 'bool'; readonly value: boolean }
|
|
34
|
+
| { readonly kind: 'number'; readonly value: number }
|
|
35
|
+
| { readonly kind: 'string'; readonly value: string }
|
|
36
|
+
| { readonly kind: 'colour'; readonly value: Colour }
|
|
37
|
+
| { readonly kind: 'array'; readonly values: readonly Value[] }
|
|
38
|
+
/** Carried into a declaration field as the reference of 2.3, never computed with. */
|
|
39
|
+
| { readonly kind: 'input'; readonly key: string };
|
|
40
|
+
|
|
41
|
+
export const ABSENT: Value = { kind: 'absent' };
|
|
42
|
+
|
|
43
|
+
export interface FoldEnvironment {
|
|
44
|
+
/** What a bare name denotes before bar 0, or nothing when it denotes a bar. */
|
|
45
|
+
name(reference: NameReference): Value | undefined;
|
|
46
|
+
/** A resolved call: its library name and its arguments in parameter order. */
|
|
47
|
+
call(
|
|
48
|
+
call: Call,
|
|
49
|
+
): { readonly name: string; readonly args: readonly (Argument | undefined)[] } | undefined;
|
|
50
|
+
/** The input an `input()` call declares, as the reference that names it. */
|
|
51
|
+
input(call: Call): Value | undefined;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/** The language's own rounding, halves away from zero, `stdlib.md` 8.1. */
|
|
55
|
+
export function roundHalfAway(x: number): number {
|
|
56
|
+
return x < 0 ? -Math.floor(-x + 0.5) : Math.floor(x + 0.5);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
/** Normalises a negative zero, which nothing in the language can observe (3.1). */
|
|
60
|
+
function noNegativeZero(x: number): number {
|
|
61
|
+
return x === 0 ? 0 : x;
|
|
62
|
+
}
|
|
63
|
+
|
|
64
|
+
type Channels = readonly [number, number, number, number];
|
|
65
|
+
|
|
66
|
+
function at(colour: Channels, index: number): number {
|
|
67
|
+
return colour[index] ?? 0;
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
function colourOf(value: Value | undefined): Colour | undefined {
|
|
71
|
+
return value !== undefined && value.kind === 'colour' ? value.value : undefined;
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
function numberOf(value: Value | undefined): number | undefined {
|
|
75
|
+
return value !== undefined && value.kind === 'number' ? value.value : undefined;
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
function channel(x: number): number {
|
|
79
|
+
return roundHalfAway(x);
|
|
80
|
+
}
|
|
81
|
+
|
|
82
|
+
/**
|
|
83
|
+
* The colour calls of `stdlib.md` 11.2 that a declaration field can hold.
|
|
84
|
+
*
|
|
85
|
+
* `mix` is included because it is the call that produces fractional channels
|
|
86
|
+
* and is therefore the one where the rounding rule bites; `alpha` is included
|
|
87
|
+
* because it returns a number and a script may use one in a field.
|
|
88
|
+
*
|
|
89
|
+
* Which names those are is the checker's `FOLDABLE_CALLS`, and is read from
|
|
90
|
+
* there rather than repeated here: the checker accepts a call in a field that
|
|
91
|
+
* has to be fixed before bar 0 on the strength of this folding it, so the two
|
|
92
|
+
* lists being one list is what keeps the compiler from refusing a script it had
|
|
93
|
+
* already passed.
|
|
94
|
+
*/
|
|
95
|
+
function foldColourCall(
|
|
96
|
+
name: string,
|
|
97
|
+
args: readonly (Value | undefined)[],
|
|
98
|
+
): Value | undefined {
|
|
99
|
+
if (!FOLDABLE_CALLS.has(name)) return undefined;
|
|
100
|
+
if (name === 'rgb' || name === 'rgba') {
|
|
101
|
+
const r = numberOf(args[0]);
|
|
102
|
+
const g = numberOf(args[1]);
|
|
103
|
+
const b = numberOf(args[2]);
|
|
104
|
+
const a = name === 'rgba' ? numberOf(args[3]) : 1;
|
|
105
|
+
if (r === undefined || g === undefined || b === undefined || a === undefined) return undefined;
|
|
106
|
+
return { kind: 'colour', value: [channel(r), channel(g), channel(b), a] };
|
|
107
|
+
}
|
|
108
|
+
if (name === 'fade' || name === 'withAlpha') {
|
|
109
|
+
const colour = colourOf(args[0]);
|
|
110
|
+
const amount = numberOf(args[1]);
|
|
111
|
+
if (colour === undefined || amount === undefined) return undefined;
|
|
112
|
+
// fade takes transparency as a percentage and sets the alpha absolutely.
|
|
113
|
+
const alpha = name === 'fade' ? (100 - amount) / 100 : amount;
|
|
114
|
+
return { kind: 'colour', value: [colour[0], colour[1], colour[2], alpha] };
|
|
115
|
+
}
|
|
116
|
+
if (name === 'alpha') {
|
|
117
|
+
const colour = colourOf(args[0]);
|
|
118
|
+
return colour === undefined ? undefined : { kind: 'number', value: colour[3] };
|
|
119
|
+
}
|
|
120
|
+
if (name === 'mix') {
|
|
121
|
+
const a = colourOf(args[0]);
|
|
122
|
+
const b = colourOf(args[1]);
|
|
123
|
+
const weight = numberOf(args[2]);
|
|
124
|
+
if (a === undefined || b === undefined || weight === undefined) return undefined;
|
|
125
|
+
const blend = (i: number): number => channel(at(a, i) + (at(b, i) - at(a, i)) * weight);
|
|
126
|
+
return {
|
|
127
|
+
kind: 'colour',
|
|
128
|
+
value: [blend(0), blend(1), blend(2), a[3] + (b[3] - a[3]) * weight],
|
|
129
|
+
} as const;
|
|
130
|
+
}
|
|
131
|
+
return undefined;
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
function foldArithmetic(operator: string, left: Value, right: Value): Value | undefined {
|
|
135
|
+
if (operator === '+' && left.kind === 'string' && right.kind === 'string') {
|
|
136
|
+
return { kind: 'string', value: left.value + right.value };
|
|
137
|
+
}
|
|
138
|
+
if (left.kind !== 'number' || right.kind !== 'number') return undefined;
|
|
139
|
+
const a = left.value;
|
|
140
|
+
const b = right.value;
|
|
141
|
+
let result: number;
|
|
142
|
+
switch (operator) {
|
|
143
|
+
case '+':
|
|
144
|
+
result = a + b;
|
|
145
|
+
break;
|
|
146
|
+
case '-':
|
|
147
|
+
result = a - b;
|
|
148
|
+
break;
|
|
149
|
+
case '*':
|
|
150
|
+
result = a * b;
|
|
151
|
+
break;
|
|
152
|
+
case '/':
|
|
153
|
+
if (b === 0) return ABSENT;
|
|
154
|
+
result = a / b;
|
|
155
|
+
break;
|
|
156
|
+
case '%':
|
|
157
|
+
if (b === 0) return ABSENT;
|
|
158
|
+
result = a % b;
|
|
159
|
+
break;
|
|
160
|
+
default:
|
|
161
|
+
return undefined;
|
|
162
|
+
}
|
|
163
|
+
// Any result that is not finite is absent, checked after each operation (3.1).
|
|
164
|
+
return Number.isFinite(result)
|
|
165
|
+
? { kind: 'number', value: noNegativeZero(result) }
|
|
166
|
+
: ABSENT;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
/**
|
|
170
|
+
* The value an expression has before bar 0, or nothing when it has none.
|
|
171
|
+
*
|
|
172
|
+
* Nothing here reports a diagnostic. An expression the checker already accepted
|
|
173
|
+
* as a compile-time constant and this refuses is a shape the format cannot
|
|
174
|
+
* carry, and the caller is the one that knows which field it was going into.
|
|
175
|
+
*/
|
|
176
|
+
export function fold(expression: Expression, environment: FoldEnvironment): Value | undefined {
|
|
177
|
+
const inner = withoutGrouping(expression);
|
|
178
|
+
switch (inner.kind) {
|
|
179
|
+
case 'numberLiteral':
|
|
180
|
+
return { kind: 'number', value: noNegativeZero(inner.value) };
|
|
181
|
+
case 'stringLiteral':
|
|
182
|
+
return { kind: 'string', value: inner.value };
|
|
183
|
+
case 'booleanLiteral':
|
|
184
|
+
return { kind: 'bool', value: inner.value };
|
|
185
|
+
case 'noneLiteral':
|
|
186
|
+
return ABSENT;
|
|
187
|
+
case 'colorLiteral': {
|
|
188
|
+
const colour = hexColour(inner.text);
|
|
189
|
+
return colour === undefined ? undefined : { kind: 'colour', value: colour };
|
|
190
|
+
}
|
|
191
|
+
case 'nameReference': {
|
|
192
|
+
const named = namedColour(inner.name);
|
|
193
|
+
if (named !== undefined) return { kind: 'colour', value: named };
|
|
194
|
+
return environment.name(inner);
|
|
195
|
+
}
|
|
196
|
+
case 'member': {
|
|
197
|
+
const object = withoutGrouping(inner.object);
|
|
198
|
+
if (object.kind !== 'nameReference' || object.name !== 'math') return undefined;
|
|
199
|
+
if (inner.member.text === 'pi') return { kind: 'number', value: Math.PI };
|
|
200
|
+
if (inner.member.text === 'e') return { kind: 'number', value: Math.E };
|
|
201
|
+
return undefined;
|
|
202
|
+
}
|
|
203
|
+
case 'arrayLiteral': {
|
|
204
|
+
const values: Value[] = [];
|
|
205
|
+
for (const element of inner.elements) {
|
|
206
|
+
const value = fold(element, environment);
|
|
207
|
+
if (value === undefined) return undefined;
|
|
208
|
+
// A reference stands **in place of** a field's value and never inside
|
|
209
|
+
// one, so `range = [input(0, "Low"), 100]` has nowhere in the format to
|
|
210
|
+
// live and is refused here rather than written as an absent range.
|
|
211
|
+
if (value.kind === 'input') return undefined;
|
|
212
|
+
values.push(value);
|
|
213
|
+
}
|
|
214
|
+
return { kind: 'array', values };
|
|
215
|
+
}
|
|
216
|
+
case 'unary': {
|
|
217
|
+
const operand = fold(inner.operand, environment);
|
|
218
|
+
if (operand === undefined) return undefined;
|
|
219
|
+
if (operand.kind === 'absent') return ABSENT;
|
|
220
|
+
if (inner.operator === 'not') {
|
|
221
|
+
return operand.kind === 'bool' ? { kind: 'bool', value: !operand.value } : undefined;
|
|
222
|
+
}
|
|
223
|
+
if (operand.kind !== 'number') return undefined;
|
|
224
|
+
const value = inner.operator === '-' ? -operand.value : operand.value;
|
|
225
|
+
return { kind: 'number', value: noNegativeZero(value) };
|
|
226
|
+
}
|
|
227
|
+
case 'binary': {
|
|
228
|
+
const left = fold(inner.left, environment);
|
|
229
|
+
const right = fold(inner.right, environment);
|
|
230
|
+
if (left === undefined || right === undefined) return undefined;
|
|
231
|
+
if (left.kind === 'absent' || right.kind === 'absent') return ABSENT;
|
|
232
|
+
return foldArithmetic(inner.operator, left, right);
|
|
233
|
+
}
|
|
234
|
+
case 'ternary': {
|
|
235
|
+
const condition = fold(inner.condition, environment);
|
|
236
|
+
if (condition === undefined || condition.kind !== 'bool') return undefined;
|
|
237
|
+
return fold(condition.value ? inner.whenTrue : inner.whenFalse, environment);
|
|
238
|
+
}
|
|
239
|
+
case 'call': {
|
|
240
|
+
const resolved = environment.call(inner);
|
|
241
|
+
if (resolved === undefined) return undefined;
|
|
242
|
+
// An `input()` written in place is the reference of 2.3, exactly as the
|
|
243
|
+
// name a script bound one to is. `language.md` 13.2 admits both spellings
|
|
244
|
+
// of an option value and the declaration line can only write this one:
|
|
245
|
+
// it is the first statement of the file, so there is no name above it.
|
|
246
|
+
if (resolved.name === 'input') return environment.input(inner);
|
|
247
|
+
const args = resolved.args.map((one) =>
|
|
248
|
+
one === undefined ? undefined : fold(one.value, environment),
|
|
249
|
+
);
|
|
250
|
+
return foldColourCall(resolved.name, args);
|
|
251
|
+
}
|
|
252
|
+
default:
|
|
253
|
+
return undefined;
|
|
254
|
+
}
|
|
255
|
+
}
|
|
256
|
+
|
|
257
|
+
/**
|
|
258
|
+
* A folded value as a declaration field, `compiled-program.md` 2.3.
|
|
259
|
+
*
|
|
260
|
+
* Absence is null, because absence is what an argument a script named none for
|
|
261
|
+
* resolves to and null is the effective value rather than a missing one. An
|
|
262
|
+
* input is carried as its reference and is resolved away before bar 0.
|
|
263
|
+
*/
|
|
264
|
+
export function fieldOf(value: Value | undefined): Field {
|
|
265
|
+
if (value === undefined) return null;
|
|
266
|
+
switch (value.kind) {
|
|
267
|
+
case 'absent':
|
|
268
|
+
return null;
|
|
269
|
+
case 'bool':
|
|
270
|
+
return value.value;
|
|
271
|
+
case 'number':
|
|
272
|
+
return value.value;
|
|
273
|
+
case 'string':
|
|
274
|
+
return value.value;
|
|
275
|
+
case 'colour':
|
|
276
|
+
return value.value;
|
|
277
|
+
case 'input':
|
|
278
|
+
return { input: value.key };
|
|
279
|
+
case 'array': {
|
|
280
|
+
const numbers = value.values.map((one) => (one.kind === 'number' ? one.value : Number.NaN));
|
|
281
|
+
return numbers.some((one) => Number.isNaN(one)) ? null : numbers;
|
|
282
|
+
}
|
|
283
|
+
}
|
|
284
|
+
}
|
|
@@ -0,0 +1,152 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The watched conditions, and the two rules that decide whether one fires.
|
|
3
|
+
*
|
|
4
|
+
* `outputs.alerts` is a declaration: a boolean channel, a message channel and a
|
|
5
|
+
* frequency (`compiled-program.md` 2.8). Turning that into an alert somebody is
|
|
6
|
+
* woken by is the engine's, because both rules that gate it are facts the
|
|
7
|
+
* engine holds and a host asked to apply them would be applying them
|
|
8
|
+
* differently in every host.
|
|
9
|
+
*
|
|
10
|
+
* **A confirmed bar, first.** The condition channel is declared `defer`, so it
|
|
11
|
+
* is applied at step 9 and only on a bar the engine decided (5.4). A condition
|
|
12
|
+
* that was true halfway through a bar and false when it closed never fires,
|
|
13
|
+
* which is the whole of what makes an alert worth acting on.
|
|
14
|
+
*
|
|
15
|
+
* **A bar the host is driving live, second.** `stdlib.md` 16.2: adding a study
|
|
16
|
+
* to a chart that already holds history fires nothing for those bars. The fact
|
|
17
|
+
* that separates the two is `bar.isRealtime`, which the host states and no
|
|
18
|
+
* engine can derive (`host-interface.md` 6.1 and 6.4): a history load states it
|
|
19
|
+
* false for every bar, and a live feed states it true for the bar it is
|
|
20
|
+
* driving. So the rule is one test against a fact somebody already had to
|
|
21
|
+
* state, rather than a watermark this would have to keep and get wrong after a
|
|
22
|
+
* recompute. An engine that only backtests states it false throughout and fires
|
|
23
|
+
* nothing, which is the same answer from the other direction.
|
|
24
|
+
*
|
|
25
|
+
* Neither rule is rolled back. A moving bar re-executes and its deferred
|
|
26
|
+
* channels are discarded each time, so nothing fires until the bar is decided;
|
|
27
|
+
* once one has fired, it has been sent, and no rollback unsends it. That is why
|
|
28
|
+
* `once` and `oncePerBar` are counted here rather than restored with the rest
|
|
29
|
+
* of the state.
|
|
30
|
+
*/
|
|
31
|
+
import { fieldValue } from './inputs.js';
|
|
32
|
+
import type { ResolvedInput } from './inputs.js';
|
|
33
|
+
import type { Alert, CompiledProgram, Field } from './types.js';
|
|
34
|
+
import type { Value } from './values/index.js';
|
|
35
|
+
|
|
36
|
+
/** One alert the engine raised, for the host to deliver. */
|
|
37
|
+
export interface AlertFiring {
|
|
38
|
+
/** The entry's stable name: the script's `id`, or one derived from the line. */
|
|
39
|
+
readonly key: string;
|
|
40
|
+
readonly title: string;
|
|
41
|
+
/** The message, evaluated on the bar that fired, or absent where it was. */
|
|
42
|
+
readonly message: Value;
|
|
43
|
+
readonly bar: number;
|
|
44
|
+
/** The bar's open time in milliseconds, or null when the host stated none. */
|
|
45
|
+
readonly time: number | null;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** What one execution of a bar offers the watch. */
|
|
49
|
+
export interface AlertBar {
|
|
50
|
+
readonly index: number;
|
|
51
|
+
readonly time: number | null;
|
|
52
|
+
readonly isRealtime: boolean;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/** The three of `stdlib.md` 16.2, with the default first. */
|
|
56
|
+
const ONCE_PER_BAR = 'oncePerBar';
|
|
57
|
+
const ONCE = 'once';
|
|
58
|
+
|
|
59
|
+
/**
|
|
60
|
+
* The watch for one program, with its declaration fields resolved.
|
|
61
|
+
*
|
|
62
|
+
* A title and a frequency are declaration fields, which a script may write with
|
|
63
|
+
* an `input()`, and inputs are resolved once at load. So they are read here,
|
|
64
|
+
* before bar 0, rather than per bar, as every other declaration the descriptor
|
|
65
|
+
* is built from is.
|
|
66
|
+
*
|
|
67
|
+
* A field that holds no string at all is a program whose field was lost or hand
|
|
68
|
+
* edited, and the frequency it falls back to is the safest of the three: at most
|
|
69
|
+
* one alert for a bar.
|
|
70
|
+
*/
|
|
71
|
+
export function alertsFor(
|
|
72
|
+
program: CompiledProgram,
|
|
73
|
+
inputs: readonly ResolvedInput[],
|
|
74
|
+
): Alerts {
|
|
75
|
+
const text = (field: Field, fallback: string): string => {
|
|
76
|
+
const value = fieldValue(field, inputs);
|
|
77
|
+
return typeof value === 'string' ? value : fallback;
|
|
78
|
+
};
|
|
79
|
+
return new Alerts(
|
|
80
|
+
program.outputs.alerts,
|
|
81
|
+
program.outputs.alerts.map((one) => ({
|
|
82
|
+
title: text(one.title, ''),
|
|
83
|
+
frequency: text(one.frequency, ONCE_PER_BAR),
|
|
84
|
+
})),
|
|
85
|
+
);
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** One entry's declaration fields, resolved against the settings at load. */
|
|
89
|
+
export interface AlertFields {
|
|
90
|
+
readonly title: string;
|
|
91
|
+
readonly frequency: string;
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
export class Alerts {
|
|
95
|
+
private readonly declared: readonly Alert[];
|
|
96
|
+
private readonly resolved: readonly AlertFields[];
|
|
97
|
+
/** The last bar each entry fired on, by declaration order. */
|
|
98
|
+
private readonly lastBar: number[];
|
|
99
|
+
private readonly everFired: boolean[];
|
|
100
|
+
|
|
101
|
+
constructor(declared: readonly Alert[], resolved: readonly AlertFields[]) {
|
|
102
|
+
this.declared = declared;
|
|
103
|
+
this.resolved = resolved;
|
|
104
|
+
this.lastBar = declared.map(() => -1);
|
|
105
|
+
this.everFired = declared.map(() => false);
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
/**
|
|
109
|
+
* Step 9 on a bar the engine decided: the alerts it raises, in order.
|
|
110
|
+
*
|
|
111
|
+
* `read` is the channel's published value for this bar. A condition that is
|
|
112
|
+
* absent is not true, which is `language.md` 6.6's three-valued logic reaching
|
|
113
|
+
* a surface: an alert under a guard that was absent during warmup does not
|
|
114
|
+
* fire, and that is the most common reason a new alert looks dead.
|
|
115
|
+
*/
|
|
116
|
+
raise(bar: AlertBar, read: (channel: number) => Value): readonly AlertFiring[] {
|
|
117
|
+
if (this.declared.length === 0 || !bar.isRealtime) return [];
|
|
118
|
+
const out: AlertFiring[] = [];
|
|
119
|
+
for (let index = 0; index < this.declared.length; index += 1) {
|
|
120
|
+
const entry = this.declared[index];
|
|
121
|
+
const fields = this.resolved[index];
|
|
122
|
+
if (entry === undefined || fields === undefined) continue;
|
|
123
|
+
if (read(entry.condChannel) !== true) continue;
|
|
124
|
+
if (!this.allowed(index, bar.index, fields.frequency)) continue;
|
|
125
|
+
this.lastBar[index] = bar.index;
|
|
126
|
+
this.everFired[index] = true;
|
|
127
|
+
out.push({
|
|
128
|
+
key: entry.key,
|
|
129
|
+
title: fields.title,
|
|
130
|
+
message: entry.messageChannel === null ? null : read(entry.messageChannel),
|
|
131
|
+
bar: bar.index,
|
|
132
|
+
time: bar.time,
|
|
133
|
+
});
|
|
134
|
+
}
|
|
135
|
+
return out;
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/**
|
|
139
|
+
* The frequency rule, which nothing else in the program implies.
|
|
140
|
+
*
|
|
141
|
+
* Two engines that guessed would fire different numbers of alerts from one
|
|
142
|
+
* program, so the compiler writes the effective value and this reads it.
|
|
143
|
+
* `everyUpdate` is the one that needs no test here: it fires on every decided
|
|
144
|
+
* execution of the bar, which is why it needs `meta.onUnconfirmed` true to
|
|
145
|
+
* mean anything and is OS3009 without it.
|
|
146
|
+
*/
|
|
147
|
+
private allowed(index: number, bar: number, frequency: string): boolean {
|
|
148
|
+
if (frequency === ONCE) return this.everFired[index] !== true;
|
|
149
|
+
if (frequency === ONCE_PER_BAR) return this.lastBar[index] !== bar;
|
|
150
|
+
return true;
|
|
151
|
+
}
|
|
152
|
+
}
|
|
@@ -0,0 +1,165 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The operator instructions, `compiled-program.md` 4.5 to 4.7.
|
|
3
|
+
*
|
|
4
|
+
* Five rules live in this file and nowhere else, which is section 7's claim
|
|
5
|
+
* about the whole language: absence propagates through arithmetic and ordering
|
|
6
|
+
* comparison, is total under equality, is three-valued under `and`, `or` and
|
|
7
|
+
* `not`, and is false at a branch. The last one is `JUMP_FALSE` and is in the
|
|
8
|
+
* machine; the other four are here. An engine that gets all five right has the
|
|
9
|
+
* whole of `language.md` section 6, and an engine that special cases absence
|
|
10
|
+
* anywhere else has a bug.
|
|
11
|
+
*
|
|
12
|
+
* Two details that look like nothing and are not:
|
|
13
|
+
*
|
|
14
|
+
* **Finiteness is checked after each individual operation**, not at the end of
|
|
15
|
+
* an expression, so `(1e308 * 10) / 10` is absent rather than `1e307`. Checking
|
|
16
|
+
* per expression would make the answer depend on where an engine happened to
|
|
17
|
+
* round, which is the whole failure this project exists to prevent.
|
|
18
|
+
*
|
|
19
|
+
* **`MOD` is truncated division and the library's `mod` is floored.** They are
|
|
20
|
+
* different functions with the same name in two places on purpose: the operator
|
|
21
|
+
* follows the sign of its left operand, which is what every language's `%`
|
|
22
|
+
* does, and the library call follows the sign of its right operand, which is
|
|
23
|
+
* what a script wants when it wraps an index. Collapsing them would silently
|
|
24
|
+
* change one of the two.
|
|
25
|
+
*/
|
|
26
|
+
import type { Value } from './values/index.js';
|
|
27
|
+
import { ABSENT, numberValue, valuesEqual } from './values/index.js';
|
|
28
|
+
|
|
29
|
+
/** Whether a corrupt program reached an operator with tags it cannot take. */
|
|
30
|
+
export class OperandMismatch extends Error {
|
|
31
|
+
readonly opcode: string;
|
|
32
|
+
|
|
33
|
+
constructor(opcode: string) {
|
|
34
|
+
super(opcode);
|
|
35
|
+
this.name = 'OperandMismatch';
|
|
36
|
+
this.opcode = opcode;
|
|
37
|
+
}
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/**
|
|
41
|
+
* `ADD`: the sum of two numbers, or the concatenation of two strings.
|
|
42
|
+
*
|
|
43
|
+
* The only instruction that reads two tags. Any other combination is a program
|
|
44
|
+
* the checker should have rejected, and an engine treats it as corrupt rather
|
|
45
|
+
* than inventing a conversion: `language.md` 5.3 has no coercion anywhere, and
|
|
46
|
+
* an engine that grows one here becomes the only engine that runs that script.
|
|
47
|
+
*/
|
|
48
|
+
export function add(a: Value, b: Value): Value {
|
|
49
|
+
if (a === null || b === null) return ABSENT;
|
|
50
|
+
if (typeof a === 'number' && typeof b === 'number') return numberValue(a + b);
|
|
51
|
+
if (typeof a === 'string' && typeof b === 'string') return a + b;
|
|
52
|
+
throw new OperandMismatch('ADD');
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export function subtract(a: Value, b: Value): Value {
|
|
56
|
+
return numeric('SUB', a, b, (x, y) => x - y);
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
export function multiply(a: Value, b: Value): Value {
|
|
60
|
+
return numeric('MUL', a, b, (x, y) => x * y);
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** `DIV`: absent when the divisor is zero, including `0 / 0`. */
|
|
64
|
+
export function divide(a: Value, b: Value): Value {
|
|
65
|
+
if (a === null || b === null) return ABSENT;
|
|
66
|
+
if (typeof a !== 'number' || typeof b !== 'number') throw new OperandMismatch('DIV');
|
|
67
|
+
return b === 0 ? ABSENT : numberValue(a / b);
|
|
68
|
+
}
|
|
69
|
+
|
|
70
|
+
/** `MOD`: the remainder of truncated division, sign following the left operand. */
|
|
71
|
+
export function remainder(a: Value, b: Value): Value {
|
|
72
|
+
if (a === null || b === null) return ABSENT;
|
|
73
|
+
if (typeof a !== 'number' || typeof b !== 'number') throw new OperandMismatch('MOD');
|
|
74
|
+
return b === 0 ? ABSENT : numberValue(a % b);
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
export function negate(a: Value): Value {
|
|
78
|
+
if (a === null) return ABSENT;
|
|
79
|
+
if (typeof a !== 'number') throw new OperandMismatch('NEG');
|
|
80
|
+
return numberValue(-a);
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
function numeric(
|
|
84
|
+
opcode: string,
|
|
85
|
+
a: Value,
|
|
86
|
+
b: Value,
|
|
87
|
+
of: (x: number, y: number) => number,
|
|
88
|
+
): Value {
|
|
89
|
+
if (a === null || b === null) return ABSENT;
|
|
90
|
+
if (typeof a !== 'number' || typeof b !== 'number') throw new OperandMismatch(opcode);
|
|
91
|
+
return numberValue(of(a, b));
|
|
92
|
+
}
|
|
93
|
+
|
|
94
|
+
/**
|
|
95
|
+
* The four ordering comparisons, which **propagate absence**.
|
|
96
|
+
*
|
|
97
|
+
* An absent operand gives absence rather than `false` (`language.md` 6.4).
|
|
98
|
+
* Together with `EQ` being total, this is the one place in the language where
|
|
99
|
+
* absence is treated two ways, and it is deliberate: an operator that can
|
|
100
|
+
* itself be absent gives a script no way to ask whether a value is absent at
|
|
101
|
+
* all, so equality is the exception and every other comparison is not.
|
|
102
|
+
*/
|
|
103
|
+
export function compare(opcode: 'LT' | 'LE' | 'GT' | 'GE', a: Value, b: Value): Value {
|
|
104
|
+
if (a === null || b === null) return ABSENT;
|
|
105
|
+
const bothNumbers = typeof a === 'number' && typeof b === 'number';
|
|
106
|
+
const bothStrings = typeof a === 'string' && typeof b === 'string';
|
|
107
|
+
if (!bothNumbers && !bothStrings) throw new OperandMismatch(opcode);
|
|
108
|
+
switch (opcode) {
|
|
109
|
+
case 'LT':
|
|
110
|
+
return a < b;
|
|
111
|
+
case 'LE':
|
|
112
|
+
return a <= b;
|
|
113
|
+
case 'GT':
|
|
114
|
+
return a > b;
|
|
115
|
+
default:
|
|
116
|
+
return a >= b;
|
|
117
|
+
}
|
|
118
|
+
}
|
|
119
|
+
|
|
120
|
+
/** `EQ` and `NE` are total: they always produce a boolean. */
|
|
121
|
+
export function equals(a: Value, b: Value): boolean {
|
|
122
|
+
return valuesEqual(a, b);
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** `NOT`: true becomes false, false becomes true, absent stays absent. */
|
|
126
|
+
export function not(a: Value): Value {
|
|
127
|
+
if (a === null) return ABSENT;
|
|
128
|
+
if (typeof a !== 'boolean') throw new OperandMismatch('NOT');
|
|
129
|
+
return !a;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* `AND`, the three-valued conjunction of `language.md` 6.6.
|
|
134
|
+
*
|
|
135
|
+
* The table holds only the cases the short circuit leaves to it: `AND_SHORT`
|
|
136
|
+
* has already decided a `false` left operand. A `false` on the right fixes the
|
|
137
|
+
* answer whatever an absent left operand would have held, which is what makes
|
|
138
|
+
* the operator commutative.
|
|
139
|
+
*/
|
|
140
|
+
export function and(a: Value, b: Value): Value {
|
|
141
|
+
if (a === false || b === false) return false;
|
|
142
|
+
if (a === null || b === null) return ABSENT;
|
|
143
|
+
if (typeof a !== 'boolean' || typeof b !== 'boolean') throw new OperandMismatch('AND');
|
|
144
|
+
return a && b;
|
|
145
|
+
}
|
|
146
|
+
|
|
147
|
+
/** `OR`, the disjunction beside it. A `true` on either side fixes the answer. */
|
|
148
|
+
export function or(a: Value, b: Value): Value {
|
|
149
|
+
if (a === true || b === true) return true;
|
|
150
|
+
if (a === null || b === null) return ABSENT;
|
|
151
|
+
if (typeof a !== 'boolean' || typeof b !== 'boolean') throw new OperandMismatch('OR');
|
|
152
|
+
return a || b;
|
|
153
|
+
}
|
|
154
|
+
|
|
155
|
+
/**
|
|
156
|
+
* Whether a branch is taken, which is the fifth rule.
|
|
157
|
+
*
|
|
158
|
+
* `JUMP_FALSE` treats absence as false. This is the one place absence is
|
|
159
|
+
* absorbed rather than propagated, and it is unavoidable: execution has to go
|
|
160
|
+
* somewhere. It serves `if`, `else if`, `while`, the ternary and a `switch`
|
|
161
|
+
* condition arm, so the rule is written once in one instruction.
|
|
162
|
+
*/
|
|
163
|
+
export function isFalsey(value: Value): boolean {
|
|
164
|
+
return value === false || value === null;
|
|
165
|
+
}
|