Bentrix Docs
HomePricingDashboard

JavaScript: forecast

Every method of client.forecast in the JavaScript SDK.

chartSetForecast#

Set how a chart draws forecasts · tool chart_set_forecast

scope: labplan: freesince 3.3.0

Sets how a chart draws a model's forecast: show, the ghost's opacity, uncertainty (fan, band, paths, off), the bands' opacity, the room on the right (forecast, shift_only, or N slots), how long a realized forecast stays (until_replaced, off, {horizons}, {bars}), a coarser interval spanned or by time, a finer one folded or by time, an element forecast on a time chart (auto, strip, by_expected_time, panel), a time forecast and another rule on a chart built by price (derived, strip, both), a profile (forecast_session, strip, off), true equivolume's widths (by_volume, median), the time past the newest bar (clock_time, session_time), the sampled paths drawn, and the models hidden on it (the legend's eye); models_per_market applies to every workbench. A field not named keeps its value. Answers the chart's forecast settings.

Declaration

client.forecast
chartSetForecast(args: { chart: string; arrival_marks?: boolean; band_opacity?: number; coarser?: string; diff?: unknown; element_on_time?: string; equivolume_width?: string; finer?: string; hidden?: string[]; journal?: string; keep_after_realized?: unknown; models_per_market?: number; on_profile?: string; opacity?: number; other_rule?: string; past_newest?: string; read_at_anchor?: unknown; readout?: boolean; room?: unknown; samples_drawn?: number; show?: boolean; time_on_elements?: string; trail?: number; uncertainty?: string }): Promise<any>

Parameters

NameTypeWhat it is
chartstringrequiredThe chart's uri.
arrival_marksbooleanoptionalA tick on the time axis at each forecast's arrival.
band_opacitynumberoptionalThe bands' opacity, 0.05 to 0.6.
coarserstringoptionalA coarser interval: "spanned" or "by_time".
diffunknownoptional**The diff view**{"a": model, "b": model} shades the gap between their closes step by step; "off" takes it away.
element_on_timestringoptionalAn element forecast (renko, kagi, …) on a time chart: "auto" (by expected time where every step says when it closes, else the strip), "strip", "by_expected_time" or "panel".
equivolume_widthstringoptionalA step's width on true equivolume: "by_volume" (its own volume, else the window's median) or "median".
finerstringoptionalA finer interval: "folded" or "by_time".
hiddenstring[]optionalModels hidden on this chart, as the legend's eye hides them: the whole set.
journalstringoptionalThe journal, for every workbench: laboratory_and_paper (the default), also_real, or off.
keep_after_realizedunknownoptionalKeep after realized: "until_replaced", "off", {"horizons": n} or {"bars": n}.
models_per_marketnumberoptionalModels per market, for every workbench: 1 to 64.
on_profilestringoptionalOn a profile: "forecast_session" (letters over the rows one session after the last), "strip" or "off".
opacitynumberoptionalThe ghost's opacity, 0.2 to 1.
other_rulestringoptionalAn element forecast of another type or rule on a chart built by price: "derived", "strip" or "both".
past_neweststringoptionalPast the newest bar: "clock_time", or "session_time" (only the hours the market prints bars in).
read_at_anchorunknownoptionalRead a forecast at its anchor, for every workbench: {"laboratory": bool, "paper_and_real": bool}; both off by default. A look-ahead: marked wherever it reads; on a live bench never the newest close.
readoutbooleanoptionalA step's figures beside the pointer and in the data window.
roomunknownoptionalRoom on the right: "forecast" (as wide as the widest forecast), "shift_only", or a number of slots.
samples_drawnnumberoptionalSampled paths drawn per step, 1 to 256.
showbooleanoptionalDraw forecasts on this chart.
time_on_elementsstringoptionalA time forecast on a chart built by price: "derived" (through the chart's own rule), "strip" or "both".
trailnumberoptionalThe trail: the forecasts each model put before the one standing, drawn faint - 0 (off) to 64.
uncertaintystringoptionalFan, band, paths or off.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the chart's forecast settings.

Example

await client.forecast.chartSetForecast({ chart })

clear#

Remove forecasts from a workbench · tool forecast_clear

scope: labplan: plussince 3.3.0

Removes the forecasts of one model, one market, or all of them from the workbench, every arrival kept for them included, as the × on a forecast's legend row does. Answers how many (market, model) pairs were cleared.

Declaration

client.forecast
clear(args: { bench: string; model?: string; symbol?: string }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequiredThe workbench's uri.
modelstringoptionalOne model; omitted, every model.
symbolstringoptionalOne market; omitted, every market.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers how many (market, model) pairs were cleared.

Example

await client.forecast.clear({ bench })

compare#

Set models' reports side by side · tool forecast_compare

scope: readplan: freesince 3.3.0

Forecast_report for several models on one market, a row each, over the same journal and the same bars. Unordered (by name) unless metric_order names a measure, then best first. A comparison is a laboratory's instrument: nothing here is published or ranked anywhere else.

Declaration

client.forecast
compare(args: { bench: string; symbol: string; last?: number; metric_order?: string; models?: string[] }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired
symbolstringrequired
lastnumberoptional
metric_orderstringoptionalOrder the rows by this measure, best first (mae_close, rmse_close, mape_close, pinball_loss, crps ascending; direction_hit_rate descending). Omitted, by the model's name: no ranking is drawn unless asked.
modelsstring[]optionalThe models; omitted, every model the journal holds on the market.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

What the tool's description says.

Example

await client.forecast.compare({ bench, symbol: "SYN-DOCS" })

diff#

Set two models' forecasts step by step · tool forecast_diff

scope: readplan: freesince 3.3.0

The two models' forecasts a reader at the workbench's clock sees on one market, step by step where their steps open at the same instant: each one's close and the difference (b minus a), and where their outermost bands overlap.

Declaration

client.forecast
diff(args: { bench: string; symbol: string; a: string; b: string }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired
symbolstringrequired
astringrequired
bstringrequired

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

What the tool's description says.

Example

await client.forecast.diff({ bench, symbol: "SYN-DOCS", a: "…", b: "…" })

ensembleDefine#

Declare an ensemble of forecasts · tool forecast_ensemble_define

scope: labplan: freesince 3.4.0

Declares an ensemble on a workbench's market: its label, its members (models' labels), the rule its closes are combined by (mean, median, weighted with one weight a member) and the NAMED rule its bands are combined by - quantiles_averaged (each level's lo and hi averaged; the band claims no coverage of its own), members_pooled (the mixture of the members' samples, quantiles or band edges, its quantiles at each level; partly pooled where a member gave only a band), or none. Bentrix computes only what is declared: whenever a member's newest forecast arrives and every member stands at one anchor, the ensemble's forecast is put, authored ensemble:<id>, so its arrival is the latest of its members'; a member cleared takes it off with a sentence. Declaring an id again replaces it. Answers the ensemble.

Declaration

client.forecast
ensembleDefine(args: { bench: string; symbol: string; id: string; members: string[]; rule: "mean" | "median" | "weighted"; bands?: "quantiles_averaged" | "members_pooled" | "none"; weights?: number[] }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired
symbolstringrequired
idstringrequiredThe ensemble's label, as a model's: [a-z0-9_]{1,32}, none of its members.
membersstring[]requiredThe members' model labels, at least two.
rule"mean" | "median" | "weighted"requiredMean, median or weighted.
bands"quantiles_averaged" | "members_pooled" | "none"optionalQuantiles_averaged (each level's edges averaged; the band claims no p), members_pooled (the mixture's quantiles) or none. Omitted: quantiles_averaged.
weightsnumber[]optionalFor weighted: one weight a member, in the members' order.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the ensemble.

Example

await client.forecast.ensembleDefine({ bench, symbol: "SYN-DOCS", id: "…", members: "…", rule: "…" })

ensembleList#

List a workbench's ensembles · tool forecast_ensemble_list

scope: readplan: freesince 3.4.0

Answers the ensembles declared on a workbench: each one's label, market, members, rules, the latest member arrival its forecast was made from, and what it last said where none stands.

Declaration

client.forecast
ensembleList(args: { bench: string }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the ensembles declared on a workbench: each one's label, market, members, rules, the latest member arrival its forecast was made from, and what it last said where none stands.

Example

await client.forecast.ensembleList({ bench })

ensembleRemove#

Remove an ensemble · tool forecast_ensemble_remove

scope: labplan: freesince 3.4.0

Removes an ensemble from a workbench's market, and its forecast with it. Answers whether one was there.

Declaration

client.forecast
ensembleRemove(args: { bench: string; symbol: string; id: string }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired
symbolstringrequired
idstringrequired

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers whether one was there.

Example

await client.forecast.ensembleRemove({ bench, symbol: "SYN-DOCS", id: "…" })

evalBatch#

Run a batch of evaluation runs with ONNX models · tool forecast_eval_batch

scope: labplan: plussince 3.4.0

Runs one evaluation run per cell over the workbench's own history, each with an ONNX model from the models folder asked INSIDE the loop by Bentrix's built-in engine: at each close the window its manifest describes is cut there, the model run, its output put as that close's forecast, stamped close + latency, and scored as forecast_eval_close scores. The workbench's clock does not move. Answers each cell's report, or why it did not run, in the cells' order.

Declaration

client.forecast
evalBatch(args: { bench: string; cells: Array<{ file: string; from_ms: number; latency?: unknown; stride?: number; symbol?: string; to_ms?: number }> }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired
cellsArray<{ file: string; from_ms: number; latency?: unknown; stride?: number; symbol?: string; to_ms?: number }>requiredOne evaluation run each.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers each cell's report, or why it did not run, in the cells' order.

Example

await client.forecast.evalBatch({ bench, cells: "…" })

evalClose#

End an evaluation run and report it · tool forecast_eval_close

scope: labplan: plussince 3.3.0

Ends an evaluation run: its report (forecast_report's measures over the run's forecasts against the workbench's history, each step only if it had not closed at its stamped arrival, the latency said) and its journal written as one JSON-lines file in the export folder under this agent's name. The bench's own journal is not touched.

Declaration

client.forecast
evalClose(args: { eval: number }): Promise<any>

Parameters

NameTypeWhat it is
evalnumberrequired

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

What the tool's description says.

Example

await client.forecast.evalClose({ eval: 1 })

evalMake#

Start an evaluation run over history · tool forecast_eval_make

scope: labplan: plussince 3.3.0

Starts an evaluation run over the workbench's own history between from_ms and to_ms (its clock at most; the clock does not move): the closes of forecast_tf on the first market, one in stride. Forecast_eval_next hands the window cut at each close and scores the forecast handed back for the close before; forecast_eval_close answers the report. Each forecast's arrival is stamped close + latency (none, measured - this model's mean live latency on the bench's journal, 0 and said when it has none - or N ms), and a step it could already see is late and unscored, exactly as live. Over a span the workbench's laboratory does not hold nothing is made or fetched: the answer is an ask - which laboratory, the span, the days and markets downloaded, what MetaTrader will be asked - and a watch uri, and the person answers on one sheet in Bentrix's window (Make it and run, or No); forecast_eval_state and the event bentrix://forecasts/eval say what came of it. Answers the eval's id, the closes and what it runs on.

Declaration

client.forecast
evalMake(args: { bench: string; symbols: string[]; frames: string[]; forecast_tf: string; from_ms: number; model: string; latency?: unknown; limit?: number; retrain?: string; run_model?: string; stride?: number; to_ms?: number }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequiredThe workbench whose history the run walks; its clock does not move.
symbolsstring[]requiredThe markets of each window, the first the forecast's.
framesstring[]requiredThe frames of each window: intervals' labels.
forecast_tfstringrequiredThe interval whose closes the run walks, and the forecast's.
from_msnumberrequired
modelstringrequiredThe model label the run's forecasts carry.
latencyunknownoptionalThe latency each forecast is stamped with: "none", "measured" (this model's mean live latency on the bench's journal, the default), or a number of ms.
limitnumberoptionalClosed bars per frame in each window (200 when omitted).
retrainstringoptionalWhen a retrain is due: "session" (each new day), "week", or a count of closes.
run_modelstringoptional**A model of the models folder Bentrix runs at each close itself**the run is driven by Bentrix to its end, the model handed each window and its answer scored, its label the model's own; omitted, the caller drives the run with forecast_eval_next.
stridenumberoptionalOne close in N.
to_msnumberoptionalAt most the workbench's clock; omitted, the clock.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the eval's id, the closes and what it runs on.

Example

await client.forecast.evalMake({ bench, symbols: "…", frames: "…", forecast_tf: "…", from_ms: 1, model: "…" })

evalNext#

The next window of an evaluation run · tool forecast_eval_next

scope: labplan: plussince 3.3.0

Scores the forecast handed for the last window - checked as forecast_put checks it, its arrival stamped at that window's close plus the run's latency - and hands the window cut at the next close: close_ms, the window (bars_window's answer at that instant, nothing later), done once the closes are walked, scored (the forecasts recorded so far), and retrain_due where the run's retrain rule falls.

Declaration

client.forecast
evalNext(args: { eval: number; forecast?: unknown }): Promise<any>

Parameters

NameTypeWhat it is
evalnumberrequired
forecastunknownoptionalThe forecast for the window handed last, as forecast_spec (its model and market the run's; its anchor the last closed bar of that window's close). Omitted for the first window, or to pass a close.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

What the tool's description says.

Example

await client.forecast.evalNext({ eval: 1 })

evalState#

Where an evaluation run or its ask stands · tool forecast_eval_state

scope: readplan: freesince 3.3.0

A run's closes walked and left, its forecasts recorded, its latency rule and retrain rule; or where an ask forecast_eval_make answered stands: asked (the sheet stands in Bentrix's window), confirmed (Make it and run pressed), made_laboratory (the workbench over the span is made and its days are downloading), started (with the eval to drive), declined (by the person - never a failure), or failed (with why). The person's press on the sheet is the one answer; no tool answers it. The event bentrix://forecasts/eval carries each move of an ask.

Declaration

client.forecast
evalState(args: { ask?: string; eval?: number }): Promise<any>

Parameters

NameTypeWhat it is
askstringoptionalOr an ask it answered (bentrix://ask/N), over days the workbench's laboratory did not hold.
evalnumberoptionalA run forecast_eval_make started.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

What the tool's description says.

Example

await client.forecast.evalState()

get#

Read the forecasts on a workbench · tool forecast_get

scope: readplan: freesince 3.3.0

Answers the forecasts a reader at at_ms (the workbench's clock when omitted) sees on the workbench, by arrival - never one that arrived after that instant - each with its model, market, epoch, form, anchor, put_ms, steps' count, state (current, partly realized, realized), how many steps have closed, who put it and its colours; steps true hands the steps. Arrivals lists every arrival the workbench keeps per model.

Declaration

client.forecast
get(args: { bench: string; at_ms?: number; model?: string; steps?: boolean; symbol?: string }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequiredThe workbench's uri.
at_msnumberoptionalThe instant to read at, UTC ms: what a reader at that instant saw. Omitted, the workbench's clock.
modelstringoptionalOne model; omitted, every model.
stepsbooleanoptionalTrue hands each forecast's steps too.
symbolstringoptionalOne market; omitted, every market.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the forecasts a reader at at_ms (the workbench's clock when omitted) sees on the workbench, by arrival - never one that arrived after that instant - each with its model, market, epoch, form, anchor, put_ms, steps' count, state (current, partly realized, realized), how many steps have closed, who put it and its colours; steps true hands the steps.

Example

await client.forecast.get({ bench })

presetApply#

Apply a forecast preset · tool forecast_preset_apply

scope: labplan: freesince 3.4.0

Applies a preset's look to a chart, or with all true to every chart of that chart's workbench, as the card's Preset row does; each chart keeps its Show and the models its legend hid. Answers the charts it was applied to.

Declaration

client.forecast
presetApply(args: { name: string; chart: string; all?: boolean }): Promise<any>

Parameters

NameTypeWhat it is
namestringrequiredThe preset: bentrix, quiet, or a name it was saved under.
chartstringrequiredThe chart it is applied to; omitted with all true, every chart of the workbench the chart is on.
allbooleanoptional

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the charts it was applied to.

Example

await client.forecast.presetApply({ name: "…", chart })

presetDelete#

Delete a saved forecast preset · tool forecast_preset_delete

scope: labplan: freesince 3.4.0

Deletes a preset the person saved; Bentrix's own (bentrix, quiet) cannot be. Answers every preset's name left.

Declaration

client.forecast
presetDelete(args: { name: string }): Promise<any>

Parameters

NameTypeWhat it is
namestringrequired

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers every preset's name left.

Example

await client.forecast.presetDelete({ name: "…" })

presetSave#

Save a chart's forecast look as a preset · tool forecast_preset_save

scope: labplan: freesince 3.4.0

Saves a chart's forecast look - every row of its Forecast tab but Show and the models its legend hid - under a name, kept on this machine; the card's Preset row offers it beside Bentrix's own presets (bentrix, quiet). Saving a name again replaces it. Answers every preset's name.

Declaration

client.forecast
presetSave(args: { chart: string; name: string }): Promise<any>

Parameters

NameTypeWhat it is
chartstringrequiredThe chart whose look is saved.
namestringrequiredThe preset's name, [a-z0-9_]{1,32}, not a built-in's (bentrix, quiet).

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers every preset's name.

Example

await client.forecast.presetSave({ chart, name: "…" })

put#

Put a model's forecast on a workbench · tool forecast_put

scope: labplan: plussince 3.3.0

Hands over a forecast_spec: drawn on every chart of its market on the workbench from the instant it arrives, which Bentrix stamps as put_ms on the workbench's own clock (a laboratory's replay instant, a live bench's market clock) - no reader sees it before. Refused by name where it cannot be true (a high under its body, a band upside down, falling quantiles, an anchor that is not a closed bar of the form's interval, an element form naming an interval) with what is offered instead; a lower epoch than the model's standing forecast is refused; past Models per market the answer names the setting. Answers the arrival, the state, where the steps end, the replaced epoch, and each chart of the market with where the forecast stands on it.

Declaration

client.forecast
put(args: { bench: string; forecast: unknown; steps_total?: number }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequiredThe workbench's uri.
forecastunknownrequiredThe forecast, as forecast_spec describes it.
steps_totalnumberoptional**A long forecast in chunks**the steps the whole forecast will hold. Its steps here are the first chunk; the rest come by forecast_put_chunk, and it arrives - for every reader - when the last one lands.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers the arrival, the state, where the steps end, the replaced epoch, and each chart of the market with where the forecast stands on it.

Example

await client.forecast.put({ bench, forecast: "…" })

putChunk#

Send the next chunk of a long forecast · tool forecast_put_chunk

scope: labplan: plussince 3.3.0

Appends steps to a forecast opened with forecast_put and steps_total, from_step being the count already sent. Until the last chunk lands the forecast exists for no reader (the legend says receiving N of M); at the last one the whole forecast is checked as forecast_put checks it and arrives then, stamped put_ms. A chunk out of order, of another epoch or past the total is refused by name. Answers have and of, and at the last chunk forecast_put's answer.

Declaration

client.forecast
putChunk(args: { bench: string; symbol: string; model: string; epoch: number; from_step: number; steps: unknown[] }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequiredThe workbench's uri.
symbolstringrequired
modelstringrequired
epochnumberrequiredThe epoch the forecast was opened with.
from_stepnumberrequiredThe index (0-based) of this chunk's first step: the count of steps already sent.
stepsunknown[]requiredThe steps, as forecast_spec's steps.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers have and of, and at the last chunk forecast_put's answer.

Example

await client.forecast.putChunk({ bench, symbol: "SYN-DOCS", model: "…", epoch: 1, from_step: 1, steps: "…" })

putMany#

Put several forecasts at once · tool forecast_put_many

scope: labplan: plussince 3.3.0

Hands over up to 256 forecast_specs to one workbench in one call, every one arriving at the same instant of its clock: several markets and several models. Each refused one is named by its index with why; all_or_nothing lands none when one is refused. Answers put (each landed forecast as forecast_put answers it) and refused [{index, why}].

Declaration

client.forecast
putMany(args: { bench: string; forecasts: unknown[]; all_or_nothing?: boolean }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequiredThe workbench's uri.
forecastsunknown[]requiredThe forecasts, each a forecast_spec: several markets, several models, at most 256.
all_or_nothingbooleanoptionalTrue lands none when one is refused; false (the default) lands every one that can be, and names the rest.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

Answers put (each landed forecast as forecast_put answers it) and refused [{index, why}].

Example

await client.forecast.putMany({ bench, forecasts: "…" })

report#

Report how a model's forecasts did · tool forecast_report

scope: readplan: freesince 3.3.0

Scores a model's journalled forecasts on one market against the bars the workbench's history holds, up to its clock - each step only if it had not closed when its forecast arrived: per step and overall, the count, the close's mean absolute error, its percentage, the root mean square error, the mean signed error, the direction hit rate (the close's move from the anchor's own close), each band's coverage against its nominal p, the quantiles' pinball loss, the samples' CRPS, and the mean latency (put_ms after the anchor's close). Steps still to close are pending; steps a late arrival could already see are late and unscored.

Declaration

client.forecast
report(args: { bench: string; symbol: string; model: string; last?: number; since_ms?: number; source?: string }): Promise<any>

Parameters

NameTypeWhat it is
benchstringrequired
symbolstringrequired
modelstringrequired
lastnumberoptionalOnly the newest N forecasts.
since_msnumberoptionalOnly forecasts that arrived at or after this instant, UTC ms.
sourcestringoptionalLive or eval; omitted, both.

Returns

Promise<any> — the tool’s answer as a plain object.

What it answers

What the tool's description says.

Example

await client.forecast.report({ bench, symbol: "SYN-DOCS", model: "…" })

Bentrix 0.1.382Every number, name and default on these pages is read from the application itself.What is comingWhat changed