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
|
@@ -25,16 +25,65 @@
|
|
|
25
25
|
* is reported on bar k + 1. A frame answered after the last bar has no boundary
|
|
26
26
|
* left to fold at: it is not delivered, it is not recorded as delivered, and
|
|
27
27
|
* the order it was about is in the ledger at whatever it last said.
|
|
28
|
+
*
|
|
29
|
+
* **Two drivers, and the only difference between them is where the frames come
|
|
30
|
+
* from.** `backtest` runs against the simulated destination, which decides a
|
|
31
|
+
* fill from the bars and answers frames of its own; `backtestSupplied` is
|
|
32
|
+
* handed the frames and delivers those. Everything else about the two is one
|
|
33
|
+
* function below: the same window, the same load, the same refusals, the same
|
|
34
|
+
* loop and the same record.
|
|
28
35
|
*/
|
|
29
36
|
import { reportOf, scheduleFromDeclaration } from '../accounting/index.js';
|
|
30
37
|
import { load } from '../engine/index.js';
|
|
31
38
|
import { declarationOf } from './declaration.js';
|
|
39
|
+
import { Delivery, framedAs, ordinalsOf } from './deliver.js';
|
|
32
40
|
import { marksFor, windowFor } from './range.js';
|
|
33
|
-
import {
|
|
41
|
+
import { orderIn, recordOf } from './record.js';
|
|
34
42
|
import { Simulator } from './simulate.js';
|
|
35
43
|
import { checkSettings } from './settings.js';
|
|
44
|
+
import { walk } from './walk.js';
|
|
45
|
+
/**
|
|
46
|
+
* One run against a simulated destination, from a compiled program to a record.
|
|
47
|
+
*
|
|
48
|
+
* The frames are the destination's own: it is handed the orders, it reads the
|
|
49
|
+
* bars, and what it answers is what the engine folds. A run whose frames
|
|
50
|
+
* somebody else is supplying is `backtestSupplied` below.
|
|
51
|
+
*/
|
|
52
|
+
export function backtest(program, bars, settings, options = {}) {
|
|
53
|
+
return drive(program, bars, settings, options, (declared, schedule) => simulated(new Simulator({
|
|
54
|
+
bars,
|
|
55
|
+
contract: settings.contract,
|
|
56
|
+
fill: settings.fill,
|
|
57
|
+
slippageTicks: schedule.slippageTicks,
|
|
58
|
+
fillOn: declared.fillOn,
|
|
59
|
+
qtyType: declared.qtyType,
|
|
60
|
+
})));
|
|
61
|
+
}
|
|
36
62
|
/**
|
|
37
|
-
* One run
|
|
63
|
+
* One run over the frames somebody else supplied, which this engine does not
|
|
64
|
+
* choose and does not add to.
|
|
65
|
+
*
|
|
66
|
+
* `conformance.md` section 3 gives a case a `frames.csv` that supplies order
|
|
67
|
+
* frames the way `bars.csv` supplies bars, so that a case asserts the fold
|
|
68
|
+
* against input the engine did not choose. Every other argument is `backtest`'s
|
|
69
|
+
* and means there what it means here. A row is delivered at the boundary it
|
|
70
|
+
* names and folded before the next bar, and the record carries the rows it was
|
|
71
|
+
* handed rather than a second spelling of them.
|
|
72
|
+
*
|
|
73
|
+
* **Nothing is invented.** No fill is priced off a bar, no order rests and no
|
|
74
|
+
* schedule is read, so an order the frames say nothing about stays where its
|
|
75
|
+
* placement left it, which is what a case saying nothing about it means.
|
|
76
|
+
*
|
|
77
|
+
* **A record made here is a record of this run and not of a simulated one.**
|
|
78
|
+
* `rerun` puts a record's program back on a simulated destination, because a
|
|
79
|
+
* record does not say which of the two answered it, so a rerun of one of these
|
|
80
|
+
* reproduces it only where that destination would answer these same frames.
|
|
81
|
+
*/
|
|
82
|
+
export function backtestSupplied(program, bars, settings, frames, options = {}) {
|
|
83
|
+
return drive(program, bars, settings, options, () => new Delivery(frames));
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* The run both drivers are, and the one place a record is made.
|
|
38
87
|
*
|
|
39
88
|
* A refusal before the first bar comes back as a refusal and not as a record:
|
|
40
89
|
* a program that would not load, a setting that cannot be applied and a window
|
|
@@ -42,19 +91,22 @@ import { checkSettings } from './settings.js';
|
|
|
42
91
|
* be a document asserting figures nothing computed. A failure during a bar is
|
|
43
92
|
* the other way round: the run happened, it stopped, and the record carries
|
|
44
93
|
* both what it did and the diagnostic that stopped it.
|
|
94
|
+
*
|
|
95
|
+
* **The destination is chosen after the program is loaded**, which is why it
|
|
96
|
+
* arrives as a function of the declaration and the schedule: the bar a market
|
|
97
|
+
* order is priced at is the declaration's, and the declaration is resolved at
|
|
98
|
+
* load. The route is wired first and reaches whatever is chosen through the
|
|
99
|
+
* binding below, which is what lets one host serve both halves.
|
|
45
100
|
*/
|
|
46
|
-
|
|
101
|
+
function drive(program, bars, settings, options, choose) {
|
|
47
102
|
const framed = windowFor(bars, settings.range);
|
|
48
103
|
if (!framed.ok)
|
|
49
104
|
return { ok: false, diagnostic: framed.diagnostic };
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
// load. The route is wired first and reaches it through this binding, which
|
|
53
|
-
// is what lets one host serve both halves.
|
|
54
|
-
let venue;
|
|
105
|
+
let sending;
|
|
106
|
+
const instrument = instrumentFor(settings.contract, options.instrument ?? {});
|
|
55
107
|
const loaded = load(program, {
|
|
56
108
|
settings: settings.inputs,
|
|
57
|
-
host: hostFor(settings, (effect, bar) =>
|
|
109
|
+
host: hostFor(instrument, settings.now, (effect, bar) => sending?.route(effect, bar), options.requestBars),
|
|
58
110
|
});
|
|
59
111
|
if (!loaded.ok)
|
|
60
112
|
return { ok: false, diagnostic: loaded.diagnostic };
|
|
@@ -64,156 +116,40 @@ export function backtest(program, bars, settings, options = {}) {
|
|
|
64
116
|
if (problem !== null)
|
|
65
117
|
return { ok: false, diagnostic: problem };
|
|
66
118
|
const schedule = scheduleFor(settings, declared);
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
slippageTicks: schedule.slippageTicks,
|
|
72
|
-
fillOn: declared.fillOn,
|
|
73
|
-
qtyType: declared.qtyType,
|
|
74
|
-
});
|
|
75
|
-
const run = walk(engine, venue, bars, framed.covered);
|
|
76
|
-
const ordinals = ordinalsOf(venue.intents);
|
|
119
|
+
const destination = choose(declared, schedule);
|
|
120
|
+
sending = destination;
|
|
121
|
+
const run = walk(engine, destination, bars, framed.covered, options);
|
|
122
|
+
const ordinals = ordinalsOf(destination.intents);
|
|
77
123
|
const marks = marksFor(bars, framed.covered);
|
|
78
124
|
return {
|
|
79
125
|
ok: true,
|
|
126
|
+
...(options.rows === true ? { rows: run.rows } : {}),
|
|
127
|
+
...(options.log === true ? { log: run.log } : {}),
|
|
128
|
+
...(options.surface === true ? { surface: { drawings: engine.drawings(), tables: engine.tables() } } : {}),
|
|
80
129
|
record: recordOf({
|
|
81
130
|
program: engine.program,
|
|
131
|
+
...(options.sourceText === undefined ? {} : { sourceText: options.sourceText }),
|
|
82
132
|
settings,
|
|
133
|
+
instrument,
|
|
83
134
|
bars,
|
|
84
135
|
form: options.form ?? 'inline',
|
|
85
|
-
|
|
136
|
+
// The row where a case supplied one, because that row is the input and a
|
|
137
|
+
// record of a run over it says what it was given rather than what it
|
|
138
|
+
// would have written down had it decided the frame itself.
|
|
139
|
+
frames: run.frames.map((one) => one.row ?? framedAs(one.frame, one.afterBar, ordinals)),
|
|
86
140
|
fills: run.fills,
|
|
87
|
-
orders: ordersOf(engine.orders(),
|
|
141
|
+
orders: ordersOf(engine.orders(), destination.intents, ordinals),
|
|
88
142
|
diagnostics: run.diagnostics,
|
|
89
143
|
report: reportOf(run.fills, marks, schedule, settings.contract, declared.capital),
|
|
90
144
|
}),
|
|
91
145
|
};
|
|
92
146
|
}
|
|
93
|
-
/**
|
|
94
|
-
|
|
95
|
-
*
|
|
96
|
-
* The one ordering rule: deliver, then append, then collect what the append
|
|
97
|
-
* reported, then ask the venue what this bar did. A driver that asked the venue
|
|
98
|
-
* before appending would price a fill against a bar the strategy had not seen.
|
|
99
|
-
*/
|
|
100
|
-
function walk(engine, venue, bars, covered) {
|
|
101
|
-
const fills = [];
|
|
102
|
-
const frames = [];
|
|
103
|
-
const diagnostics = [];
|
|
104
|
-
const intents = new Map();
|
|
105
|
-
const refs = new Map();
|
|
106
|
-
const sizes = new Map();
|
|
107
|
-
let pending = [];
|
|
108
|
-
let seq = 0;
|
|
109
|
-
for (let index = 0; index < covered.total; index += 1) {
|
|
110
|
-
const bar = bars[index];
|
|
111
|
-
if (bar === undefined)
|
|
112
|
-
continue;
|
|
113
|
-
for (const one of pending) {
|
|
114
|
-
const ref = one.frame.orderRef;
|
|
115
|
-
if (typeof ref === 'string')
|
|
116
|
-
refs.set(one.frame.intentId, ref);
|
|
117
|
-
engine.deliver(one.frame);
|
|
118
|
-
frames.push(one);
|
|
119
|
-
}
|
|
120
|
-
pending = [];
|
|
121
|
-
const result = engine.append({ time: bar.time, open: bar.open, high: bar.high, low: bar.low, close: bar.close,
|
|
122
|
-
volume: bar.volume, oi: bar.oi }, { isConfirmed: true, isRealtime: false }, covered.total);
|
|
123
|
-
for (const intent of intentsIn(result))
|
|
124
|
-
intents.set(intent.intentId, intent);
|
|
125
|
-
seq = settle(result, index, bar, { intents, refs, sizes }, fills, seq);
|
|
126
|
-
if (result.diagnostic !== undefined) {
|
|
127
|
-
diagnostics.push(diagnosticIn(result.diagnostic, index));
|
|
128
|
-
break;
|
|
129
|
-
}
|
|
130
|
-
pending = venue.framesFor(index).map((frame) => ({ frame, afterBar: index }));
|
|
131
|
-
}
|
|
132
|
-
return { fills, frames, diagnostics };
|
|
133
|
-
}
|
|
134
|
-
/**
|
|
135
|
-
* The fills one bar's fold settled.
|
|
136
|
-
*
|
|
137
|
-
* **The position sizes either side of step 6 are kept here and not read back
|
|
138
|
-
* from the engine**, because the engine reports a leg's net and a fill settles
|
|
139
|
-
* against one position reference: the two are different numbers whenever a leg
|
|
140
|
-
* holds more than one position, which is every flip. They are folded in the
|
|
141
|
-
* order the frames were folded in, from the same deltas, so they are the same
|
|
142
|
-
* arithmetic the position book did rather than a second reading of its result.
|
|
143
|
-
* When `FrameOutcome` carries them, these two lines come from the engine and
|
|
144
|
-
* this fold keeps only the sequence number.
|
|
145
|
-
*
|
|
146
|
-
* A refused frame settles nothing and is not a fill. Today the fold reports the
|
|
147
|
-
* refusal as a word rather than a code, so nothing here can write it into the
|
|
148
|
-
* record as a diagnostic; that is OS7018 and OS7019, and both are deferred.
|
|
149
|
-
*/
|
|
150
|
-
function settle(result, index, bar, books, fills, from) {
|
|
151
|
-
let seq = from;
|
|
152
|
-
for (const outcome of result.frames) {
|
|
153
|
-
if (outcome.refused !== undefined)
|
|
154
|
-
continue;
|
|
155
|
-
if (outcome.delta <= 0 || outcome.price === null)
|
|
156
|
-
continue;
|
|
157
|
-
const intent = books.intents.get(outcome.intentId);
|
|
158
|
-
if (intent === undefined || intent.side === null)
|
|
159
|
-
continue;
|
|
160
|
-
const before = books.sizes.get(intent.positionRef) ?? 0;
|
|
161
|
-
const after = before + (intent.side === 'sell' ? -outcome.delta : outcome.delta);
|
|
162
|
-
books.sizes.set(intent.positionRef, after);
|
|
163
|
-
seq += 1;
|
|
164
|
-
fills.push({
|
|
165
|
-
seq,
|
|
166
|
-
intentId: outcome.intentId,
|
|
167
|
-
orderRef: books.refs.get(outcome.intentId) ?? '',
|
|
168
|
-
tag: intent.tag,
|
|
169
|
-
positionRef: intent.positionRef,
|
|
170
|
-
side: intent.side,
|
|
171
|
-
units: outcome.delta,
|
|
172
|
-
price: outcome.price,
|
|
173
|
-
// The bar the fold happened at, which is the bar the position exists
|
|
174
|
-
// from. Where the fill itself traded is the bar before it or this bar's
|
|
175
|
-
// own open, and neither is a bar the strategy could have acted on it in.
|
|
176
|
-
barIndex: index,
|
|
177
|
-
barTime: bar.time,
|
|
178
|
-
refSizeBefore: before,
|
|
179
|
-
refSizeAfter: after,
|
|
180
|
-
});
|
|
181
|
-
}
|
|
182
|
-
return seq;
|
|
183
|
-
}
|
|
184
|
-
/** Every intent one bar handed over, in the order the bar applied them. */
|
|
185
|
-
function intentsIn(result) {
|
|
186
|
-
const out = [];
|
|
187
|
-
for (const effect of result.effects)
|
|
188
|
-
for (const intent of effect.intents)
|
|
189
|
-
out.push(intent);
|
|
190
|
-
return out;
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* The ordinal of every intent, which is how a case names one.
|
|
194
|
-
*
|
|
195
|
-
* One, two, three in the order the run placed them, because no engine can know
|
|
196
|
-
* the id another minted and a case that named one would only ever be readable
|
|
197
|
-
* by the engine that wrote it.
|
|
198
|
-
*/
|
|
199
|
-
function ordinalsOf(intents) {
|
|
200
|
-
const out = new Map();
|
|
201
|
-
for (const intent of intents) {
|
|
202
|
-
if (!out.has(intent.intentId))
|
|
203
|
-
out.set(intent.intentId, out.size + 1);
|
|
204
|
-
}
|
|
205
|
-
return out;
|
|
206
|
-
}
|
|
207
|
-
/** One delivered frame, in the columns a case file prints. */
|
|
208
|
-
function framedAs(frame, afterBar, ordinals) {
|
|
147
|
+
/** The simulated destination, as a destination the loop below can drive. */
|
|
148
|
+
function simulated(venue) {
|
|
209
149
|
return {
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
filledQty: frame.filledQty,
|
|
214
|
-
avgFillPrice: frame.avgFillPrice ?? null,
|
|
215
|
-
orderRef: frame.orderRef ?? null,
|
|
216
|
-
text: frame.text ?? null,
|
|
150
|
+
route: (effect, barIndex) => venue.route(effect, barIndex),
|
|
151
|
+
answers: (barIndex) => venue.framesFor(barIndex).map((frame) => ({ frame, afterBar: barIndex, row: null })),
|
|
152
|
+
intents: venue.intents,
|
|
217
153
|
};
|
|
218
154
|
}
|
|
219
155
|
/** The ledger at the end, copied out of the engine's own array. */
|
|
@@ -237,26 +173,46 @@ function scheduleFor(settings, declared) {
|
|
|
237
173
|
return scheduleFromDeclaration(declared.commission, declared.commissionType, declared.slippage, settings.contract.currency, settings.contract.digits);
|
|
238
174
|
}
|
|
239
175
|
/**
|
|
240
|
-
* The
|
|
176
|
+
* The instrument record of `host-interface.md` 4.1 the engine is handed, and
|
|
177
|
+
* the record carries verbatim.
|
|
241
178
|
*
|
|
242
|
-
*
|
|
243
|
-
* so
|
|
244
|
-
*
|
|
245
|
-
*
|
|
179
|
+
* Composed once, here, from the contract's six facts and the six stated beside
|
|
180
|
+
* it, so the engine and the record read one document and there is no second
|
|
181
|
+
* composition for the two to disagree by. A fact nobody stated is left out
|
|
182
|
+
* rather than written as undefined: the record travels as JSON, which drops an
|
|
183
|
+
* undefined member, and a document that changes shape in transit is not the
|
|
184
|
+
* document the engine read.
|
|
246
185
|
*/
|
|
247
|
-
function
|
|
248
|
-
|
|
249
|
-
...(
|
|
250
|
-
...(
|
|
251
|
-
...(
|
|
252
|
-
...(
|
|
253
|
-
|
|
254
|
-
|
|
186
|
+
function instrumentFor(contract, facts) {
|
|
187
|
+
return {
|
|
188
|
+
...(contract.symbol === null ? {} : { symbol: contract.symbol }),
|
|
189
|
+
...(contract.exchange === null ? {} : { exchange: contract.exchange }),
|
|
190
|
+
...(facts.interval === undefined ? {} : { interval: facts.interval }),
|
|
191
|
+
...(facts.timezone === undefined ? {} : { timezone: facts.timezone }),
|
|
192
|
+
...(contract.tickSize === null ? {} : { tickSize: contract.tickSize }),
|
|
193
|
+
...(contract.lotSize === null ? {} : { lotSize: contract.lotSize }),
|
|
194
|
+
pointValue: contract.pointValue,
|
|
195
|
+
currency: contract.currency,
|
|
196
|
+
...(facts.instrumentType === undefined ? {} : { instrumentType: facts.instrumentType }),
|
|
197
|
+
...(facts.hasVolume === undefined ? {} : { hasVolume: facts.hasVolume }),
|
|
198
|
+
...(facts.hasOpenInterest === undefined ? {} : { hasOpenInterest: facts.hasOpenInterest }),
|
|
199
|
+
...(facts.session === undefined ? {} : { session: facts.session }),
|
|
255
200
|
};
|
|
201
|
+
}
|
|
202
|
+
/**
|
|
203
|
+
* The host a backtest is: an instrument record, a clock and a destination.
|
|
204
|
+
*
|
|
205
|
+
* Duty 3 is served only when the caller supplied bars for it. A backtest with
|
|
206
|
+
* none holds the chart's own bars and nothing else, so a program that reads
|
|
207
|
+
* another instrument declares a capability this host does not have and is
|
|
208
|
+
* refused at load, by name, rather than drawing a line with nothing in it.
|
|
209
|
+
*/
|
|
210
|
+
function hostFor(instrument, now, route, requestBars) {
|
|
256
211
|
return {
|
|
257
212
|
instrument,
|
|
258
|
-
...(
|
|
213
|
+
...(now === null ? {} : { now }),
|
|
259
214
|
route,
|
|
215
|
+
...(requestBars === undefined ? {} : { requestBars }),
|
|
260
216
|
};
|
|
261
217
|
}
|
|
262
218
|
//# sourceMappingURL=drive.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"drive.js","sourceRoot":"","sources":["../../../src/core/backtest/drive.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"drive.js","sourceRoot":"","sources":["../../../src/core/backtest/drive.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAkCG;AACH,OAAO,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,wBAAwB,CAAC;AAI3E,OAAO,EAAE,IAAI,EAAE,MAAM,oBAAoB,CAAC;AAY1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,QAAQ,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAE9D,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEhD,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC9C,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAA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,EAAE,CAAC;QACvF,GAAG,CAAC,KAAK,CAAC,SAAS,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC;QACxE,GAAG,CAAC,KAAK,CAAC,eAAe,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,eAAe,EAAE,KAAK,CAAC,eAAe,EAAE,CAAC;QAC1F,GAAG,CAAC,KAAK,CAAC,OAAO,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,CAAC;KACnE,CAAC;AACJ,CAAC;AAED;;;;;;;GAOG;AACH,SAAS,OAAO,CACd,UAAsB,EACtB,GAAkB,EAClB,KAAkD,EAClD,WAAwC;IAExC,OAAO;QACL,UAAU;QACV,GAAG,CAAC,GAAG,KAAK,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,GAAG,EAAE,CAAC;QAChC,KAAK;QACL,GAAG,CAAC,WAAW,KAAK,SAAS,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,WAAW,EAAE,CAAC;KACtD,CAAC;AACJ,CAAC"}
|
|
@@ -14,18 +14,30 @@
|
|
|
14
14
|
* worsened by a tick and a fill is charged. The engine never adjusts a price and
|
|
15
15
|
* this module never folds one.
|
|
16
16
|
*
|
|
17
|
-
* `backtest` drives one
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
17
|
+
* `backtest` drives one against a simulated destination and `backtestSupplied`
|
|
18
|
+
* drives one over frames somebody else supplied, which is what `conformance.md`
|
|
19
|
+
* section 3 asks of an engine running a case. `replay` folds a stored one's
|
|
20
|
+
* money again from its own fills, and `rerun` executes a stored one again and
|
|
21
|
+
* is held to producing the same bytes. `recordToJson` and `recordFromJson` are
|
|
22
|
+
* the document itself. `compareRuns` puts two records beside each other and
|
|
23
|
+
* says whether the gap between them clears the noise. `caseFilesFrom` turns a
|
|
24
|
+
* record into the files of a conformance case, returning text and writing
|
|
25
|
+
* nothing because core does no I/O. It needed three channels the record did not
|
|
26
|
+
* carry. `conformance.md` section 2 requires a case to hold `script.os`, the
|
|
27
|
+
* source text, and a record carried only the source's hash, its line count and
|
|
28
|
+
* its file name: record version 2 carries the text, checked against that hash.
|
|
29
|
+
* The same section says `instrument.json` is the record of `host-interface.md`
|
|
30
|
+
* 4.1, and a record carried the money layer's contract, which holds six of its
|
|
31
|
+
* twelve facts: record version 3 carries the record the engine was handed,
|
|
32
|
+
* whole. And a case is handed frames, which `stdlib.md` 17.7 folds one ledger
|
|
33
|
+
* field from an instant of: a record carried a frame without the instant it
|
|
34
|
+
* arrived at, so a case projected from it asserted a field its own input could
|
|
35
|
+
* not reproduce. Record version 4 carries a frame's time.
|
|
26
36
|
*/
|
|
27
|
-
export { backtest } from './drive.js';
|
|
28
|
-
export type { BacktestResult, DriveOptions } from './drive.js';
|
|
37
|
+
export { backtest, backtestSupplied } from './drive.js';
|
|
38
|
+
export type { BacktestResult, DriveOptions, InstrumentFacts } from './drive.js';
|
|
39
|
+
export type { LogLine } from './walk.js';
|
|
40
|
+
export type { Surface } from './drive.js';
|
|
29
41
|
export { declarationOf } from './declaration.js';
|
|
30
42
|
export type { RunDeclaration } from './declaration.js';
|
|
31
43
|
export { marksFor, windowFor } from './range.js';
|
|
@@ -35,8 +47,10 @@ export type { ReplayResult } from './replay.js';
|
|
|
35
47
|
export { testResting } from './resting.js';
|
|
36
48
|
export type { RestOutcome, RestingOrder } from './resting.js';
|
|
37
49
|
export { Simulator } from './simulate.js';
|
|
38
|
-
export type { SimulatorOptions } from './simulate.js';
|
|
50
|
+
export type { SimulatorOptions, VenueAct, VenueDoes, VenuePolicy } from './simulate.js';
|
|
39
51
|
export { DEFAULT_FILL, EXACT, WHOLE_RANGE, checkSettings, settingsFor } from './settings.js';
|
|
52
|
+
export { caseFilesFrom } from './case.js';
|
|
53
|
+
export type { CaseFiles, CaseIdentity, CaseResult } from './case.js';
|
|
40
54
|
export { RECORD_VERSION, barsHash, recordFromJson, recordOf, recordToJson, runBytes } from './record.js';
|
|
41
55
|
export type { RecordParts } from './record.js';
|
|
42
56
|
export type { BacktestSettings, DateRange, FillPolicy, Tolerance } from './settings.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AACxD,YAAY,EAAE,cAAc,EAAE,YAAY,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAChF,YAAY,EAAE,OAAO,EAAE,MAAM,WAAW,CAAC;AACzC,YAAY,EAAE,OAAO,EAAE,MAAM,YAAY,CAAC;AAC1C,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AACjD,YAAY,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AACvD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AACjD,YAAY,EAAE,YAAY,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAC5C,YAAY,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAChD,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,WAAW,EAAE,YAAY,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAC1C,YAAY,EAAE,gBAAgB,EAAE,QAAQ,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACxF,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAC1C,YAAY,EAAE,SAAS,EAAE,YAAY,EAAE,UAAU,EAAE,MAAM,WAAW,CAAC;AACrE,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AACzG,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AAC/C,YAAY,EAAE,gBAAgB,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AACxF,YAAY,EACV,YAAY,EACZ,WAAW,EACX,kBAAkB,EAClB,aAAa,EACb,aAAa,EACb,SAAS,GACV,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3C,YAAY,EAAE,aAAa,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -14,23 +14,34 @@
|
|
|
14
14
|
* worsened by a tick and a fill is charged. The engine never adjusts a price and
|
|
15
15
|
* this module never folds one.
|
|
16
16
|
*
|
|
17
|
-
* `backtest` drives one
|
|
18
|
-
*
|
|
19
|
-
*
|
|
20
|
-
*
|
|
21
|
-
*
|
|
22
|
-
*
|
|
23
|
-
*
|
|
24
|
-
*
|
|
25
|
-
*
|
|
17
|
+
* `backtest` drives one against a simulated destination and `backtestSupplied`
|
|
18
|
+
* drives one over frames somebody else supplied, which is what `conformance.md`
|
|
19
|
+
* section 3 asks of an engine running a case. `replay` folds a stored one's
|
|
20
|
+
* money again from its own fills, and `rerun` executes a stored one again and
|
|
21
|
+
* is held to producing the same bytes. `recordToJson` and `recordFromJson` are
|
|
22
|
+
* the document itself. `compareRuns` puts two records beside each other and
|
|
23
|
+
* says whether the gap between them clears the noise. `caseFilesFrom` turns a
|
|
24
|
+
* record into the files of a conformance case, returning text and writing
|
|
25
|
+
* nothing because core does no I/O. It needed three channels the record did not
|
|
26
|
+
* carry. `conformance.md` section 2 requires a case to hold `script.os`, the
|
|
27
|
+
* source text, and a record carried only the source's hash, its line count and
|
|
28
|
+
* its file name: record version 2 carries the text, checked against that hash.
|
|
29
|
+
* The same section says `instrument.json` is the record of `host-interface.md`
|
|
30
|
+
* 4.1, and a record carried the money layer's contract, which holds six of its
|
|
31
|
+
* twelve facts: record version 3 carries the record the engine was handed,
|
|
32
|
+
* whole. And a case is handed frames, which `stdlib.md` 17.7 folds one ledger
|
|
33
|
+
* field from an instant of: a record carried a frame without the instant it
|
|
34
|
+
* arrived at, so a case projected from it asserted a field its own input could
|
|
35
|
+
* not reproduce. Record version 4 carries a frame's time.
|
|
26
36
|
*/
|
|
27
|
-
export { backtest } from './drive.js';
|
|
37
|
+
export { backtest, backtestSupplied } from './drive.js';
|
|
28
38
|
export { declarationOf } from './declaration.js';
|
|
29
39
|
export { marksFor, windowFor } from './range.js';
|
|
30
40
|
export { replay, rerun } from './replay.js';
|
|
31
41
|
export { testResting } from './resting.js';
|
|
32
42
|
export { Simulator } from './simulate.js';
|
|
33
43
|
export { DEFAULT_FILL, EXACT, WHOLE_RANGE, checkSettings, settingsFor } from './settings.js';
|
|
44
|
+
export { caseFilesFrom } from './case.js';
|
|
34
45
|
export { RECORD_VERSION, barsHash, recordFromJson, recordOf, recordToJson, runBytes } from './record.js';
|
|
35
46
|
export { compareRuns } from './compare.js';
|
|
36
47
|
//# sourceMappingURL=index.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/core/backtest/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAmCG;AACH,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAC;AAIxD,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjD,OAAO,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,YAAY,CAAC;AAEjD,OAAO,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,aAAa,CAAC;AAE5C,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAE3C,OAAO,EAAE,SAAS,EAAE,MAAM,eAAe,CAAC;AAE1C,OAAO,EAAE,YAAY,EAAE,KAAK,EAAE,WAAW,EAAE,aAAa,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAC7F,OAAO,EAAE,aAAa,EAAE,MAAM,WAAW,CAAC;AAE1C,OAAO,EAAE,cAAc,EAAE,QAAQ,EAAE,cAAc,EAAE,QAAQ,EAAE,YAAY,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAWzG,OAAO,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC"}
|
|
@@ -27,7 +27,7 @@
|
|
|
27
27
|
import type { RecordedFill, Report } from '../accounting/index.js';
|
|
28
28
|
import type { Diagnostic } from '../diagnostics/index.js';
|
|
29
29
|
import type { CompiledProgram, SourceStamp } from '../emit/index.js';
|
|
30
|
-
import type { LedgerRow } from '../engine/index.js';
|
|
30
|
+
import type { Instrument, LedgerRow } from '../engine/index.js';
|
|
31
31
|
import type { BacktestSettings } from './settings.js';
|
|
32
32
|
/** One bar as a record holds it. */
|
|
33
33
|
export interface RecordedBar {
|
|
@@ -68,6 +68,20 @@ export interface RecordedFrame {
|
|
|
68
68
|
readonly avgFillPrice: number | null;
|
|
69
69
|
readonly orderRef: string | null;
|
|
70
70
|
readonly text: string | null;
|
|
71
|
+
/**
|
|
72
|
+
* The destination's own instant for this frame, or null where it stated none.
|
|
73
|
+
*
|
|
74
|
+
* **One field of the ledger is folded from it.** `host-interface.md` 7.2
|
|
75
|
+
* gives a frame a `time` and `stdlib.md` 17.7 moves `updatedAt` to it, so a
|
|
76
|
+
* record that dropped it wrote a ledger no engine reading the case back could
|
|
77
|
+
* fold to: handed frames with no instant, that engine leaves every
|
|
78
|
+
* `updatedAt` at `placedAt`, and the two disagree on exactly the rows whose
|
|
79
|
+
* destination answered later than the bar that placed the order.
|
|
80
|
+
*
|
|
81
|
+
* Absent rather than substituted, because 7.2 lets a destination state none
|
|
82
|
+
* and a row whose frame stated none keeps the instant it had.
|
|
83
|
+
*/
|
|
84
|
+
readonly time: number | null;
|
|
71
85
|
}
|
|
72
86
|
/** A ledger row of `stdlib.md` 17.7, flattened: the `orders` channel of expected.json. */
|
|
73
87
|
export interface RecordedOrder {
|
|
@@ -114,7 +128,43 @@ export interface RunRecord {
|
|
|
114
128
|
readonly programHash: string;
|
|
115
129
|
/** Hash, lines, file: the script revision. */
|
|
116
130
|
readonly source: SourceStamp;
|
|
131
|
+
/**
|
|
132
|
+
* The source text itself, or null on a record written before version 2.
|
|
133
|
+
*
|
|
134
|
+
* **A record is the conformance case, and a case has to hold `script.os`.**
|
|
135
|
+
* `source` above identifies the script and cannot reproduce it: a hash is a
|
|
136
|
+
* fingerprint, so it settles whether two files are the same and yields
|
|
137
|
+
* neither of them. Without the text a stored record could be replayed months
|
|
138
|
+
* later and still not be handed to anybody else to run, which is the whole
|
|
139
|
+
* claim the suite exists to test.
|
|
140
|
+
*
|
|
141
|
+
* It lives here and not on the compiled program on purpose. A program is
|
|
142
|
+
* executable data that no engine needs the source to run, and it is the
|
|
143
|
+
* versioned artefact adopters depend on; putting the text there would send a
|
|
144
|
+
* script everywhere its program travels and widen the format every engine
|
|
145
|
+
* has to read. The record is the thing that wants to be self-contained.
|
|
146
|
+
*/
|
|
147
|
+
readonly sourceText: string | null;
|
|
117
148
|
readonly settings: BacktestSettings;
|
|
149
|
+
/**
|
|
150
|
+
* The instrument record of `host-interface.md` 4.1, as the engine was handed
|
|
151
|
+
* it, or null on a record written before version 3.
|
|
152
|
+
*
|
|
153
|
+
* **A case holds `instrument.json`, and `conformance.md` section 2 says that
|
|
154
|
+
* file is this record.** The contract in `settings` is the money layer's
|
|
155
|
+
* snapshot of the same instrument and holds six of the twelve facts; the
|
|
156
|
+
* ones a script reads and the money never does, the interval, the timezone,
|
|
157
|
+
* the session and the volume flag, were handed to the engine and written
|
|
158
|
+
* down nowhere. A case harvested from such a record either omitted a fact
|
|
159
|
+
* the page requires or stated one the run never had, and either way the
|
|
160
|
+
* second engine ran a different study than the one the expected output
|
|
161
|
+
* came from.
|
|
162
|
+
*
|
|
163
|
+
* It is the whole record and not the six facts beside the contract, because
|
|
164
|
+
* what is recorded is what the engine read at load, verbatim, and a reader
|
|
165
|
+
* should not have to compose it.
|
|
166
|
+
*/
|
|
167
|
+
readonly instrument: Instrument | null;
|
|
118
168
|
readonly bars: BarsInRecord;
|
|
119
169
|
/** What the destination answered, in delivery order. */
|
|
120
170
|
readonly frames: readonly RecordedFrame[];
|
|
@@ -133,11 +183,22 @@ export interface RunRecord {
|
|
|
133
183
|
* file alone. It moves when a channel is added or a meaning changes, never when
|
|
134
184
|
* a figure in a report does.
|
|
135
185
|
*/
|
|
136
|
-
export declare const RECORD_VERSION =
|
|
186
|
+
export declare const RECORD_VERSION = 4;
|
|
137
187
|
/** The parts a run hands over, each already in the shape the record holds. */
|
|
138
188
|
export interface RecordParts {
|
|
139
189
|
readonly program: CompiledProgram;
|
|
190
|
+
/**
|
|
191
|
+
* The script's own text, so the record can become a conformance case.
|
|
192
|
+
*
|
|
193
|
+
* Optional because a caller that has only a compiled program cannot invent
|
|
194
|
+
* it, and a run is still worth recording without it. `caseFilesFrom` is the
|
|
195
|
+
* one thing that then cannot be served, and it says so rather than writing a
|
|
196
|
+
* case with a hole in it.
|
|
197
|
+
*/
|
|
198
|
+
readonly sourceText?: string;
|
|
140
199
|
readonly settings: BacktestSettings;
|
|
200
|
+
/** The instrument record the engine was handed, `host-interface.md` 4.1. */
|
|
201
|
+
readonly instrument: Instrument;
|
|
141
202
|
readonly bars: readonly RecordedBar[];
|
|
142
203
|
/**
|
|
143
204
|
* Whether the bars travel in the record or are pointed at.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;
|
|
1
|
+
{"version":3,"file":"record.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/record.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,EAAE,MAAM,wBAAwB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAE1D,OAAO,KAAK,EAAE,eAAe,EAAE,WAAW,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,KAAK,EAAE,UAAU,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEhE,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC;AAEtD,oCAAoC;AACpC,MAAM,WAAW,WAAW;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAA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