Bentrix Docs
HomePricingDashboard

JavaScript: laboratories

Every method of client.laboratory in the JavaScript SDK.

benchData#

Keep or move a workbench's data · tool bench_data

scope: labplan: freesince 2.1.0

A workbench of a laboratory of the person's own files whose data a later import rewrote, as its card does: state says which imports changed its data and on how many days; keep keeps its data and puts the card away; move rebuilds it from its record over the new data and says what changed (deals filled at another price, deals no longer made, the balance before and after); keep_move keeps the move; undo puts the workbench back on its own data.

Declaration

client.laboratory
benchData(args: { workbench: string; action?: string }): Promise<any>

Parameters

NameTypeWhat it is
workbenchstringrequiredA laboratory workbench, as a bentrix://bench/... Uri.
actionstringoptionalState (the default), keep, move, keep_move or undo.

Returns

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

What it answers

What the tool's description says.

Example

await client.laboratory.benchData({ workbench: "…" })

generatedLabCreate#

Make the laboratory of generated markets · tool generated_lab_create

scope: labplan: freesince 2.1.0

Makes the one laboratory of markets made from a recipe and a seed, as the Sources sheet's Generated markets card does, or answers it where it exists already: there is one, so a program run twice, or after another, finds it here. Answers the laboratory and made (false when it was there).

Declaration

client.laboratory
generatedLabCreate(): Promise<any>

It takes no arguments.

Returns

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

What it answers

Recorded from a running Bentrix 0.1.382 on a laboratory of generated markets (long lists cut to their first rows):

{
  "laboratory": "bentrix://lab/lab-1",
  "made": true
}

Example

await client.laboratory.generatedLabCreate()

importLabCreate#

Make a laboratory of the person's own files · tool import_lab_create

scope: labplan: freesince 2.1.0

Makes a laboratory of the person's own market data files under a name, as the Sources sheet's card of the person's own files does: empty until a file is imported into it (import_run). There may be many. Answers the laboratory; bench_create makes its workbenches.

Declaration

client.laboratory
importLabCreate(args: { label: string }): Promise<any>

Parameters

NameTypeWhat it is
labelstringrequiredThe laboratory's name, as the person would type it on the Sources sheet.

Returns

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

What it answers

Answers the laboratory; bench_create makes its workbenches.

Example

await client.laboratory.importLabCreate({ label: "…" })

labAdopt#

Answer the one-time adoption · tool lab_adopt

scope: adminplan: freesince 1.0.0

When Bentrix offers once to move an older laboratory's workbenches into the laboratory of the same history, answers it as the offer's own buttons do: keep_both keeps them apart, else they move. Refused when nothing is offered.

Declaration

client.laboratory
labAdopt(args: { keep_both: boolean }): Promise<any>

Parameters

NameTypeWhat it is
keep_bothbooleanrequiredKeep the two apart rather than move the older one's workbenches into the newer.

Returns

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

What it answers

What the tool's description says.

Example

await client.laboratory.labAdopt({ keep_both: true })

labCreate#

Make a laboratory · tool lab_create

scope: labplan: freesince 1.0.0

Makes a laboratory over a data source this edition carries (source, a token from bentrix://sources; the first when omitted) and its first, empty workbench, as the New laboratory sheet's Create does: the account's currency (USD, EUR, GBP, JPY, CHF; over the crypto exchange USDT, USDC, EUR, JPY), opening balance, leverage, hedging or netting and time zone are fixed at birth. Its markets come from Market Watch and its days from the Replay widget. Answers the laboratory and the workbench.

Declaration

client.laboratory
labCreate(args: { currency?: string; leverage?: number; margin_mode?: string; name?: string; opening_balance?: number; source?: string; time_zone?: string }): Promise<any>

Parameters

NameTypeWhat it is
currencystringoptionalThe account's currency: USD, EUR, GBP, JPY or CHF; over the crypto exchange (the crypto exchange) USDT, USDC, EUR or JPY.
leveragenumberoptionalThe leverage, 1 to the venue's ceiling (100 is 1:100).
margin_modestringoptionalHedging or netting.
namestringoptionalThe first workbench's name; a generated one when omitted.
opening_balancenumberoptionalWhat the workbench's account opens on, in its currency.
sourcestringoptional**The recording the laboratory is over**by its token — one of the sources this edition carries (bentrix://sources); the first of them when omitted. A source this edition does not carry is refused: its laboratory found on disk replays, and no new one is made.
time_zonestringoptionalA time zone's code, as the sheet offers them (UTC by default).

Returns

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

What it answers

Answers the laboratory and the workbench.

Example

await client.laboratory.labCreate()

labDelete#

Ask the person to delete a laboratory · tool lab_delete

scope: adminplan: freesince 1.0.0long work: answers a job

Opens Bentrix's own delete sheet for a laboratory, the one that names what goes - its recording's data - and what stays; the person deletes it or keeps it. Answers a job: completed when it is gone, failed when the person kept it.

Declaration

client.laboratory
labDelete(args: { lab: string }): Job<any>

Parameters

NameTypeWhat it is
labstringrequiredThe laboratory's uri, as get_state gives it.

Returns

Job — await job.wait() answers the result: this is long work, or work the person allows first, so the call answers at once with a job and its result comes when it ends, as a plain object.

What it answers

Answers a job: completed when it is gone, failed when the person kept it.

Example

await client.laboratory.labDelete({ lab: "…" })

labRestoreOrphan#

Restore, move or remove a laboratory the list does not name · tool lab_restore_orphan

scope: adminplan: freesince 1.0.0

Restore puts an orphan whose recording has no laboratory back on the list, as its row's restore does, at once. Move (its workbenches into the laboratory its recording already has) and remove (its workbenches lost) ask the person on its row; answers a job for those.

Declaration

client.laboratory
labRestoreOrphan(args: { orphan: string; action: string }): Promise<any>

Parameters

NameTypeWhat it is
orphanstringrequiredThe orphan's uri, as orphans_list gives it.
actionstringrequiredRestore, move or remove - as its row offers.

Returns

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

What it answers

What the tool's description says.

Example

await client.laboratory.labRestoreOrphan({ orphan: "…", action: "…" })

orphansList#

Read the laboratories the list does not name · tool orphans_list

scope: readplan: freesince 1.0.0

Answers each laboratory on disk that the workspace's list does not name - its uri, how many of its workbenches read, its own words when it does not read, the laboratory its recording already has and what can be done with it (restore, or move and remove) - and whether a one-time adoption is offered.

Declaration

client.laboratory
orphansList(): Promise<any>

It takes no arguments.

Returns

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

What it answers

Answers each laboratory on disk that the workspace's list does not name - its uri, how many of its workbenches read, its own words when it does not read, the laboratory its recording already has and what can be done with it (restore, or move and remove) - and whether a one-time adoption is offered.

Example

await client.laboratory.orphansList()

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