openalgo-script 0.5.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 +121 -0
- package/README.md +53 -22
- package/dist/adapters/charts/run.d.ts.map +1 -1
- package/dist/adapters/charts/run.js +6 -0
- 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/core/backtest/drive.d.ts +36 -1
- package/dist/core/backtest/drive.d.ts.map +1 -1
- package/dist/core/backtest/drive.js +13 -107
- package/dist/core/backtest/drive.js.map +1 -1
- package/dist/core/backtest/index.d.ts +2 -0
- package/dist/core/backtest/index.d.ts.map +1 -1
- package/dist/core/backtest/index.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 +178 -1
- package/dist/core/catalogue/catalogue.generated.d.ts.map +1 -1
- package/dist/core/catalogue/catalogue.generated.js +18 -1
- 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-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 +10 -10
- 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/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 +1 -0
- package/dist/core/engine/index.d.ts.map +1 -1
- package/dist/core/engine/index.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/index.d.ts +8 -0
- package/dist/core/engine/library/index.d.ts.map +1 -1
- package/dist/core/engine/library/index.js +10 -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/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/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 +12 -0
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +11 -0
- 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/version/version.generated.d.ts +1 -1
- package/dist/core/version/version.generated.js +1 -1
- package/package.json +5 -2
- package/spec/errors.json +380 -20
- package/src/adapters/charts/run.ts +6 -0
- package/src/adapters/charts/tables.ts +6 -19
- package/src/adapters/charts/undrawable.ts +51 -0
- package/src/core/backtest/drive.ts +66 -154
- package/src/core/backtest/index.ts +2 -0
- package/src/core/backtest/walk.ts +182 -0
- package/src/core/catalogue/catalogue.generated.ts +18 -1
- 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-output.ts +1 -0
- package/src/core/check/library-prose.generated.ts +10 -10
- package/src/core/check/library.ts +8 -0
- package/src/core/check/surface.ts +16 -0
- 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 +1 -0
- package/src/core/engine/library/binding.ts +2 -0
- package/src/core/engine/library/index.ts +11 -0
- package/src/core/engine/library/objects.ts +1 -6
- 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/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 +13 -0
- package/src/core/stdlib/calendar/civil.ts +5 -2
- package/src/core/version/version.generated.ts +1 -1
|
@@ -38,9 +38,10 @@ import { load } from '../engine/index.js';
|
|
|
38
38
|
import { declarationOf } from './declaration.js';
|
|
39
39
|
import { Delivery, framedAs, ordinalsOf } from './deliver.js';
|
|
40
40
|
import { marksFor, windowFor } from './range.js';
|
|
41
|
-
import {
|
|
41
|
+
import { orderIn, recordOf } from './record.js';
|
|
42
42
|
import { Simulator } from './simulate.js';
|
|
43
43
|
import { checkSettings } from './settings.js';
|
|
44
|
+
import { walk } from './walk.js';
|
|
44
45
|
/**
|
|
45
46
|
* One run against a simulated destination, from a compiled program to a record.
|
|
46
47
|
*
|
|
@@ -105,7 +106,7 @@ function drive(program, bars, settings, options, choose) {
|
|
|
105
106
|
const instrument = instrumentFor(settings.contract, options.instrument ?? {});
|
|
106
107
|
const loaded = load(program, {
|
|
107
108
|
settings: settings.inputs,
|
|
108
|
-
host: hostFor(instrument, settings.now, (effect, bar) => sending?.route(effect, bar)),
|
|
109
|
+
host: hostFor(instrument, settings.now, (effect, bar) => sending?.route(effect, bar), options.requestBars),
|
|
109
110
|
});
|
|
110
111
|
if (!loaded.ok)
|
|
111
112
|
return { ok: false, diagnostic: loaded.diagnostic };
|
|
@@ -117,11 +118,14 @@ function drive(program, bars, settings, options, choose) {
|
|
|
117
118
|
const schedule = scheduleFor(settings, declared);
|
|
118
119
|
const destination = choose(declared, schedule);
|
|
119
120
|
sending = destination;
|
|
120
|
-
const run = walk(engine, destination, bars, framed.covered);
|
|
121
|
+
const run = walk(engine, destination, bars, framed.covered, options);
|
|
121
122
|
const ordinals = ordinalsOf(destination.intents);
|
|
122
123
|
const marks = marksFor(bars, framed.covered);
|
|
123
124
|
return {
|
|
124
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() } } : {}),
|
|
125
129
|
record: recordOf({
|
|
126
130
|
program: engine.program,
|
|
127
131
|
...(options.sourceText === undefined ? {} : { sourceText: options.sourceText }),
|
|
@@ -148,105 +152,6 @@ function simulated(venue) {
|
|
|
148
152
|
intents: venue.intents,
|
|
149
153
|
};
|
|
150
154
|
}
|
|
151
|
-
/**
|
|
152
|
-
* The bars, in order, with the venue answering between them.
|
|
153
|
-
*
|
|
154
|
-
* The one ordering rule: deliver, then append, then collect what the append
|
|
155
|
-
* reported, then ask the venue what this bar did. A driver that asked the venue
|
|
156
|
-
* before appending would price a fill against a bar the strategy had not seen.
|
|
157
|
-
*/
|
|
158
|
-
function walk(engine, destination, bars, covered) {
|
|
159
|
-
const fills = [];
|
|
160
|
-
const frames = [];
|
|
161
|
-
const diagnostics = [];
|
|
162
|
-
const intents = new Map();
|
|
163
|
-
const refs = new Map();
|
|
164
|
-
const sizes = new Map();
|
|
165
|
-
let pending = [];
|
|
166
|
-
let seq = 0;
|
|
167
|
-
for (let index = 0; index < covered.total; index += 1) {
|
|
168
|
-
const bar = bars[index];
|
|
169
|
-
if (bar === undefined)
|
|
170
|
-
continue;
|
|
171
|
-
for (const one of pending) {
|
|
172
|
-
const ref = one.frame.orderRef;
|
|
173
|
-
if (typeof ref === 'string')
|
|
174
|
-
refs.set(one.frame.intentId, ref);
|
|
175
|
-
engine.deliver(one.frame);
|
|
176
|
-
frames.push(one);
|
|
177
|
-
}
|
|
178
|
-
pending = [];
|
|
179
|
-
const result = engine.append({ time: bar.time, open: bar.open, high: bar.high, low: bar.low, close: bar.close,
|
|
180
|
-
volume: bar.volume, oi: bar.oi }, { isConfirmed: true, isRealtime: false }, covered.total);
|
|
181
|
-
for (const intent of intentsIn(result))
|
|
182
|
-
intents.set(intent.intentId, intent);
|
|
183
|
-
seq = settle(result, index, bar, { intents, refs, sizes }, fills, seq);
|
|
184
|
-
if (result.diagnostic !== undefined) {
|
|
185
|
-
diagnostics.push(diagnosticIn(result.diagnostic, index));
|
|
186
|
-
break;
|
|
187
|
-
}
|
|
188
|
-
pending = destination.answers(index);
|
|
189
|
-
}
|
|
190
|
-
return { fills, frames, diagnostics };
|
|
191
|
-
}
|
|
192
|
-
/**
|
|
193
|
-
* The fills one bar's fold settled.
|
|
194
|
-
*
|
|
195
|
-
* **The position sizes either side of step 6 are kept here and not read back
|
|
196
|
-
* from the engine**, because the engine reports a leg's net and a fill settles
|
|
197
|
-
* against one position reference: the two are different numbers whenever a leg
|
|
198
|
-
* holds more than one position, which is every flip. They are folded in the
|
|
199
|
-
* order the frames were folded in, from the same deltas, so they are the same
|
|
200
|
-
* arithmetic the position book did rather than a second reading of its result.
|
|
201
|
-
* When `FrameOutcome` carries them, these two lines come from the engine and
|
|
202
|
-
* this fold keeps only the sequence number.
|
|
203
|
-
*
|
|
204
|
-
* A refused frame settles nothing and is not a fill. Today the fold reports the
|
|
205
|
-
* refusal as a word rather than a code, so nothing here can write it into the
|
|
206
|
-
* record as a diagnostic; that is OS7018 and OS7019, and both are deferred.
|
|
207
|
-
*/
|
|
208
|
-
function settle(result, index, bar, books, fills, from) {
|
|
209
|
-
let seq = from;
|
|
210
|
-
for (const outcome of result.frames) {
|
|
211
|
-
if (outcome.refused !== undefined)
|
|
212
|
-
continue;
|
|
213
|
-
if (outcome.delta <= 0 || outcome.price === null)
|
|
214
|
-
continue;
|
|
215
|
-
const intent = books.intents.get(outcome.intentId);
|
|
216
|
-
if (intent === undefined || intent.side === null)
|
|
217
|
-
continue;
|
|
218
|
-
const before = books.sizes.get(intent.positionRef) ?? 0;
|
|
219
|
-
const after = before + (intent.side === 'sell' ? -outcome.delta : outcome.delta);
|
|
220
|
-
books.sizes.set(intent.positionRef, after);
|
|
221
|
-
seq += 1;
|
|
222
|
-
fills.push({
|
|
223
|
-
seq,
|
|
224
|
-
intentId: outcome.intentId,
|
|
225
|
-
orderRef: books.refs.get(outcome.intentId) ?? '',
|
|
226
|
-
tag: intent.tag,
|
|
227
|
-
positionRef: intent.positionRef,
|
|
228
|
-
side: intent.side,
|
|
229
|
-
units: outcome.delta,
|
|
230
|
-
price: outcome.price,
|
|
231
|
-
// The bar the fold happened at, which is the bar the position exists
|
|
232
|
-
// from. Where the fill itself traded is the bar before it or this bar's
|
|
233
|
-
// own open, and neither is a bar the strategy could have acted on it in.
|
|
234
|
-
barIndex: index,
|
|
235
|
-
barTime: bar.time,
|
|
236
|
-
refSizeBefore: before,
|
|
237
|
-
refSizeAfter: after,
|
|
238
|
-
});
|
|
239
|
-
}
|
|
240
|
-
return seq;
|
|
241
|
-
}
|
|
242
|
-
/** Every intent one bar handed over, in the order the bar applied them. */
|
|
243
|
-
function intentsIn(result) {
|
|
244
|
-
const out = [];
|
|
245
|
-
for (const effect of result.effects)
|
|
246
|
-
for (const intent of effect.intents)
|
|
247
|
-
out.push(intent);
|
|
248
|
-
return out;
|
|
249
|
-
}
|
|
250
155
|
/** The ledger at the end, copied out of the engine's own array. */
|
|
251
156
|
function ordersOf(rows, intents, ordinals) {
|
|
252
157
|
return rows.map((row) => {
|
|
@@ -297,16 +202,17 @@ function instrumentFor(contract, facts) {
|
|
|
297
202
|
/**
|
|
298
203
|
* The host a backtest is: an instrument record, a clock and a destination.
|
|
299
204
|
*
|
|
300
|
-
* Duty 3 is
|
|
301
|
-
*
|
|
302
|
-
*
|
|
303
|
-
* with nothing in it.
|
|
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.
|
|
304
209
|
*/
|
|
305
|
-
function hostFor(instrument, now, route) {
|
|
210
|
+
function hostFor(instrument, now, route, requestBars) {
|
|
306
211
|
return {
|
|
307
212
|
instrument,
|
|
308
213
|
...(now === null ? {} : { now }),
|
|
309
214
|
route,
|
|
215
|
+
...(requestBars === undefined ? {} : { requestBars }),
|
|
310
216
|
};
|
|
311
217
|
}
|
|
312
218
|
//# sourceMappingURL=drive.js.map
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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,EA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est, backtestSupplied } from './drive.js';
|
|
38
38
|
export type { BacktestResult, DriveOptions, InstrumentFacts } from './drive.js';
|
|
39
|
+
export type { LogLine } from './walk.js';
|
|
40
|
+
export type { Surface } from './drive.js';
|
|
39
41
|
export { declarationOf } from './declaration.js';
|
|
40
42
|
export type { RunDeclaration } from './declaration.js';
|
|
41
43
|
export { marksFor, windowFor } from './range.js';
|
|
@@ -1 +1 @@
|
|
|
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,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,aAA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AE,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"}
|
|
@@ -1 +1 @@
|
|
|
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;
|
|
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"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* One walk of a backtest's bars, with the venue answering between them.
|
|
3
|
+
*
|
|
4
|
+
* Split from `drive.ts`, which sets a run up and writes its record, because the
|
|
5
|
+
* walk is the one part of a backtest that runs once per bar and it is read on its
|
|
6
|
+
* own: the order in which a frame is delivered, a bar appended and its fills
|
|
7
|
+
* folded is the whole of what makes a backtest reproducible.
|
|
8
|
+
*/
|
|
9
|
+
import type { RecordedFill } from '../accounting/index.js';
|
|
10
|
+
import type { Engine, Value } from '../engine/index.js';
|
|
11
|
+
import type { Delivered, Destination } from './deliver.js';
|
|
12
|
+
import type { ReportWindow } from './range.js';
|
|
13
|
+
import type { RecordedBar, RecordedDiagnostic } from './record.js';
|
|
14
|
+
/** One line of the script's log, `conformance.md` section 4. */
|
|
15
|
+
export interface LogLine {
|
|
16
|
+
readonly barIndex: number;
|
|
17
|
+
readonly time: number | null;
|
|
18
|
+
readonly value: Value;
|
|
19
|
+
}
|
|
20
|
+
/** What one walk of the bars produced. */
|
|
21
|
+
export interface Walked {
|
|
22
|
+
readonly fills: readonly RecordedFill[];
|
|
23
|
+
readonly frames: readonly Delivered[];
|
|
24
|
+
readonly diagnostics: readonly RecordedDiagnostic[];
|
|
25
|
+
readonly rows: readonly (readonly Value[])[];
|
|
26
|
+
readonly log: readonly LogLine[];
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* The bars, in order, with the venue answering between them.
|
|
30
|
+
*
|
|
31
|
+
* The one ordering rule: deliver, then append, then collect what the append
|
|
32
|
+
* reported, then ask the venue what this bar did. A driver that asked the venue
|
|
33
|
+
* before appending would price a fill against a bar the strategy had not seen.
|
|
34
|
+
*/
|
|
35
|
+
export declare function walk(engine: Engine, destination: Destination, bars: readonly RecordedBar[], covered: ReportWindow, keep: {
|
|
36
|
+
readonly rows?: boolean;
|
|
37
|
+
readonly log?: boolean;
|
|
38
|
+
}): Walked;
|
|
39
|
+
//# sourceMappingURL=walk.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.d.ts","sourceRoot":"","sources":["../../../src/core/backtest/walk.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AACH,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,wBAAwB,CAAC;AAC3D,OAAO,KAAK,EAAa,MAAM,EAAwB,KAAK,EAAE,MAAM,oBAAoB,CAAC;AACzF,OAAO,KAAK,EAAE,SAAS,EAAE,WAAW,EAAE,MAAM,cAAc,CAAC;AAC3D,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,YAAY,CAAC;AAE/C,OAAO,KAAK,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AAEnE,gEAAgE;AAChE,MAAM,WAAW,OAAO;IACtB,QAAQ,CAAC,QAAQ,EAAE,MAAM,CAAC;IAC1B,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IAC7B,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;CACvB;AAED,0CAA0C;AAC1C,MAAM,WAAW,MAAM;IACrB,QAAQ,CAAC,KAAK,EAAE,SAAS,YAAY,EAAE,CAAC;IACxC,QAAQ,CAAC,MAAM,EAAE,SAAS,SAAS,EAAE,CAAC;IACtC,QAAQ,CAAC,WAAW,EAAE,SAAS,kBAAkB,EAAE,CAAC;IACpD,QAAQ,CAAC,IAAI,EAAE,SAAS,CAAC,SAAS,KAAK,EAAE,CAAC,EAAE,CAAC;IAC7C,QAAQ,CAAC,GAAG,EAAE,SAAS,OAAO,EAAE,CAAC;CAClC;AAED;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,MAAM,EAAE,MAAM,EACd,WAAW,EAAE,WAAW,EACxB,IAAI,EAAE,SAAS,WAAW,EAAE,EAC5B,OAAO,EAAE,YAAY,EACrB,IAAI,EAAE;IAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,OAAO,CAAC;IAAC,QAAQ,CAAC,GAAG,CAAC,EAAE,OAAO,CAAA;CAAE,GACxD,MAAM,CA0DR"}
|
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
import { diagnosticIn } from './record.js';
|
|
2
|
+
/**
|
|
3
|
+
* The bars, in order, with the venue answering between them.
|
|
4
|
+
*
|
|
5
|
+
* The one ordering rule: deliver, then append, then collect what the append
|
|
6
|
+
* reported, then ask the venue what this bar did. A driver that asked the venue
|
|
7
|
+
* before appending would price a fill against a bar the strategy had not seen.
|
|
8
|
+
*/
|
|
9
|
+
export function walk(engine, destination, bars, covered, keep) {
|
|
10
|
+
const fills = [];
|
|
11
|
+
const rows = [];
|
|
12
|
+
const log = [];
|
|
13
|
+
const frames = [];
|
|
14
|
+
const diagnostics = [];
|
|
15
|
+
const intents = new Map();
|
|
16
|
+
const refs = new Map();
|
|
17
|
+
const sizes = new Map();
|
|
18
|
+
let pending = [];
|
|
19
|
+
let seq = 0;
|
|
20
|
+
// The bars are a settled history, so the fold is handed all of them before
|
|
21
|
+
// bar 0 as `Engine.run` hands them. A `"lookahead"` read is the one reading
|
|
22
|
+
// that can tell (`compiled-program.md` 2.16.2): over history it reads the
|
|
23
|
+
// bucket a bar is inside in full, and a driver that fed the fold one bar at
|
|
24
|
+
// a time would answer the bucket so far, which is the live chart's reading.
|
|
25
|
+
const handed = bars.slice(0, covered.total).map(hostBarOf);
|
|
26
|
+
engine.history(handed);
|
|
27
|
+
for (let index = 0; index < covered.total; index += 1) {
|
|
28
|
+
const bar = bars[index];
|
|
29
|
+
const held = handed[index];
|
|
30
|
+
if (bar === undefined || held === undefined)
|
|
31
|
+
continue;
|
|
32
|
+
for (const one of pending) {
|
|
33
|
+
const ref = one.frame.orderRef;
|
|
34
|
+
if (typeof ref === 'string')
|
|
35
|
+
refs.set(one.frame.intentId, ref);
|
|
36
|
+
engine.deliver(one.frame);
|
|
37
|
+
frames.push(one);
|
|
38
|
+
}
|
|
39
|
+
pending = [];
|
|
40
|
+
const result = engine.append(held, { isConfirmed: true, isRealtime: false }, covered.total);
|
|
41
|
+
for (const intent of intentsIn(result))
|
|
42
|
+
intents.set(intent.intentId, intent);
|
|
43
|
+
seq = settle(result, index, bar, { intents, refs, sizes }, fills, seq);
|
|
44
|
+
if (result.diagnostic !== undefined) {
|
|
45
|
+
diagnostics.push(diagnosticIn(result.diagnostic, index));
|
|
46
|
+
break;
|
|
47
|
+
}
|
|
48
|
+
if (keep.rows === true)
|
|
49
|
+
rows.push([...result.columns]);
|
|
50
|
+
if (keep.log === true) {
|
|
51
|
+
for (const one of result.effects) {
|
|
52
|
+
if (one.effect === 'log')
|
|
53
|
+
log.push({ barIndex: index, time: bar.time, value: one.args[0] ?? null });
|
|
54
|
+
}
|
|
55
|
+
}
|
|
56
|
+
pending = destination.answers(index);
|
|
57
|
+
}
|
|
58
|
+
return { fills, frames, diagnostics, rows, log };
|
|
59
|
+
}
|
|
60
|
+
/** A recorded bar as the engine is handed one. */
|
|
61
|
+
function hostBarOf(bar) {
|
|
62
|
+
return {
|
|
63
|
+
time: bar.time, open: bar.open, high: bar.high, low: bar.low, close: bar.close,
|
|
64
|
+
volume: bar.volume, oi: bar.oi,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
/**
|
|
68
|
+
* The fills one bar's fold settled.
|
|
69
|
+
*
|
|
70
|
+
* **The position sizes either side of step 6 are kept here and not read back
|
|
71
|
+
* from the engine**, because the engine reports a leg's net and a fill settles
|
|
72
|
+
* against one position reference: the two are different numbers whenever a leg
|
|
73
|
+
* holds more than one position, which is every flip. They are folded in the
|
|
74
|
+
* order the frames were folded in, from the same deltas, so they are the same
|
|
75
|
+
* arithmetic the position book did rather than a second reading of its result.
|
|
76
|
+
* When `FrameOutcome` carries them, these two lines come from the engine and
|
|
77
|
+
* this fold keeps only the sequence number.
|
|
78
|
+
*
|
|
79
|
+
* A refused frame settles nothing and is not a fill. Today the fold reports the
|
|
80
|
+
* refusal as a word rather than a code, so nothing here can write it into the
|
|
81
|
+
* record as a diagnostic; that is OS7018 and OS7019, and both are deferred.
|
|
82
|
+
*/
|
|
83
|
+
function settle(result, index, bar, books, fills, from) {
|
|
84
|
+
let seq = from;
|
|
85
|
+
for (const outcome of result.frames) {
|
|
86
|
+
if (outcome.refused !== undefined)
|
|
87
|
+
continue;
|
|
88
|
+
if (outcome.delta <= 0 || outcome.price === null)
|
|
89
|
+
continue;
|
|
90
|
+
const intent = books.intents.get(outcome.intentId);
|
|
91
|
+
if (intent === undefined || intent.side === null)
|
|
92
|
+
continue;
|
|
93
|
+
const before = books.sizes.get(intent.positionRef) ?? 0;
|
|
94
|
+
const after = before + (intent.side === 'sell' ? -outcome.delta : outcome.delta);
|
|
95
|
+
books.sizes.set(intent.positionRef, after);
|
|
96
|
+
seq += 1;
|
|
97
|
+
fills.push({
|
|
98
|
+
seq,
|
|
99
|
+
intentId: outcome.intentId,
|
|
100
|
+
orderRef: books.refs.get(outcome.intentId) ?? '',
|
|
101
|
+
tag: intent.tag,
|
|
102
|
+
positionRef: intent.positionRef,
|
|
103
|
+
side: intent.side,
|
|
104
|
+
units: outcome.delta,
|
|
105
|
+
price: outcome.price,
|
|
106
|
+
// The bar the fold happened at, which is the bar the position exists
|
|
107
|
+
// from. Where the fill itself traded is the bar before it or this bar's
|
|
108
|
+
// own open, and neither is a bar the strategy could have acted on it in.
|
|
109
|
+
barIndex: index,
|
|
110
|
+
barTime: bar.time,
|
|
111
|
+
refSizeBefore: before,
|
|
112
|
+
refSizeAfter: after,
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
return seq;
|
|
116
|
+
}
|
|
117
|
+
/** Every intent one bar handed over, in the order the bar applied them. */
|
|
118
|
+
function intentsIn(result) {
|
|
119
|
+
const out = [];
|
|
120
|
+
for (const effect of result.effects)
|
|
121
|
+
for (const intent of effect.intents)
|
|
122
|
+
out.push(intent);
|
|
123
|
+
return out;
|
|
124
|
+
}
|
|
125
|
+
//# sourceMappingURL=walk.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"walk.js","sourceRoot":"","sources":["../../../src/core/backtest/walk.ts"],"names":[],"mappings":"AAYA,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAmB3C;;;;;;GAMG;AACH,MAAM,UAAU,IAAI,CAClB,MAAc,EACd,WAAwB,EACxB,IAA4B,EAC5B,OAAqB,EACrB,IAAyD;IAEzD,MAAM,KAAK,GAAmB,EAAE,CAAC;IACjC,MAAM,IAAI,GAAyB,EAAE,CAAC;IACtC,MAAM,GAAG,GAAc,EAAE,CAAC;IAC1B,MAAM,MAAM,GAAgB,EAAE,CAAC;IAC/B,MAAM,WAAW,GAAyB,EAAE,CAAC;IAC7C,MAAM,OAAO,GAAG,IAAI,GAAG,EAAuB,CAAC;IAC/C,MAAM,IAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;IACvC,MAAM,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,EAAE,MAAM,CAAC,GAAG;YACf,WAAW,EAAE,MAAM,CAAC,WAAW;YAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;YACjB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,KAAK,EAAE,OAAO,CAAC,KAAK;YACpB,qEAAqE;YACrE,wEAAwE;YACxE,yEAAyE;YACzE,QAAQ,EAAE,KAAK;YACf,OAAO,EAAE,GAAG,CAAC,IAAI;YACjB,aAAa,EAAE,MAAM;YACrB,YAAY,EAAE,KAAK;SACpB,CAAC,CAAC;IACL,CAAC;IACD,OAAO,GAAG,CAAC;AACb,CAAC;AAED,2EAA2E;AAC3E,SAAS,SAAS,CAAC,MAAiB;IAClC,MAAM,GAAG,GAAkB,EAAE,CAAC;IAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO;QAAE,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,OAAO;YAAE,GAAG,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC;IAC3F,OAAO,GAAG,CAAC;AACb,CAAC"}
|
|
@@ -9,6 +9,7 @@ export declare const STAGE_LABELS: {
|
|
|
9
9
|
readonly check: "checker";
|
|
10
10
|
readonly runtime: "engine";
|
|
11
11
|
readonly host: "host";
|
|
12
|
+
readonly import: "importer";
|
|
12
13
|
};
|
|
13
14
|
export declare const ENTRIES: {
|
|
14
15
|
readonly OS1001: {
|
|
@@ -814,6 +815,28 @@ export declare const ENTRIES: {
|
|
|
814
815
|
readonly fix: "Give the title something to say: input(2, \"Precision\").";
|
|
815
816
|
readonly placeholders: readonly [];
|
|
816
817
|
};
|
|
818
|
+
readonly OS3025: {
|
|
819
|
+
readonly code: "OS3025";
|
|
820
|
+
readonly title: "A setting is part of a larger expression here";
|
|
821
|
+
readonly severity: "error";
|
|
822
|
+
readonly stage: "check";
|
|
823
|
+
readonly since: 1;
|
|
824
|
+
readonly autofix: false;
|
|
825
|
+
readonly message: "{option} is fixed before the first bar and holds an input() only as the whole of its value, so it cannot hold an expression over one.";
|
|
826
|
+
readonly fix: "Declare the setting as the value itself, with an input() written as the whole of {option}, or write the value out as a literal.";
|
|
827
|
+
readonly placeholders: readonly ["option"];
|
|
828
|
+
};
|
|
829
|
+
readonly OS3026: {
|
|
830
|
+
readonly code: "OS3026";
|
|
831
|
+
readonly title: "This option cannot be a setting";
|
|
832
|
+
readonly severity: "error";
|
|
833
|
+
readonly stage: "check";
|
|
834
|
+
readonly since: 1;
|
|
835
|
+
readonly autofix: false;
|
|
836
|
+
readonly message: "{option} is written into the compiled program as a plain value, so a setting cannot choose it in this format version.";
|
|
837
|
+
readonly fix: "Write the option out as a string literal and drop the input(): style = \"step\", for instance, is one of the values OS3008 names.";
|
|
838
|
+
readonly placeholders: readonly ["option"];
|
|
839
|
+
};
|
|
817
840
|
readonly OS4001: {
|
|
818
841
|
readonly code: "OS4001";
|
|
819
842
|
readonly title: "History index is not usable";
|
|
@@ -1196,7 +1219,7 @@ export declare const ENTRIES: {
|
|
|
1196
1219
|
readonly since: 1;
|
|
1197
1220
|
readonly autofix: false;
|
|
1198
1221
|
readonly message: "The host did not supply {fact} for {symbol}.";
|
|
1199
|
-
readonly fix: "Supply {fact} in the host's instrument record, or
|
|
1222
|
+
readonly fix: "Supply {fact} in the host's instrument record for {symbol}, or leave the session out of the record, which makes every session read absent rather than wrong.";
|
|
1200
1223
|
readonly placeholders: readonly ["fact", "symbol"];
|
|
1201
1224
|
};
|
|
1202
1225
|
readonly OS6013: {
|
|
@@ -1320,6 +1343,28 @@ export declare const ENTRIES: {
|
|
|
1320
1343
|
readonly fix: "Supply the schedule and leave the declaration's commission at its default of zero, or state the commission in the declaration and supply no schedule. A schedule is the one of the two that can carry a floor, a cap, a charge levied on a charge, and a cost that falls on one side of the trade only.";
|
|
1321
1344
|
readonly placeholders: readonly ["commission", "commissionType"];
|
|
1322
1345
|
};
|
|
1346
|
+
readonly OS6024: {
|
|
1347
|
+
readonly code: "OS6024";
|
|
1348
|
+
readonly title: "The host cannot draw something this study declares";
|
|
1349
|
+
readonly severity: "error";
|
|
1350
|
+
readonly stage: "host";
|
|
1351
|
+
readonly since: 1;
|
|
1352
|
+
readonly autofix: false;
|
|
1353
|
+
readonly message: "This host cannot draw {what}: {limit}.";
|
|
1354
|
+
readonly fix: "Declare what this host draws, or run the study on a host that draws {what}.";
|
|
1355
|
+
readonly placeholders: readonly ["what", "limit"];
|
|
1356
|
+
};
|
|
1357
|
+
readonly OS6025: {
|
|
1358
|
+
readonly code: "OS6025";
|
|
1359
|
+
readonly title: "A bar has no time";
|
|
1360
|
+
readonly severity: "error";
|
|
1361
|
+
readonly stage: "host";
|
|
1362
|
+
readonly since: 1;
|
|
1363
|
+
readonly autofix: false;
|
|
1364
|
+
readonly message: "Bar {index} was handed over with no time.";
|
|
1365
|
+
readonly fix: "State the bar's open instant in whole milliseconds since the Unix epoch, UTC, and leave out a bar the host cannot date rather than handing it over without a time.";
|
|
1366
|
+
readonly placeholders: readonly ["index"];
|
|
1367
|
+
};
|
|
1323
1368
|
readonly OS7001: {
|
|
1324
1369
|
readonly code: "OS7001";
|
|
1325
1370
|
readonly title: "Only a strategy can do that";
|
|
@@ -1738,6 +1783,138 @@ export declare const ENTRIES: {
|
|
|
1738
1783
|
readonly fix: "Assign none to the name on the same path as the delete, and where the object came out of an array, remove the element as well as deleting the object.";
|
|
1739
1784
|
readonly placeholders: readonly ["name", "kind", "line"];
|
|
1740
1785
|
};
|
|
1786
|
+
readonly OS9001: {
|
|
1787
|
+
readonly code: "OS9001";
|
|
1788
|
+
readonly title: "Version not read by the importer";
|
|
1789
|
+
readonly severity: "error";
|
|
1790
|
+
readonly stage: "import";
|
|
1791
|
+
readonly since: 1;
|
|
1792
|
+
readonly autofix: false;
|
|
1793
|
+
readonly message: "The importer reads scripts written for version 5 or 6 of the source dialect, and this one {found}.";
|
|
1794
|
+
readonly fix: "Bring the script up to version 5 or 6 in the source dialect, or translate it by hand, and import it again.";
|
|
1795
|
+
readonly placeholders: readonly ["found"];
|
|
1796
|
+
};
|
|
1797
|
+
readonly OS9002: {
|
|
1798
|
+
readonly code: "OS9002";
|
|
1799
|
+
readonly title: "Construct with no equivalent";
|
|
1800
|
+
readonly severity: "error";
|
|
1801
|
+
readonly stage: "import";
|
|
1802
|
+
readonly since: 1;
|
|
1803
|
+
readonly autofix: false;
|
|
1804
|
+
readonly message: "The importer cannot translate {construct}, so the statement holding it was kept as a comment.";
|
|
1805
|
+
readonly fix: "Translate that statement by hand from the comment that holds it: the rest of the script was translated around it.";
|
|
1806
|
+
readonly placeholders: readonly ["construct"];
|
|
1807
|
+
};
|
|
1808
|
+
readonly OS9003: {
|
|
1809
|
+
readonly code: "OS9003";
|
|
1810
|
+
readonly title: "Built-in with no mapping";
|
|
1811
|
+
readonly severity: "error";
|
|
1812
|
+
readonly stage: "import";
|
|
1813
|
+
readonly since: 1;
|
|
1814
|
+
readonly autofix: false;
|
|
1815
|
+
readonly message: "{name} is not one of the built-ins the importer maps, so the statement holding it was kept as a comment.";
|
|
1816
|
+
readonly fix: "Find the OpenScript library call that does the same job, check how it treats its first bars and absent values, and write the statement by hand.";
|
|
1817
|
+
readonly placeholders: readonly ["name"];
|
|
1818
|
+
};
|
|
1819
|
+
readonly OS9004: {
|
|
1820
|
+
readonly code: "OS9004";
|
|
1821
|
+
readonly title: "Declaration the importer cannot place";
|
|
1822
|
+
readonly severity: "error";
|
|
1823
|
+
readonly stage: "import";
|
|
1824
|
+
readonly since: 1;
|
|
1825
|
+
readonly autofix: false;
|
|
1826
|
+
readonly message: "The importer writes the declaration from one indicator or strategy call at the top level, and this script {found}.";
|
|
1827
|
+
readonly fix: "Give the source script exactly one indicator or strategy declaration at the top level, and import it again.";
|
|
1828
|
+
readonly placeholders: readonly ["found"];
|
|
1829
|
+
};
|
|
1830
|
+
readonly OS9005: {
|
|
1831
|
+
readonly code: "OS9005";
|
|
1832
|
+
readonly title: "Reads a statement that was not translated";
|
|
1833
|
+
readonly severity: "error";
|
|
1834
|
+
readonly stage: "import";
|
|
1835
|
+
readonly since: 1;
|
|
1836
|
+
readonly autofix: false;
|
|
1837
|
+
readonly message: "{name} is declared by the statement at line {line}, which was not translated, so this statement that reads it was kept as a comment too.";
|
|
1838
|
+
readonly fix: "Translate the statement at line {line} by hand first, then this one, which was kept as a comment only because it reads {name}.";
|
|
1839
|
+
readonly placeholders: readonly ["name", "line"];
|
|
1840
|
+
};
|
|
1841
|
+
readonly OS9006: {
|
|
1842
|
+
readonly code: "OS9006";
|
|
1843
|
+
readonly title: "Argument with no equivalent";
|
|
1844
|
+
readonly severity: "error";
|
|
1845
|
+
readonly stage: "import";
|
|
1846
|
+
readonly since: 1;
|
|
1847
|
+
readonly autofix: false;
|
|
1848
|
+
readonly message: "{argument} changes what {call} computes or trades, and OpenScript has no equivalent the importer can write.";
|
|
1849
|
+
readonly fix: "Translate the call by hand, deciding what OpenScript should do in place of {argument}, or remove {argument} from the source script if the script does not depend on it.";
|
|
1850
|
+
readonly placeholders: readonly ["argument", "call"];
|
|
1851
|
+
};
|
|
1852
|
+
readonly OS9007: {
|
|
1853
|
+
readonly code: "OS9007";
|
|
1854
|
+
readonly title: "Warmup and absent bars follow OpenScript";
|
|
1855
|
+
readonly severity: "warning";
|
|
1856
|
+
readonly stage: "import";
|
|
1857
|
+
readonly since: 1;
|
|
1858
|
+
readonly autofix: false;
|
|
1859
|
+
readonly message: "{call} became {target} here and wherever else the script calls it, and {target} follows OpenScript's own warmup, arithmetic and handling of absent values, which the original is not guaranteed to share.";
|
|
1860
|
+
readonly fix: "Compare the first bars of the translation with the original, and where the script depends on them, write the value as an explicit recurrence held in var, seeded the way the original seeds it.";
|
|
1861
|
+
readonly placeholders: readonly ["call", "target"];
|
|
1862
|
+
};
|
|
1863
|
+
readonly OS9008: {
|
|
1864
|
+
readonly code: "OS9008";
|
|
1865
|
+
readonly title: "Whole-number division in version 5";
|
|
1866
|
+
readonly severity: "warning";
|
|
1867
|
+
readonly stage: "import";
|
|
1868
|
+
readonly since: 1;
|
|
1869
|
+
readonly autofix: false;
|
|
1870
|
+
readonly message: "Both sides of this division are whole-number constants, which version 5 of the source dialect divides without a fractional part, and OpenScript keeps the fraction.";
|
|
1871
|
+
readonly fix: "If the script relied on the whole-number result, wrap the translated division in trunc(); otherwise leave it as it is.";
|
|
1872
|
+
readonly placeholders: readonly [];
|
|
1873
|
+
};
|
|
1874
|
+
readonly OS9009: {
|
|
1875
|
+
readonly code: "OS9009";
|
|
1876
|
+
readonly title: "Presentation argument left out";
|
|
1877
|
+
readonly severity: "warning";
|
|
1878
|
+
readonly stage: "import";
|
|
1879
|
+
readonly since: 1;
|
|
1880
|
+
readonly autofix: false;
|
|
1881
|
+
readonly message: "{argument} changes how {call} is displayed or what it may allocate, not what it computes, and OpenScript has no equivalent, so the translation leaves it out.";
|
|
1882
|
+
readonly fix: "Nothing needs to change unless the display mattered; where it did, restyle the translated call with the arguments OpenScript does have, such as its colour, width and style.";
|
|
1883
|
+
readonly placeholders: readonly ["argument", "call"];
|
|
1884
|
+
};
|
|
1885
|
+
readonly OS9010: {
|
|
1886
|
+
readonly code: "OS9010";
|
|
1887
|
+
readonly title: "Order placed under OpenScript's order model";
|
|
1888
|
+
readonly severity: "warning";
|
|
1889
|
+
readonly stage: "import";
|
|
1890
|
+
readonly since: 1;
|
|
1891
|
+
readonly autofix: false;
|
|
1892
|
+
readonly message: "{call} was translated into OpenScript's order calls here and wherever else the script uses it, and OpenScript decides when an order fills, how a reversal and a repeated entry are handled and when an exit level starts to apply by its own order model.";
|
|
1893
|
+
readonly fix: "Backtest the translation beside the original and compare the two trade lists before relying on it, and adjust the order calls by hand where they part.";
|
|
1894
|
+
readonly placeholders: readonly ["call"];
|
|
1895
|
+
};
|
|
1896
|
+
readonly OS9011: {
|
|
1897
|
+
readonly code: "OS9011";
|
|
1898
|
+
readonly title: "Equality over two absent values";
|
|
1899
|
+
readonly severity: "warning";
|
|
1900
|
+
readonly stage: "import";
|
|
1901
|
+
readonly since: 1;
|
|
1902
|
+
readonly autofix: false;
|
|
1903
|
+
readonly message: "Both sides of {operator} can be absent on the same bar, and OpenScript counts two absent values as equal, which the original is not guaranteed to do.";
|
|
1904
|
+
readonly fix: "If the original relied on two absent values never comparing equal, guard the translated comparison with isNone() on either side.";
|
|
1905
|
+
readonly placeholders: readonly ["operator"];
|
|
1906
|
+
};
|
|
1907
|
+
readonly OS9012: {
|
|
1908
|
+
readonly code: "OS9012";
|
|
1909
|
+
readonly title: "The translation does not compile";
|
|
1910
|
+
readonly severity: "error";
|
|
1911
|
+
readonly stage: "import";
|
|
1912
|
+
readonly since: 1;
|
|
1913
|
+
readonly autofix: false;
|
|
1914
|
+
readonly message: "The OpenScript compiler refused the translation of this statement with {code}, so the statement was kept as a comment.";
|
|
1915
|
+
readonly fix: "Look up {code} in this catalogue and translate the statement by hand in the form that code's fix describes.";
|
|
1916
|
+
readonly placeholders: readonly ["code"];
|
|
1917
|
+
};
|
|
1741
1918
|
};
|
|
1742
1919
|
/** Every code the compiler and the engines may emit. Nothing else is one. */
|
|
1743
1920
|
export type DiagnosticCode = keyof typeof ENTRIES;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"catalogue.generated.d.ts","sourceRoot":"","sources":["../../../src/core/catalogue/catalogue.generated.ts"],"names":[],"mappings":"AAQA,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,oDAAoD;AACpD,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,+FAA+F;AAC/F,eAAO,MAAM,YAAY
|
|
1
|
+
{"version":3,"file":"catalogue.generated.d.ts","sourceRoot":"","sources":["../../../src/core/catalogue/catalogue.generated.ts"],"names":[],"mappings":"AAQA,uEAAuE;AACvE,eAAO,MAAM,wBAAwB,IAAI,CAAC;AAE1C,oDAAoD;AACpD,eAAO,MAAM,0BAA0B,IAAI,CAAC;AAE5C,+FAA+F;AAC/F,eAAO,MAAM,YAAY;;;;;;;CAO2B,CAAC;AAErD,eAAO,MAAM,OAAO;;;;;;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