openalgo-script 0.4.0 → 0.6.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 +1050 -0
- package/README.md +111 -27
- package/dist/adapters/charts/driving.d.ts +50 -0
- package/dist/adapters/charts/driving.d.ts.map +1 -0
- package/dist/adapters/charts/driving.js +57 -0
- package/dist/adapters/charts/driving.js.map +1 -0
- package/dist/adapters/charts/run.d.ts +20 -0
- package/dist/adapters/charts/run.d.ts.map +1 -1
- package/dist/adapters/charts/run.js +89 -16
- package/dist/adapters/charts/run.js.map +1 -1
- package/dist/adapters/charts/tables.d.ts +6 -19
- package/dist/adapters/charts/tables.d.ts.map +1 -1
- package/dist/adapters/charts/tables.js.map +1 -1
- package/dist/adapters/charts/undrawable.d.ts +4 -0
- package/dist/adapters/charts/undrawable.d.ts.map +1 -0
- package/dist/adapters/charts/undrawable.js +47 -0
- package/dist/adapters/charts/undrawable.js.map +1 -0
- package/dist/adapters/charts/venue.d.ts +73 -0
- package/dist/adapters/charts/venue.d.ts.map +1 -0
- package/dist/adapters/charts/venue.js +104 -0
- package/dist/adapters/charts/venue.js.map +1 -0
- package/dist/core/accounting/analysis.d.ts +111 -0
- package/dist/core/accounting/analysis.d.ts.map +1 -0
- package/dist/core/accounting/analysis.js +123 -0
- package/dist/core/accounting/analysis.js.map +1 -0
- package/dist/core/accounting/equity.d.ts +33 -0
- package/dist/core/accounting/equity.d.ts.map +1 -1
- package/dist/core/accounting/equity.js +12 -0
- package/dist/core/accounting/equity.js.map +1 -1
- package/dist/core/accounting/index.d.ts +2 -0
- package/dist/core/accounting/index.d.ts.map +1 -1
- package/dist/core/accounting/index.js +1 -0
- package/dist/core/accounting/index.js.map +1 -1
- package/dist/core/accounting/report.d.ts +3 -0
- package/dist/core/accounting/report.d.ts.map +1 -1
- package/dist/core/accounting/report.js +2 -0
- package/dist/core/accounting/report.js.map +1 -1
- package/dist/core/accounting/statistics.d.ts +12 -0
- package/dist/core/accounting/statistics.d.ts.map +1 -1
- package/dist/core/accounting/statistics.js +23 -1
- package/dist/core/accounting/statistics.js.map +1 -1
- package/dist/core/backtest/case.d.ts +60 -0
- package/dist/core/backtest/case.d.ts.map +1 -0
- package/dist/core/backtest/case.js +319 -0
- package/dist/core/backtest/case.js.map +1 -0
- package/dist/core/backtest/compare.d.ts.map +1 -1
- package/dist/core/backtest/compare.js +2 -0
- package/dist/core/backtest/compare.js.map +1 -1
- package/dist/core/backtest/deliver.d.ts +93 -0
- package/dist/core/backtest/deliver.d.ts.map +1 -0
- package/dist/core/backtest/deliver.js +94 -0
- package/dist/core/backtest/deliver.js.map +1 -0
- package/dist/core/backtest/drive.d.ts +101 -8
- package/dist/core/backtest/drive.d.ts.map +1 -1
- package/dist/core/backtest/drive.js +114 -158
- package/dist/core/backtest/drive.js.map +1 -1
- package/dist/core/backtest/index.d.ts +26 -12
- package/dist/core/backtest/index.d.ts.map +1 -1
- package/dist/core/backtest/index.js +21 -10
- package/dist/core/backtest/index.js.map +1 -1
- package/dist/core/backtest/record.d.ts +63 -2
- package/dist/core/backtest/record.d.ts.map +1 -1
- package/dist/core/backtest/record.js +71 -4
- package/dist/core/backtest/record.js.map +1 -1
- package/dist/core/backtest/replay.d.ts.map +1 -1
- package/dist/core/backtest/replay.js +11 -1
- package/dist/core/backtest/replay.js.map +1 -1
- package/dist/core/backtest/simulate.d.ts +113 -1
- package/dist/core/backtest/simulate.d.ts.map +1 -1
- package/dist/core/backtest/simulate.js +123 -5
- package/dist/core/backtest/simulate.js.map +1 -1
- package/dist/core/backtest/walk.d.ts +39 -0
- package/dist/core/backtest/walk.d.ts.map +1 -0
- package/dist/core/backtest/walk.js +125 -0
- package/dist/core/backtest/walk.js.map +1 -0
- package/dist/core/catalogue/catalogue.generated.d.ts +179 -2
- package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
- package/dist/core/catalogue/catalogue.generated.js +19 -2
- package/dist/core/catalogue/catalogue.generated.js.map +1 -1
- package/dist/core/catalogue/types.d.ts +8 -2
- package/dist/core/catalogue/types.d.ts.map +1 -1
- package/dist/core/catalogue/values.generated.d.ts +51 -0
- package/dist/core/catalogue/values.generated.d.ts.map +1 -1
- package/dist/core/check/assigned.d.ts +19 -0
- package/dist/core/check/assigned.d.ts.map +1 -0
- package/dist/core/check/assigned.js +14 -0
- package/dist/core/check/assigned.js.map +1 -0
- package/dist/core/check/call-sites.d.ts.map +1 -1
- package/dist/core/check/call-sites.js +9 -4
- package/dist/core/check/call-sites.js.map +1 -1
- package/dist/core/check/calls.d.ts.map +1 -1
- package/dist/core/check/calls.js +12 -4
- package/dist/core/check/calls.js.map +1 -1
- package/dist/core/check/check.d.ts.map +1 -1
- package/dist/core/check/check.js +15 -2
- package/dist/core/check/check.js.map +1 -1
- package/dist/core/check/checker.d.ts +26 -0
- package/dist/core/check/checker.d.ts.map +1 -1
- package/dist/core/check/checker.js +38 -2
- package/dist/core/check/checker.js.map +1 -1
- package/dist/core/check/constant.d.ts +16 -0
- package/dist/core/check/constant.d.ts.map +1 -1
- package/dist/core/check/constant.js +52 -0
- package/dist/core/check/constant.js.map +1 -1
- package/dist/core/check/deleted.d.ts +3 -0
- package/dist/core/check/deleted.d.ts.map +1 -0
- package/dist/core/check/deleted.js +109 -0
- package/dist/core/check/deleted.js.map +1 -0
- package/dist/core/check/expressions.js +1 -1
- package/dist/core/check/expressions.js.map +1 -1
- package/dist/core/check/library-orders.js +2 -2
- package/dist/core/check/library-orders.js.map +1 -1
- package/dist/core/check/library-output.d.ts.map +1 -1
- package/dist/core/check/library-output.js +1 -0
- package/dist/core/check/library-output.js.map +1 -1
- package/dist/core/check/library-prose.generated.js +12 -12
- package/dist/core/check/library-prose.generated.js.map +1 -1
- package/dist/core/check/library.d.ts +7 -0
- package/dist/core/check/library.d.ts.map +1 -1
- package/dist/core/check/library.js +1 -0
- package/dist/core/check/library.js.map +1 -1
- package/dist/core/check/surface.d.ts +9 -0
- package/dist/core/check/surface.d.ts.map +1 -1
- package/dist/core/check/surface.js +13 -0
- package/dist/core/check/surface.js.map +1 -1
- package/dist/core/emit/canonical.d.ts +22 -8
- package/dist/core/emit/canonical.d.ts.map +1 -1
- package/dist/core/emit/canonical.js +67 -6
- package/dist/core/emit/canonical.js.map +1 -1
- package/dist/core/engine/arithmetic.d.ts +6 -25
- package/dist/core/engine/arithmetic.d.ts.map +1 -1
- package/dist/core/engine/arithmetic.js +48 -3
- package/dist/core/engine/arithmetic.js.map +1 -1
- package/dist/core/engine/bar-source.d.ts +65 -0
- package/dist/core/engine/bar-source.d.ts.map +1 -0
- package/dist/core/engine/bar-source.js +58 -0
- package/dist/core/engine/bar-source.js.map +1 -0
- package/dist/core/engine/engine.d.ts +9 -11
- package/dist/core/engine/engine.d.ts.map +1 -1
- package/dist/core/engine/engine.js +24 -24
- package/dist/core/engine/engine.js.map +1 -1
- package/dist/core/engine/guard.d.ts.map +1 -1
- package/dist/core/engine/guard.js +10 -0
- package/dist/core/engine/guard.js.map +1 -1
- package/dist/core/engine/host.d.ts +4 -2
- package/dist/core/engine/host.d.ts.map +1 -1
- package/dist/core/engine/host.js.map +1 -1
- package/dist/core/engine/index.d.ts +2 -1
- package/dist/core/engine/index.d.ts.map +1 -1
- package/dist/core/engine/index.js +1 -1
- package/dist/core/engine/index.js.map +1 -1
- package/dist/core/engine/library/arrays.d.ts.map +1 -1
- package/dist/core/engine/library/arrays.js +8 -2
- package/dist/core/engine/library/arrays.js.map +1 -1
- package/dist/core/engine/library/binding.d.ts +2 -0
- package/dist/core/engine/library/binding.d.ts.map +1 -1
- package/dist/core/engine/library/binding.js.map +1 -1
- package/dist/core/engine/library/code-points.d.ts +40 -0
- package/dist/core/engine/library/code-points.d.ts.map +1 -0
- package/dist/core/engine/library/code-points.js +74 -0
- package/dist/core/engine/library/code-points.js.map +1 -0
- package/dist/core/engine/library/index.d.ts +13 -0
- package/dist/core/engine/library/index.d.ts.map +1 -1
- package/dist/core/engine/library/index.js +15 -0
- package/dist/core/engine/library/index.js.map +1 -1
- package/dist/core/engine/library/objects.d.ts.map +1 -1
- package/dist/core/engine/library/objects.js +1 -1
- package/dist/core/engine/library/objects.js.map +1 -1
- package/dist/core/engine/library/text.d.ts.map +1 -1
- package/dist/core/engine/library/text.js +51 -34
- package/dist/core/engine/library/text.js.map +1 -1
- package/dist/core/engine/load.d.ts +20 -0
- package/dist/core/engine/load.d.ts.map +1 -1
- package/dist/core/engine/load.js +62 -0
- package/dist/core/engine/load.js.map +1 -1
- package/dist/core/engine/request-body.d.ts +3 -1
- package/dist/core/engine/request-body.d.ts.map +1 -1
- package/dist/core/engine/request-body.js +3 -1
- package/dist/core/engine/request-body.js.map +1 -1
- package/dist/core/engine/request-plan.d.ts +3 -3
- package/dist/core/engine/request-plan.js +3 -3
- package/dist/core/engine/requests.d.ts +2 -2
- package/dist/core/engine/requests.d.ts.map +1 -1
- package/dist/core/engine/requests.js +5 -4
- package/dist/core/engine/requests.js.map +1 -1
- package/dist/core/engine/series.d.ts +18 -6
- package/dist/core/engine/series.d.ts.map +1 -1
- package/dist/core/engine/series.js +24 -5
- package/dist/core/engine/series.js.map +1 -1
- package/dist/core/engine/session/record.d.ts +4 -4
- package/dist/core/engine/session/record.js +4 -4
- package/dist/core/engine/verify-tables.d.ts.map +1 -1
- package/dist/core/engine/verify-tables.js +41 -0
- package/dist/core/engine/verify-tables.js.map +1 -1
- package/dist/core/importer/calls.d.ts +29 -0
- package/dist/core/importer/calls.d.ts.map +1 -0
- package/dist/core/importer/calls.js +267 -0
- package/dist/core/importer/calls.js.map +1 -0
- package/dist/core/importer/context.d.ts +118 -0
- package/dist/core/importer/context.d.ts.map +1 -0
- package/dist/core/importer/context.js +120 -0
- package/dist/core/importer/context.js.map +1 -0
- package/dist/core/importer/expressions.d.ts +44 -0
- package/dist/core/importer/expressions.d.ts.map +1 -0
- package/dist/core/importer/expressions.js +223 -0
- package/dist/core/importer/expressions.js.map +1 -0
- package/dist/core/importer/importer.d.ts +13 -0
- package/dist/core/importer/importer.d.ts.map +1 -0
- package/dist/core/importer/importer.js +220 -0
- package/dist/core/importer/importer.js.map +1 -0
- package/dist/core/importer/index.d.ts +20 -0
- package/dist/core/importer/index.d.ts.map +1 -0
- package/dist/core/importer/index.js +18 -0
- package/dist/core/importer/index.js.map +1 -0
- package/dist/core/importer/lexer.d.ts +68 -0
- package/dist/core/importer/lexer.d.ts.map +1 -0
- package/dist/core/importer/lexer.js +207 -0
- package/dist/core/importer/lexer.js.map +1 -0
- package/dist/core/importer/names.d.ts +41 -0
- package/dist/core/importer/names.d.ts.map +1 -0
- package/dist/core/importer/names.js +78 -0
- package/dist/core/importer/names.js.map +1 -0
- package/dist/core/importer/orders.d.ts +8 -0
- package/dist/core/importer/orders.d.ts.map +1 -0
- package/dist/core/importer/orders.js +332 -0
- package/dist/core/importer/orders.js.map +1 -0
- package/dist/core/importer/outputs.d.ts +19 -0
- package/dist/core/importer/outputs.d.ts.map +1 -0
- package/dist/core/importer/outputs.js +266 -0
- package/dist/core/importer/outputs.js.map +1 -0
- package/dist/core/importer/parser.d.ts +5 -0
- package/dist/core/importer/parser.d.ts.map +1 -0
- package/dist/core/importer/parser.js +439 -0
- package/dist/core/importer/parser.js.map +1 -0
- package/dist/core/importer/presence.d.ts +32 -0
- package/dist/core/importer/presence.d.ts.map +1 -0
- package/dist/core/importer/presence.js +146 -0
- package/dist/core/importer/presence.js.map +1 -0
- package/dist/core/importer/settle.d.ts +23 -0
- package/dist/core/importer/settle.d.ts.map +1 -0
- package/dist/core/importer/settle.js +135 -0
- package/dist/core/importer/settle.js.map +1 -0
- package/dist/core/importer/statements.d.ts +4 -0
- package/dist/core/importer/statements.d.ts.map +1 -0
- package/dist/core/importer/statements.js +339 -0
- package/dist/core/importer/statements.js.map +1 -0
- package/dist/core/importer/syntax.d.ts +182 -0
- package/dist/core/importer/syntax.d.ts.map +1 -0
- package/dist/core/importer/syntax.js +14 -0
- package/dist/core/importer/syntax.js.map +1 -0
- package/dist/core/importer/table.d.ts +52 -0
- package/dist/core/importer/table.d.ts.map +1 -0
- package/dist/core/importer/table.js +156 -0
- package/dist/core/importer/table.js.map +1 -0
- package/dist/core/importer/values.d.ts +27 -0
- package/dist/core/importer/values.d.ts.map +1 -0
- package/dist/core/importer/values.js +236 -0
- package/dist/core/importer/values.js.map +1 -0
- package/dist/core/index.d.ts +22 -5
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +19 -3
- package/dist/core/index.js.map +1 -1
- package/dist/core/stdlib/calendar/civil.d.ts.map +1 -1
- package/dist/core/stdlib/calendar/civil.js +5 -2
- package/dist/core/stdlib/calendar/civil.js.map +1 -1
- package/dist/core/stdlib/index.d.ts +1 -1
- package/dist/core/stdlib/index.d.ts.map +1 -1
- package/dist/core/stdlib/index.js +1 -1
- package/dist/core/stdlib/index.js.map +1 -1
- package/dist/core/stdlib/maths/index.d.ts +1 -1
- package/dist/core/stdlib/maths/index.d.ts.map +1 -1
- package/dist/core/stdlib/maths/index.js +1 -1
- package/dist/core/stdlib/maths/index.js.map +1 -1
- package/dist/core/stdlib/maths/rounding.d.ts +5 -0
- package/dist/core/stdlib/maths/rounding.d.ts.map +1 -1
- package/dist/core/stdlib/maths/rounding.js +19 -1
- package/dist/core/stdlib/maths/rounding.js.map +1 -1
- package/dist/core/version/version.generated.d.ts +1 -1
- package/dist/core/version/version.generated.js +1 -1
- package/package.json +17 -2
- package/spec/README.md +2 -1
- package/spec/errors.json +383 -23
- package/src/adapters/charts/driving.ts +109 -0
- package/src/adapters/charts/run.ts +126 -28
- package/src/adapters/charts/tables.ts +6 -19
- package/src/adapters/charts/undrawable.ts +51 -0
- package/src/adapters/charts/venue.ts +132 -0
- package/src/core/accounting/analysis.ts +188 -0
- package/src/core/accounting/equity.ts +38 -0
- package/src/core/accounting/index.ts +2 -0
- package/src/core/accounting/report.ts +5 -0
- package/src/core/accounting/statistics.ts +38 -1
- package/src/core/backtest/case.ts +395 -0
- package/src/core/backtest/compare.ts +2 -0
- package/src/core/backtest/deliver.ts +161 -0
- package/src/core/backtest/drive.ts +233 -217
- package/src/core/backtest/index.ts +26 -12
- package/src/core/backtest/record.ts +134 -5
- package/src/core/backtest/replay.ts +11 -1
- package/src/core/backtest/simulate.ts +201 -6
- package/src/core/backtest/walk.ts +182 -0
- package/src/core/catalogue/catalogue.generated.ts +19 -2
- package/src/core/catalogue/types.ts +8 -2
- package/src/core/catalogue/values.generated.ts +16 -0
- package/src/core/check/assigned.ts +31 -0
- package/src/core/check/call-sites.ts +11 -4
- package/src/core/check/calls.ts +13 -4
- package/src/core/check/check.ts +14 -2
- package/src/core/check/checker.ts +39 -2
- package/src/core/check/constant.ts +57 -0
- package/src/core/check/deleted.ts +135 -0
- package/src/core/check/expressions.ts +1 -1
- package/src/core/check/library-orders.ts +2 -2
- package/src/core/check/library-output.ts +1 -0
- package/src/core/check/library-prose.generated.ts +12 -12
- package/src/core/check/library.ts +8 -0
- package/src/core/check/surface.ts +16 -0
- package/src/core/emit/canonical.ts +67 -9
- package/src/core/engine/arithmetic.ts +23 -3
- package/src/core/engine/bar-source.ts +113 -0
- package/src/core/engine/engine.ts +26 -25
- package/src/core/engine/guard.ts +12 -1
- package/src/core/engine/host.ts +4 -2
- package/src/core/engine/index.ts +2 -1
- package/src/core/engine/library/arrays.ts +8 -2
- package/src/core/engine/library/binding.ts +2 -0
- package/src/core/engine/library/code-points.ts +73 -0
- package/src/core/engine/library/index.ts +17 -0
- package/src/core/engine/library/objects.ts +1 -6
- package/src/core/engine/library/text.ts +53 -35
- package/src/core/engine/load.ts +68 -0
- package/src/core/engine/request-body.ts +5 -7
- package/src/core/engine/request-plan.ts +3 -3
- package/src/core/engine/requests.ts +11 -8
- package/src/core/engine/series.ts +30 -6
- package/src/core/engine/session/record.ts +4 -4
- package/src/core/engine/verify-tables.ts +43 -0
- package/src/core/importer/calls.ts +274 -0
- package/src/core/importer/context.ts +197 -0
- package/src/core/importer/expressions.ts +247 -0
- package/src/core/importer/importer.ts +226 -0
- package/src/core/importer/index.ts +19 -0
- package/src/core/importer/lexer.ts +285 -0
- package/src/core/importer/names.ts +104 -0
- package/src/core/importer/orders.ts +307 -0
- package/src/core/importer/outputs.ts +245 -0
- package/src/core/importer/parser.ts +436 -0
- package/src/core/importer/presence.ts +164 -0
- package/src/core/importer/settle.ts +141 -0
- package/src/core/importer/statements.ts +331 -0
- package/src/core/importer/syntax.ts +144 -0
- package/src/core/importer/table.ts +191 -0
- package/src/core/importer/values.ts +241 -0
- package/src/core/index.ts +29 -2
- package/src/core/stdlib/calendar/civil.ts +5 -2
- package/src/core/stdlib/index.ts +1 -0
- package/src/core/stdlib/maths/index.ts +1 -0
- package/src/core/stdlib/maths/rounding.ts +23 -1
- package/src/core/version/version.generated.ts +1 -1
package/README.md
CHANGED
|
@@ -15,10 +15,21 @@ can write their own engine for it.
|
|
|
15
15
|
|
|
16
16
|
---
|
|
17
17
|
|
|
18
|
+
## Architecture at a glance
|
|
19
|
+
|
|
20
|
+
[](https://raw.githubusercontent.com/marketcalls/openscript/main/docs/architecture-overview.png)
|
|
21
|
+
|
|
22
|
+
Write an indicator or a strategy once, then use it on a chart or test it against
|
|
23
|
+
historical data. Your platform supplies the editor, saved scripts, market data
|
|
24
|
+
and connections. The live runner is planned, with sandbox testing before live
|
|
25
|
+
execution; see [Phase 6](./ROADMAP.md#phase-6-the-second-engine-and-live-running).
|
|
26
|
+
|
|
18
27
|
## Status
|
|
19
28
|
|
|
20
|
-
**`0.
|
|
21
|
-
|
|
29
|
+
**`0.6.0` runs studies, backtests strategies, draws a strategy on a chart,
|
|
30
|
+
imports scripts from another chart language, and ships the language
|
|
31
|
+
intelligence an editor needs.** The Python engine is on PyPI
|
|
32
|
+
as `openscript`, at the same version, and the two are released together.
|
|
22
33
|
|
|
23
34
|
What an install gets you today: the compiler, the engine, the chart adapter and
|
|
24
35
|
the backtest. A script compiles in milliseconds in a browser tab and computes,
|
|
@@ -34,6 +45,15 @@ examples on every run rather than asserting it in a page. Two records can be put
|
|
|
34
45
|
beside each other, and a pair over different bars is reported incomparable
|
|
35
46
|
instead of being subtracted into a table that reads like a result.
|
|
36
47
|
|
|
48
|
+
**New in `0.6.0`:** `importScript`
|
|
49
|
+
imports a script written in the version-annotated chart dialect, translating
|
|
50
|
+
each statement with its meaning or saying why not; `engine.run` takes a history
|
|
51
|
+
as columns as well as one record per bar; `npm run site` builds a documentation
|
|
52
|
+
site from the specification and the error catalogue; and the Python engine
|
|
53
|
+
holds every library entry the first one does. [`CHANGELOG.md`](./CHANGELOG.md)
|
|
54
|
+
says what changed under a deployment, including a `"lookahead"` read in a
|
|
55
|
+
backtest.
|
|
56
|
+
|
|
37
57
|
What it does **not** do yet, stated plainly because the registry page is the
|
|
38
58
|
first thing a stranger reads:
|
|
39
59
|
|
|
@@ -43,10 +63,9 @@ first thing a stranger reads:
|
|
|
43
63
|
because a backtest works out no running equity to size against. The equity
|
|
44
64
|
curve marks a trade at the size it ended up entering, so a strategy that
|
|
45
65
|
scales in is reported with a drawdown deeper than the account had. A script
|
|
46
|
-
still cannot read its own equity mid-run.
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
already believed.
|
|
66
|
+
still cannot read its own equity mid-run. [`CHANGELOG.md`](./CHANGELOG.md) is
|
|
67
|
+
the full list, release by release, and every item on it is there because
|
|
68
|
+
somebody would otherwise find it inside a report they had already believed.
|
|
50
69
|
- **No editor on screen, and that is the design.** The six headless functions are
|
|
51
70
|
here and resolve as `openalgo-script/editor`: highlight, complete, diagnose,
|
|
52
71
|
hover, signature and format, text in and data out, with no DOM at any tier. The
|
|
@@ -57,14 +76,38 @@ first thing a stranger reads:
|
|
|
57
76
|
[`docs/integrating/the-editor-half.md`](./docs/integrating/the-editor-half.md).
|
|
58
77
|
The language server that would put the same errors in a desktop editor is the
|
|
59
78
|
rest of Phase 4 and is not written.
|
|
60
|
-
- **No
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
79
|
+
- **No engine anybody else wrote has run the suite, so the portability claim is
|
|
80
|
+
still untested.** The second engine is here: `engine/` holds a complete engine
|
|
81
|
+
in Python, published to PyPI as `openscript`, with a test suite of its own,
|
|
82
|
+
and `npm test` runs both on every build. A run record carries its own source
|
|
83
|
+
text rather than only a hash of it (`sourceText` in
|
|
84
|
+
[`src/core/backtest/record.ts`](./src/core/backtest/record.ts)), and
|
|
85
|
+
`caseFilesFrom` in [`src/core/backtest/case.ts`](./src/core/backtest/case.ts)
|
|
86
|
+
writes the files a suite runs from straight out of a record, which is where the
|
|
87
|
+
strategy cases under [`cases/`](./cases) came from.
|
|
88
|
+
|
|
89
|
+
There are 106 cases now: 52 in the `core` profile, 46 in `chart` and 8 in
|
|
90
|
+
`strategy`. They assert eight of the channels section 4 of
|
|
91
|
+
[`spec/conformance.md`](./spec/conformance.md) defines: diagnostics, a value
|
|
92
|
+
per bar per plot, the log, drawing objects, grid cells, orders, trades and the
|
|
93
|
+
report. Markers, fills, levels, paint and alerts have no case yet, and neither
|
|
94
|
+
engine's adapter answers them. So the `semantics` and
|
|
95
|
+
`numerics` categories, which are the reason the suite exists, now hold real
|
|
96
|
+
cases, each with expected values computed independently of both engines.
|
|
97
|
+
|
|
98
|
+
`npm run suite:agree` reports 87 pass and 19 skipped of 106 between the two
|
|
99
|
+
engines, exactly, the skips being the compiler-diagnostic cases the Python
|
|
100
|
+
engine rightly has no compiler for. The two engines hold the same 251 library
|
|
101
|
+
entries, which a check asks each of them for on every build. What that run
|
|
102
|
+
does not prove is the thing the suite exists for: both engines were written
|
|
103
|
+
in this repository, from the same specification, by the same hands, so their
|
|
104
|
+
agreement is evidence about this repository rather than about the
|
|
105
|
+
specification. Until an engine written by somebody who had only the
|
|
106
|
+
specification passes these cases, portability is a design with one
|
|
107
|
+
corroborating implementation, not a result. That is why no conformance badge
|
|
108
|
+
is shown here, though `npm run badge` will make one for an engine that passes.
|
|
109
|
+
|
|
110
|
+
The version is `0.6.0` rather than `1.0` because of that list. The studies
|
|
68
111
|
surface is the part that is finished, and it is the part to build on.
|
|
69
112
|
|
|
70
113
|
`ROADMAP.md` says what each phase owes before it is allowed to finish. The
|
|
@@ -116,10 +159,14 @@ OpenScript is the opposite of that:
|
|
|
116
159
|
timeout, and nothing you drew silently dropped to make room for the next one.
|
|
117
160
|
- **Honest.** A higher timeframe read has to say whether it repaints. The
|
|
118
161
|
compiler warns when a script would.
|
|
119
|
-
- **Connected.**
|
|
120
|
-
|
|
162
|
+
- **Connected.** Designed to route orders through your own broker connection,
|
|
163
|
+
with sandbox testing before live execution. The live runner is planned.
|
|
121
164
|
- **Open.** Apache-2.0, a written specification, and a conformance suite anyone
|
|
122
|
-
can run against their own implementation
|
|
165
|
+
can run against their own implementation: the compiler's diagnostics, the
|
|
166
|
+
runtime errors and limits, the per-bar values, the calendar, drawing objects,
|
|
167
|
+
grids, reads of other timeframes and instruments, and strategy fills and
|
|
168
|
+
reports. [The suite's own page](./spec/conformance.md) says what a pass does
|
|
169
|
+
and does not entitle an implementation to claim.
|
|
123
170
|
|
|
124
171
|
## How it is built
|
|
125
172
|
|
|
@@ -132,8 +179,10 @@ That one decision carries the whole project:
|
|
|
132
179
|
and nothing for a security team to approve.
|
|
133
180
|
2. A server-side engine is a few hundred lines that walk an instruction list,
|
|
134
181
|
not a second implementation of the language.
|
|
135
|
-
3. Anyone can write an engine in any language, and
|
|
136
|
-
the
|
|
182
|
+
3. Anyone can write an engine in any language, and hold it to the conformance
|
|
183
|
+
suite. What the suite reaches today is written down rather than implied: an
|
|
184
|
+
engine claiming the narrowest profile is handed cases and fails if it
|
|
185
|
+
answers none of them, which it was not before the `core` cases existed.
|
|
137
186
|
|
|
138
187
|
One compiler. One compiled format. Many small engines, all of which must agree
|
|
139
188
|
to the last decimal.
|
|
@@ -146,14 +195,49 @@ own, with their fixes taken from the error catalogue. A host supplies the text
|
|
|
146
195
|
component and the panel around it, and keeps its own design. The editor is not a
|
|
147
196
|
second implementation of the language to be kept in step.
|
|
148
197
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
198
|
+
[](https://raw.githubusercontent.com/marketcalls/openscript/main/docs/architecture-compiler.png)
|
|
199
|
+
|
|
200
|
+
### From source to a compiled program
|
|
201
|
+
|
|
202
|
+
| Stage | What happens | Implementation |
|
|
203
|
+
|---|---|---|
|
|
204
|
+
| Lex | Turns text into tokens with source positions. Newlines, indentation and dedentation become explicit tokens, so later stages do not reinterpret whitespace. | [`src/core/lex`](./src/core/lex/index.ts) |
|
|
205
|
+
| Parse | Builds the abstract syntax tree (AST). It recovers around malformed statements so an editor can still work with a partially typed file. | [`src/core/parse`](./src/core/parse/index.ts) |
|
|
206
|
+
| Check | Resolves names, checks types and calls, determines storage and tracks when a value becomes available. `CheckedScript` keeps those answers beside the original tree. | [`src/core/check`](./src/core/check/index.ts) |
|
|
207
|
+
| Emit | Allocates registers and persistent state, lowers statements into instructions, links calls and requests, and checks stack depths and limits. | [`src/core/emit`](./src/core/emit/emit.ts) |
|
|
208
|
+
|
|
209
|
+
The result is a [`CompiledProgram`](./src/core/emit/program.ts), not executable
|
|
210
|
+
code in the host's language. Alongside its instructions it carries the constants,
|
|
211
|
+
inputs, output declarations, storage layout and source mapping the engine needs.
|
|
212
|
+
Its [canonical encoding](./src/core/emit/canonical.ts) makes the program portable
|
|
213
|
+
and gives it stable bytes for hashing. The language and compiled format have
|
|
214
|
+
separate versions, defined by the [compiled program specification](./spec/compiled-program.md).
|
|
215
|
+
|
|
216
|
+
Every compiler stage reports through the same diagnostic system. Codes, messages
|
|
217
|
+
and fixes come from the [error catalogue](./spec/errors.json); the
|
|
218
|
+
[headless editor](./src/editor/index.ts) reuses the compiler and its language
|
|
219
|
+
tables for highlighting, completion, diagnostics, hover, signatures and formatting.
|
|
220
|
+
|
|
221
|
+
### From a compiled program to results
|
|
222
|
+
|
|
223
|
+
Before the first bar, [`load`](./src/core/engine/load.ts) verifies the program's
|
|
224
|
+
format, capabilities, tables and instructions, including stack and address
|
|
225
|
+
bounds. It checks the host's limits, resolves inputs and plans requested series.
|
|
226
|
+
A rejected program returns a diagnostic before execution starts.
|
|
227
|
+
|
|
228
|
+
The [engine](./src/core/engine/engine.ts) then advances one bar at a time. Its
|
|
229
|
+
[interpreter](./src/core/engine/machine.ts) walks the instruction list using
|
|
230
|
+
registers, persistent memory and the standard library, with instruction, memory
|
|
231
|
+
and time budgets. Updating the newest bar restores its checkpoint before
|
|
232
|
+
recomputing it; explicitly live state is retained. Drawing values are published
|
|
233
|
+
on updates, while signals, alerts and orders follow the confirmation policy.
|
|
234
|
+
|
|
235
|
+
The [chart adapter](./src/adapters/charts/index.ts) maps study outputs into the
|
|
236
|
+
host's chart. The [backtest driver](./src/core/backtest/drive.ts) supplies a
|
|
237
|
+
simulated order destination and records frames, fills, orders and the report.
|
|
238
|
+
[Replay and rerun](./src/core/backtest/replay.ts) let a stored result be checked
|
|
239
|
+
again. The host owns data access, rendering, persistence and order routing;
|
|
240
|
+
the language core does not reach into those systems itself.
|
|
157
241
|
|
|
158
242
|
## The pieces, and which way they point
|
|
159
243
|
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walking the bars, for a study and for a strategy.
|
|
3
|
+
*
|
|
4
|
+
* Split from `run.ts` because they are two things. That file decides what an
|
|
5
|
+
* engine is loaded with: the host record, the clock, the settings, the venue.
|
|
6
|
+
* This one decides how the bars are then handed over, and the two differ by
|
|
7
|
+
* exactly one thing, whether frames have to reach the engine between them.
|
|
8
|
+
*/
|
|
9
|
+
import type { CompiledProgram } from '../../core/emit/index.js';
|
|
10
|
+
import type { Engine } from '../../core/engine/index.js';
|
|
11
|
+
import type { ChartBar, ChartCalcContext, ChartSettings } from './contract.js';
|
|
12
|
+
import type { HeldVenue } from './venue.js';
|
|
13
|
+
/**
|
|
14
|
+
* A run in hand, held between a chart's recomputes.
|
|
15
|
+
*
|
|
16
|
+
* The signature and the bar times are what a tail run is checked against before
|
|
17
|
+
* it is trusted: splicing a tail onto a history that has changed underneath it
|
|
18
|
+
* draws a wrong study that looks entirely plausible.
|
|
19
|
+
*/
|
|
20
|
+
export interface Held {
|
|
21
|
+
readonly engine: Engine;
|
|
22
|
+
readonly signature: string;
|
|
23
|
+
count: number;
|
|
24
|
+
firstTime: number;
|
|
25
|
+
lastTime: number;
|
|
26
|
+
/**
|
|
27
|
+
* The destination this run's orders go to, for a strategy.
|
|
28
|
+
*
|
|
29
|
+
* Held with the engine because the two are one run: the venue holds the
|
|
30
|
+
* orders that have not filled yet, and an engine continued onto a new bar
|
|
31
|
+
* against a fresh venue would have its working orders silently forgotten.
|
|
32
|
+
*/
|
|
33
|
+
readonly venue: HeldVenue | null;
|
|
34
|
+
}
|
|
35
|
+
/** A study: every bar in one hand-over, which is what `run` is for. */
|
|
36
|
+
export declare function runWhole(engine: Engine, bars: readonly ChartBar[], ctx: ChartCalcContext | undefined, program: CompiledProgram, settings: ChartSettings): Held;
|
|
37
|
+
/**
|
|
38
|
+
* A strategy: one bar at a time, with the venue answering between them.
|
|
39
|
+
*
|
|
40
|
+
* The order is deliver, execute, then ask. A driver that asked the venue before
|
|
41
|
+
* executing would price a fill against a bar the strategy had not seen yet, and
|
|
42
|
+
* one that delivered after executing would let a script read a position its own
|
|
43
|
+
* order on this bar had just created.
|
|
44
|
+
*
|
|
45
|
+
* `supplied` is the whole count rather than the index reached, so `bar.isLast`
|
|
46
|
+
* means the same on this path as on the one above it: a strategy written to act
|
|
47
|
+
* on the final bar acts on the final bar, not on every bar in turn.
|
|
48
|
+
*/
|
|
49
|
+
export declare function walkWith(engine: Engine, held: HeldVenue, bars: readonly ChartBar[], ctx: ChartCalcContext | undefined, program: CompiledProgram, settings: ChartSettings): Held;
|
|
50
|
+
//# sourceMappingURL=driving.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driving.d.ts","sourceRoot":"","sources":["../../../src/adapters/charts/driving.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAI/E,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAE5C;;;;;;GAMG;AACH,MAAM,WAAW,IAAI;IACnB,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,KAAK,EAAE,MAAM,CAAC;IACd,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;OAMG;IACH,QAAQ,CAAC,KAAK,EAAE,SAAS,GAAG,IAAI,CAAC;CAClC;AAED,uEAAuE;AACvE,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,aAAa,GACtB,IAAI,CAON;AAED;;;;;;;;;;;GAWG;AACH,wBAAgB,QAAQ,CACtB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,SAAS,EACf,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,OAAO,EAAE,eAAe,EACxB,QAAQ,EAAE,aAAa,GACtB,IAAI,CAcN"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Walking the bars, for a study and for a strategy.
|
|
3
|
+
*
|
|
4
|
+
* Split from `run.ts` because they are two things. That file decides what an
|
|
5
|
+
* engine is loaded with: the host record, the clock, the settings, the venue.
|
|
6
|
+
* This one decides how the bars are then handed over, and the two differ by
|
|
7
|
+
* exactly one thing, whether frames have to reach the engine between them.
|
|
8
|
+
*/
|
|
9
|
+
import { hostBar, stateFor } from './bars.js';
|
|
10
|
+
import { stopped } from './errors.js';
|
|
11
|
+
import { signatureOf } from './settings.js';
|
|
12
|
+
import { answersFor } from './venue.js';
|
|
13
|
+
/** A study: every bar in one hand-over, which is what `run` is for. */
|
|
14
|
+
export function runWhole(engine, bars, ctx, program, settings) {
|
|
15
|
+
const result = engine.run(bars.map(hostBar), bars.map((_, index) => stateFor(index, bars, ctx)));
|
|
16
|
+
if (result.diagnostic !== undefined)
|
|
17
|
+
throw stopped(result.diagnostic);
|
|
18
|
+
return heldFrom(engine, null, bars, program, settings);
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* A strategy: one bar at a time, with the venue answering between them.
|
|
22
|
+
*
|
|
23
|
+
* The order is deliver, execute, then ask. A driver that asked the venue before
|
|
24
|
+
* executing would price a fill against a bar the strategy had not seen yet, and
|
|
25
|
+
* one that delivered after executing would let a script read a position its own
|
|
26
|
+
* order on this bar had just created.
|
|
27
|
+
*
|
|
28
|
+
* `supplied` is the whole count rather than the index reached, so `bar.isLast`
|
|
29
|
+
* means the same on this path as on the one above it: a strategy written to act
|
|
30
|
+
* on the final bar acts on the final bar, not on every bar in turn.
|
|
31
|
+
*/
|
|
32
|
+
export function walkWith(engine, held, bars, ctx, program, settings) {
|
|
33
|
+
for (let index = 0; index < bars.length; index += 1) {
|
|
34
|
+
const bar = bars[index];
|
|
35
|
+
if (bar === undefined)
|
|
36
|
+
continue;
|
|
37
|
+
for (const frame of held.pending)
|
|
38
|
+
engine.deliver(frame);
|
|
39
|
+
held.pending = [];
|
|
40
|
+
const result = engine.append(hostBar(bar), stateFor(index, bars, ctx), bars.length);
|
|
41
|
+
if (result.diagnostic !== undefined)
|
|
42
|
+
throw stopped(result.diagnostic);
|
|
43
|
+
answersFor(held, index);
|
|
44
|
+
}
|
|
45
|
+
return heldFrom(engine, held, bars, program, settings);
|
|
46
|
+
}
|
|
47
|
+
function heldFrom(engine, venue, bars, program, settings) {
|
|
48
|
+
return {
|
|
49
|
+
engine,
|
|
50
|
+
venue,
|
|
51
|
+
signature: signatureOf(program, settings),
|
|
52
|
+
count: bars.length,
|
|
53
|
+
firstTime: bars[0]?.time ?? 0,
|
|
54
|
+
lastTime: bars[bars.length - 1]?.time ?? 0,
|
|
55
|
+
};
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=driving.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"driving.js","sourceRoot":"","sources":["../../../src/adapters/charts/driving.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAIH,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAE9C,OAAO,EAAE,OAAO,EAAE,MAAM,aAAa,CAAC;AACtC,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC5C,OAAO,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AA0BxC,uEAAuE;AACvE,MAAM,UAAU,QAAQ,CACtB,MAAc,EACd,IAAyB,EACzB,GAAiC,EACjC,OAAwB,EACxB,QAAuB;IAEvB,MAAM,MAAM,GAAG,MAAM,CAAC,GAAG,CACvB,IAAI,CAAC,GAAG,CAAC,OAAO,CAAC,EACjB,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,KAAK,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,CACnD,CAAC;IACF,IAAI,MAAM,CAAC,UAAU,KAAK,SAAS;QAAE,MAAM,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IACtE,OAAO,QAAQ,CAAC,MAAM,EAAE,IAAI,EAAE,IAAI,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC;AACzD,CAAC;AAED;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,QAAQ,CACtB,MAAc,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@ -98,6 +98,26 @@ export interface ChartAdapterOptions {
|
|
|
98
98
|
* (`stdlib.md` 17.1), never handed over by the chart.
|
|
99
99
|
*/
|
|
100
100
|
readonly orders?: EffectRoute;
|
|
101
|
+
/**
|
|
102
|
+
* Run a strategy against a simulated destination where the host gives none.
|
|
103
|
+
*
|
|
104
|
+
* **Off by default, because the refusal it replaces is useful.** A strategy
|
|
105
|
+
* with nowhere to send an order is refused at load with OS6006 naming the
|
|
106
|
+
* capability, which is exactly what a host that meant to wire a destination
|
|
107
|
+
* and forgot needs to be told. A chart that quietly filled one in for them
|
|
108
|
+
* would draw a convincing strategy that routed nothing.
|
|
109
|
+
*
|
|
110
|
+
* **On, it is the venue a backtest uses.** A chart drawing a strategy then
|
|
111
|
+
* fills the same orders at the same prices as the report of the same script,
|
|
112
|
+
* so the marks on the price and the trades in the report are one answer
|
|
113
|
+
* rather than two. This is what a host turns on to draw a strategy the way it
|
|
114
|
+
* draws a study: the plots, the legend row and the settings all follow from
|
|
115
|
+
* the program running at all.
|
|
116
|
+
*
|
|
117
|
+
* It does not place an order anywhere. A host that wants that supplies
|
|
118
|
+
* `orders`, which wins over this.
|
|
119
|
+
*/
|
|
120
|
+
readonly simulateOrders?: boolean;
|
|
101
121
|
readonly limits?: Partial<EngineLimits>;
|
|
102
122
|
readonly clock?: Clock;
|
|
103
123
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.d.ts","sourceRoot":"","sources":["../../../src/adapters/charts/run.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,OAAO,KAAK,EACV,KAAK,EACL,WAAW,EAGX,YAAY,EACZ,IAAI,EAEJ,UAAU,EACV,OAAO,EAEP,KAAK,EACN,MAAM,4BAA4B,CAAC;AAEpC,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAC;AAChE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AAEtD,OAAO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xC,QAAQ,CAAC,KAAK,CAAC,EAAE,KAAK,CAAC;IACvB;;;;;;;OAOG;IACH,QAAQ,CAAC,WAAW,CAAC,EAAE,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,KAAK,MAAM,CAAC;CACnE;AAMD,gEAAgE;AAChE,MAAM,MAAM,OAAO,GAAG,SAAS,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,CAAC;AAEpD;;;;;;;;GAQG;AACH,MAAM,WAAW,SAAS;IACxB,QAAQ,CAAC,OAAO,EAAE,OAAO,CAAC;IAC1B,QAAQ,CAAC,MAAM,EAAE,SAAS,IAAI,EAAE,CAAC;IACjC,QAAQ,CAAC,QAAQ,EAAE,SAAS,OAAO,EAAE,CAAC;CACvC;AAED,wBAAgB,OAAO,CACrB,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,gBAAgB,GAAG,SAAS,EACjC,OAAO,EAAE,mBAAmB,GAC3B,SAAS,CAmBX;AAED;;;;;;;;GAQG;AACH,wBAAgB,OAAO,CACrB,OAAO,EAAE,eAAe,EACxB,IAAI,EAAE,SAAS,QAAQ,EAAE,EACzB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,aAAa,EACvB,KAAK,EAAE,UAAU,EACjB,GAAG,EAAE,gBAAgB,GAAG,SAAS,EAGjC,QAAQ,EAAE,mBAAmB,GAC5B,SAAS,GAAG,IAAI,CA6ClB;AAED;;;;;GAKG;AACH,wBAAgB,OAAO,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAG/C"}
|
|
@@ -1,23 +1,29 @@
|
|
|
1
1
|
import { load, utcTime } from '../../core/engine/index.js';
|
|
2
2
|
import { hostBar, hostNow, stateFor } from './bars.js';
|
|
3
3
|
import { refused, stopped } from './errors.js';
|
|
4
|
+
import { undrawable } from './undrawable.js';
|
|
4
5
|
import { stationIn, stationOf } from './requests.js';
|
|
5
6
|
import { engineSettings, signatureOf } from './settings.js';
|
|
7
|
+
import { answersFor, needsVenue, routeInto, venueFor } from './venue.js';
|
|
8
|
+
import { runWhole, walkWith } from './driving.js';
|
|
9
|
+
/** The engine one chart instance is holding, between recomputes. */
|
|
6
10
|
/** The store key. Namespaced, because the store belongs to the host as well. */
|
|
7
11
|
const HELD = 'openscript';
|
|
8
12
|
export function fullRun(program, bars, settings, store, ctx, options) {
|
|
9
13
|
const station = stationIn(store);
|
|
10
|
-
const
|
|
11
|
-
const
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
14
|
+
const started = start(program, settings, ctx, options, station.provider(bars), bars);
|
|
15
|
+
const engine = started.engine;
|
|
16
|
+
// **A strategy is walked bar by bar and a study is handed the lot.** The
|
|
17
|
+
// difference is the venue: its frames reach the engine between bars, which is
|
|
18
|
+
// the only place they can, so a strategy's position is right on the bar after
|
|
19
|
+
// the one it traded on. `run()` has no gap to put them in.
|
|
20
|
+
//
|
|
21
|
+
// It is also the loop the backtest uses, which is the point: a chart drawing a
|
|
22
|
+
// strategy and a report of the same strategy walk the same bars in the same
|
|
23
|
+
// order against the same venue, so they cannot disagree about what filled.
|
|
24
|
+
const held = started.venue === null
|
|
25
|
+
? runWhole(engine, bars, ctx, program, settings)
|
|
26
|
+
: walkWith(engine, started.venue, bars, ctx, program, settings);
|
|
21
27
|
store[HELD] = held;
|
|
22
28
|
station.settle();
|
|
23
29
|
return outputOf(program, engine);
|
|
@@ -51,11 +57,28 @@ _options) {
|
|
|
51
57
|
if (bar === undefined)
|
|
52
58
|
return null;
|
|
53
59
|
const state = stateFor(index, bars, ctx);
|
|
60
|
+
// The venue's answers about the bar before this one, delivered before this
|
|
61
|
+
// one runs, exactly as the full walk does. A tail that skipped this would
|
|
62
|
+
// draw the first bars of a strategy correctly and then quietly stop folding
|
|
63
|
+
// its fills the moment the chart went live, which is the half of the run
|
|
64
|
+
// nobody re-checks.
|
|
65
|
+
//
|
|
66
|
+
// Only when the bar is new. Re-executing the bar that moved must not
|
|
67
|
+
// deliver again: a frame is cumulative and folding one twice is harmless,
|
|
68
|
+
// but the bar's own orders have been rolled back and answering them a
|
|
69
|
+
// second time would fill an order the engine no longer knows it sent.
|
|
70
|
+
if (held.venue !== null && index !== from) {
|
|
71
|
+
for (const frame of held.venue.pending)
|
|
72
|
+
held.engine.deliver(frame);
|
|
73
|
+
held.venue.pending = [];
|
|
74
|
+
}
|
|
54
75
|
const result = index === from
|
|
55
76
|
? held.engine.update(hostBar(bar), state)
|
|
56
77
|
: held.engine.append(hostBar(bar), state);
|
|
57
78
|
if (result.diagnostic !== undefined)
|
|
58
79
|
throw stopped(result.diagnostic);
|
|
80
|
+
if (held.venue !== null)
|
|
81
|
+
answersFor(held.venue, index);
|
|
59
82
|
}
|
|
60
83
|
held.count = bars.length;
|
|
61
84
|
held.lastTime = bars[bars.length - 1]?.time ?? held.lastTime;
|
|
@@ -86,10 +109,43 @@ function outputOf(program, engine) {
|
|
|
86
109
|
// `tables.ts`'s own first paragraph.
|
|
87
110
|
return { columns, tables: engine.tables(), drawings: engine.drawings() };
|
|
88
111
|
}
|
|
89
|
-
|
|
112
|
+
/**
|
|
113
|
+
* Load the program, and give a strategy somewhere for its orders to go.
|
|
114
|
+
*
|
|
115
|
+
* **The venue is built after the load and reached through a holder, because
|
|
116
|
+
* neither can come first.** The route has to be handed to `load`, since that is
|
|
117
|
+
* what declares the `orders` capability and a program needing one is otherwise
|
|
118
|
+
* refused. The venue has to be built after it, because the declaration it reads
|
|
119
|
+
* may state its fill rule through an `input()`, and inputs are not resolved
|
|
120
|
+
* until `load` has run. The route is only ever called from inside an execution,
|
|
121
|
+
* which is after both, so the holder is always filled by the time anything
|
|
122
|
+
* reaches it.
|
|
123
|
+
*
|
|
124
|
+
* **A host that supplied its own route keeps it.** Somewhere real to send an
|
|
125
|
+
* order is a better destination than a simulated one, and a host that wired one
|
|
126
|
+
* up meant it.
|
|
127
|
+
*
|
|
128
|
+
* **And simulation is asked for rather than assumed.** Without
|
|
129
|
+
* `simulateOrders` a strategy with nowhere to send an order is still refused at
|
|
130
|
+
* load, which is the answer a host that meant to wire a destination and forgot
|
|
131
|
+
* needs to see. Filling in a venue for them would turn that mistake into a
|
|
132
|
+
* chart that draws convincingly and routes nothing, discovered whenever
|
|
133
|
+
* somebody next looked for the orders.
|
|
134
|
+
*/
|
|
135
|
+
function start(program, settings, ctx, options, requests, bars) {
|
|
136
|
+
const holder = { current: null };
|
|
137
|
+
const simulate = options.simulateOrders === true && options.orders === undefined && needsVenue(program);
|
|
138
|
+
const withRoute = simulate
|
|
139
|
+
? { ...options, orders: routeInto(holder) }
|
|
140
|
+
: options;
|
|
141
|
+
// What this chart has no room for is refused before the engine is asked,
|
|
142
|
+
// because a study drawn without it is a study that looks broken.
|
|
143
|
+
const narrower = undrawable(program);
|
|
144
|
+
if (narrower !== undefined)
|
|
145
|
+
throw refused(narrower);
|
|
90
146
|
const loaded = load(program, {
|
|
91
147
|
settings: engineSettings(program, settings),
|
|
92
|
-
host: hostFor(ctx,
|
|
148
|
+
host: hostFor(ctx, withRoute, requests),
|
|
93
149
|
time: timeFor(options, ctx?.timezone ?? ''),
|
|
94
150
|
...(options.limits === undefined ? {} : { limits: options.limits }),
|
|
95
151
|
...(options.source === undefined ? {} : { source: options.source }),
|
|
@@ -97,7 +153,13 @@ function start(program, settings, ctx, options, requests) {
|
|
|
97
153
|
});
|
|
98
154
|
if (!loaded.ok)
|
|
99
155
|
throw refused(loaded.diagnostic);
|
|
100
|
-
|
|
156
|
+
if (!simulate)
|
|
157
|
+
return { engine: loaded.engine, venue: null };
|
|
158
|
+
const venue = venueFor(program, bars, loaded.inputs, instrumentFor(ctx, options));
|
|
159
|
+
if (venue === null)
|
|
160
|
+
return { engine: loaded.engine, venue: null };
|
|
161
|
+
holder.current = venue;
|
|
162
|
+
return { engine: loaded.engine, venue: { venue, pending: [] } };
|
|
101
163
|
}
|
|
102
164
|
/**
|
|
103
165
|
* The host the engine reads, which always serves requests.
|
|
@@ -109,8 +171,16 @@ function start(program, settings, ctx, options, requests) {
|
|
|
109
171
|
* the chart's own sentence in `req.error`, instead of being refused at load
|
|
110
172
|
* with OS6006 naming a capability the chart does have.
|
|
111
173
|
*/
|
|
112
|
-
|
|
113
|
-
|
|
174
|
+
/**
|
|
175
|
+
* The instrument record, from what the host stated and what the chart knows.
|
|
176
|
+
*
|
|
177
|
+
* Its own function because two callers need it and they must not each build
|
|
178
|
+
* one: the engine is loaded with this record, and the venue prices fills
|
|
179
|
+
* against the tick size in it. Two spellings of the same record is how a fill
|
|
180
|
+
* gets rounded to a tick the strategy was never told about.
|
|
181
|
+
*/
|
|
182
|
+
function instrumentFor(ctx, options) {
|
|
183
|
+
return {
|
|
114
184
|
...(options.instrument ?? {}),
|
|
115
185
|
...(ctx?.symbol === undefined ? {} : { symbol: ctx.symbol }),
|
|
116
186
|
...(ctx?.interval === undefined ? {} : { interval: ctx.interval }),
|
|
@@ -121,6 +191,9 @@ function hostFor(ctx, options, requests) {
|
|
|
121
191
|
// the chart it was drawn on.
|
|
122
192
|
...(ctx === undefined || ctx.timezone === '' ? {} : { timezone: ctx.timezone }),
|
|
123
193
|
};
|
|
194
|
+
}
|
|
195
|
+
function hostFor(ctx, options, requests) {
|
|
196
|
+
const instrument = instrumentFor(ctx, options);
|
|
124
197
|
return {
|
|
125
198
|
instrument,
|
|
126
199
|
requestBars: requests,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"run.js","sourceRoot":"","sources":["../../../src/adapters/charts/run.ts"],"names":[],"mappings":"AAmCA,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,MAAM,4BAA4B,CAAC;AAG3D,OAAO,EAAE,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AAEvD,OAAO,EAAE,OAAO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
|
30
30
|
* **A chart pane holds one grid and the language declares as many as it likes.**
|
|
31
|
-
* The descriptor has one `table` hook,
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
* and
|
|
35
|
-
*
|
|
36
|
-
*
|
|
37
|
-
* **What ought to happen is a refusal, and it cannot be written yet.** A study
|
|
38
|
-
* whose second grid never appears is a study with no explanation, so the second
|
|
39
|
-
* `table()` should be refused where it is written, naming the limit. Every
|
|
40
|
-
* diagnostic in this project carries a catalogue code and the catalogue has
|
|
41
|
-
* none for "the chart cannot draw something this study declares"; inventing one
|
|
42
|
-
* here is the one thing that is not allowed, so the gap is reported instead, in
|
|
43
|
-
* `issues/0011-a-second-declared-grid-is-dropped-with-nothing-said.md`, with the
|
|
44
|
-
* sentence it should carry.
|
|
45
|
-
*
|
|
46
|
-
* Until it lands, the drop is at least no longer silent inside this repository:
|
|
47
|
-
* it is recorded in `spec/chart-narrowings.json` with its reason, and
|
|
48
|
-
* `scripts/check-chart-surface.mjs` fails the build if this adapter ever drops
|
|
49
|
-
* anything else a compiled program declares without recording it there.
|
|
31
|
+
* The descriptor has one `table` hook, and merging two grids into it would put
|
|
32
|
+
* cells somewhere the script never asked for. So a program declaring a second
|
|
33
|
+
* grid never reaches this file: `undrawable.ts` refuses it before any bar runs,
|
|
34
|
+
* with OS6024, and this reads the one grid a program that runs can have.
|
|
35
|
+
* `spec/chart-narrowings.json` records the refusal and
|
|
36
|
+
* `scripts/check-chart-surface.mjs` proves it with a study that declares two.
|
|
50
37
|
*/
|
|
51
38
|
import type { CompiledProgram } from '../../core/emit/index.js';
|
|
52
39
|
import type { Grid } from '../../core/engine/index.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/adapters/charts/tables.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"tables.d.ts","sourceRoot":"","sources":["../../../src/adapters/charts/tables.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoCG;AACH,OAAO,KAAK,EAAE,eAAe,EAAwB,MAAM,0BAA0B,CAAC;AACtF,OAAO,KAAK,EAAE,IAAI,EAAY,MAAM,4BAA4B,CAAC;AAGjE,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,OAAO,KAAK,EAGV,SAAS,EAEV,MAAM,eAAe,CAAC;AAYvB;;;;;;;;GAQG;AACH,wBAAgB,UAAU,CACxB,OAAO,EAAE,eAAe,EACxB,MAAM,EAAE,WAAW,EACnB,OAAO,EAAE,SAAS,IAAI,EAAE,GACvB,SAAS,GAAG,IAAI,CAIlB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/adapters/charts/tables.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"tables.js","sourceRoot":"","sources":["../../../src/adapters/charts/tables.ts"],"names":[],"mappings":"AAuCA,OAAO,EAAE,SAAS,EAAE,KAAK,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AASpE,6DAA6D;AAC7D,MAAM,OAAO,GAAiD;IAC5D,OAAO,EAAE,UAAU;IACnB,QAAQ,EAAE,WAAW;IACrB,UAAU,EAAE,aAAa;IACzB,WAAW,EAAE,cAAc;CAC5B,CAAC;AAEF,MAAM,UAAU,GAAsB,CAAC,MAAM,EAAE,QAAQ,EAAE,OAAO,CAAC,CAAC;AAElE;;;;;;;;GAQG;AACH,MAAM,UAAU,UAAU,CACxB,OAAwB,EACxB,MAAmB,EACnB,OAAwB;IAExB,MAAM,QAAQ,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC;IAC3C,IAAI,QAAQ,KAAK,SAAS;QAAE,OAAO,IAAI,CAAC;IACxC,OAAO,QAAQ,CAAC,QAAQ,EAAE,MAAM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