Bentrix Docs
HomePricingDashboard

Julia: strategies

Every method of client.strategy in the Julia SDK.

batch_get#

Read a batch · tool batch_get

scope: readplan: freesince 1.12.0

Reads a batch: how many of its cells settled, each cell's figures and where it stands (queued, arming, running, ended with its run, refused or not started with why), and the path of its record once every cell settled; then too its statistics against chance - for the cell with the highest net, the probabilistic and deflated Sharpe ratio, the minimum backtest length and the Harvey-Liu haircut over every trial the ledger counts for the strategy, the probability of backtest overfitting over the cells, the interquartile mean of the cells' nets with a bootstrap interval, the first market's price change as the baseline, and the conventions labelled as such.

Declaration

client.strategy
batch_get(batch)

Parameters

NameTypeWhat it is
batchanyrequiredThe batch's uri (bentrix://batch/<id>).

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

What the tool's description says.

Example

client.strategy.batch_get("…")

batch_stop#

Stop a batch · tool batch_stop

scope: labplan: freesince 1.12.0

Stops a batch: its running cells end as a run's Stop ends them, the cells not yet started are not started, and what settled stays. Answers the batch.

Declaration

client.strategy
batch_stop(batch)

Parameters

NameTypeWhat it is
batchanyrequiredThe batch's uri (bentrix://batch/<id>).

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the batch.

Example

client.strategy.batch_stop("…")

battery_get#

Read the verification battery · tool battery_get

scope: readplan: freesince 1.14.0

Answers this session's verification battery: how many of its workbenches settled, and once all did, each of the sixteen checks — its verdict (pass, fail, measured, not run), what it found in a sentence, and its figures.

Declaration

client.strategy
battery_get()

It takes no arguments.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers this session's verification battery: how many of its workbenches settled, and once all did, each of the sixteen checks — its verdict (pass, fail, measured, not run), what it found in a sentence, and its figures.

Example

client.strategy.battery_get()

battery_run#

Run the verification battery · tool battery_run

scope: labplan: freesince 1.14.0

Runs the sixteen checks of Bentrix's own engine on a laboratory workbench's recording: a reference strategy (EMA 8 crossing EMA 21, hourly) at machine speed on workbenches made alike it — as it is, again, on twice the spread, on one-minute OHLC ticks, over the first half of its days — and scripted orders on three more (a buy and a sell held to the middle of the days, a stop and a limit). Answers as battery_get does; battery_get again until every check is answered: pass, fail, measured or not run, each with its reason and figures.

Declaration

client.strategy
battery_run(bench)

Parameters

NameTypeWhat it is
benchanyrequiredThe laboratory workbench whose recording the battery runs on: bentrix://lab/<lab>/bench/<bench>.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers as battery_get does; battery_get again until every check is answered: pass, fail, measured or not run, each with its reason and figures.

Example

client.strategy.battery_run(bench)

bench_set_automation#

Arm a workbench's automation · tool bench_set_automation

scope: labplan: plussince 1.0.0

Arms or disarms a laboratory workbench's automation — whether a run's intents on it become orders — as the workbench's own switch does. A disarmed run still decides and journals what it would have sent. Answers the switch.

Declaration

client.strategy
bench_set_automation(bench, armed)

Parameters

NameTypeWhat it is
benchanyrequiredThe workbench's uri.
armedanyrequiredWhether a run's intents on it become orders.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "armed": true,
  "bench": "bentrix://lab/lab-1/bench/bench-2"
}

Example

client.strategy.bench_set_automation(bench, true)

env_act#

Act on the market's clock · tool env_act

scope: labplan: plussince 1.14.0

Takes one action in a live environment's episode, at the close it stands at: the position brought to the action's side - a flip closes first, and opens only once the close was sent; on a real account under Confirm the close is proposed in the trade panel for the person's Send. Moves no clock. Answers the refusal in its words and the outcome (sent, awaiting_person, refused); env_observe at the next close gives the reward.

Declaration

client.strategy
env_act(env, action)

Parameters

NameTypeWhat it is
envanyrequired
actionanyrequiredThe action: 0, 1 or 2 for a discrete environment, a number in [-1, 1] for a continuous one, {side, size, stop, target} for an order one.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the refusal in its words and the outcome (sent, awaiting_person, refused); env_observe at the next close gives the reward.

Example

client.strategy.env_act(env, "…")

env_close#

Close an environment · tool env_close

scope: labplan: plussince 1.14.0

Lets an environment go. Its workbench and its deals stay as they are.

Declaration

client.strategy
env_close(env)

Parameters

NameTypeWhat it is
envanyrequired

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "closed": "env-1"
}

Example

client.strategy.env_close("env-1")

env_make#

Make a trading environment · tool env_make

scope: labplan: plussince 1.14.0

Makes a reinforcement-learning environment over a workbench - observations of the closed candles and the account, discrete, continuous or order actions, eight named rewards, tape, window or session episodes (a growing curriculum optional), a modelled participation cap - and answers its id with its observation and action spaces. On a laboratory workbench env_reset starts an episode, env_step takes an action, run_episode runs a list; the workbench is rewound at each reset, its deals undone, so give it one of its own. On a paper or REAL workbench the clock is the market's: env_reset at a close, env_act, then env_observe at the next close. Env_close lets it go.

Declaration

client.strategy
env_make(bench; action = nothing, deadband = nothing, episode = nothing, episode_bars = nothing, follow = nothing, growing = nothing, impact = nothing, interval = nothing, lots = nothing, max_points = nothing, max_steps = nothing, participation = nothing, reward = nothing, ruin = nothing, symbol = nothing, window = nothing)

Parameters

NameTypeWhat it is
benchanyrequiredThe workbench's uri. A laboratory workbench is rewound at each reset, its deals undone — give it one of its own; a paper or REAL one runs on the market's clock (env_act, env_observe).
actionanyoptionalDiscrete (0 flat, 1 long, 2 short; the default), continuous (a target in [-1, 1]) or order (side, size, stop and target in points).
deadbandanyoptionalA continuous action's flat zone, by default 0.1.
episodeanyoptionalTape (the whole days), window (episode_bars candles from the seed's draw; the default) or session (one day).
episode_barsanyoptionalA window episode's candles, by default 200.
followanyoptionalFollow a clock someone else moves rather than drive it — a paper or REAL workbench always does; a laboratory one may (a replay the person plays, acted on at each close): no rewind, env_act and env_observe.
growinganyoptionalA curriculum: window episodes lengthening from first to last candles over over episodes.
impactanyoptionalWith participation: the reward charged impact x units / the candle's volume - never the account.
intervalanyoptionalThe interval a step lasts (M1 to W1), by default H1.
lotsanyoptionalThe lots a whole position holds, by default 0.01.
max_pointsanyoptionalAn order action's largest stop or target, in points, by default 10000.
max_stepsanyoptionalOn a live workbench: the steps after which an episode is truncated.
participationanyoptionalA modelled participation cap: an order's units at most this share of the last closed candle's volume, in (0, 1].
rewardanyoptionalThe reward plugin, by default dsr_dd_penalty@1.
ruinanyoptionalThe share of the opening equity at or below which an episode ends in ruin, by default 0.5.
symbolanyoptionalThe market, by default the workbench's first.
windowanyoptionalThe closed candles an observation holds, by default 32.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "action_space": {
    "kind": "discrete",
    "meaning": [
      "flat",
      "long",
      "short"
    ],
    "n": 3
  },
  "env": "env-1",
  "first_ms": 1790812800000,
  "interval": "H1",
  "last_ms": 1793491200000,
  "length_ms": 3600000,
  "live": false,
  "observation_space": {
    "account": {
      "dtype": "float32",
      "meaning": "side, log equity ratio to the episode's start, open profit over the opening equity",
      "shape": [
        3
      ]
    },
    "market": {
      "dtype": "float32",
      "meaning": "open, high, low, close as log ratios to the last close",
      "shape": [
        8,
        4
      ]
    }
  },
  "reward": "dsr_dd_penalty@1",
  "symbol": "SYN-DOCS"
}

Example

client.strategy.env_make(bench)

env_observe#

Observe at a close · tool env_observe

scope: labplan: plussince 1.14.0

Answers where an environment's episode stands at the close at_ms: the observation, the reward of the move since the last env_act, terminated (ruin), truncated (no candle closed, or the episode's steps) and info. On a live workbench it follows env_act at each close; on a laboratory workbench standing at at_ms it reads the observation a laboratory step would.

Declaration

client.strategy
env_observe(env, at_ms; moved = nothing)

Parameters

NameTypeWhat it is
envanyrequired
at_msanyrequiredThe close the workbench stands at.
movedanyoptionalFalse when no candle closed since the last observation (the market said nothing): the episode is truncated.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers where an environment's episode stands at the close at_ms: the observation, the reward of the move since the last env_act, terminated (ruin), truncated (no candle closed, or the episode's steps) and info.

Example

client.strategy.env_observe(env, 1)

env_reset#

Start an episode · tool env_reset

scope: labplan: plussince 1.14.0

Starts an environment's next episode. In the laboratory the workbench is rewound to its start with its deals undone, then advanced as Play would to the episode's start (the tape's first hour after the warm-up, a window the seed draws or start_ms gives, or a session's day); on a live workbench nothing moves and the episode starts at at_ms. Answers the observation and info (the reward's name, the ledger hash, the start, the end, the opening equity).

Declaration

client.strategy
env_reset(env; at_ms = nothing, bars = nothing, seed = nothing, start_ms = nothing)

Parameters

NameTypeWhat it is
envanyrequiredThe environment, as env_make answered it.
at_msanyoptionalOn a live workbench: the close the market last reached, where the episode starts.
barsanyoptionalWith start_ms: the episode's candles.
seedanyoptionalThe seed: given, the episode draws start over from it; absent, the next episode of the last seed.
start_msanyoptionalA window episode's start, chosen by a person's own sampler instead of the seed's draw.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "info": {
    "end_ms": 1792828800000,
    "episode_index": 0,
    "ledger_hash": "e3b0c44298fc1c149afbf4c8996fb92427ae41e4649b934ca495991b7852b855",
    "opening": 10000.0,
    "reward": "dsr_dd_penalty@1",
    "start_ms": 1792785600000
  },
  "obs": {
    "account": [
      0.0,
      0.0,
      -0.0
    ],
    "market": [
      [
        0.001366929616779089,
        0.003762140404433012,
        0.0010633289348334074,
        0.002853242214769125
      ],
      [
        0.002873448887839914,
        0.004236459266394377,
        0.0013568111462518573,
        0.0013568111462518573
      ],
      [
        0.001366929616779089,
        0.0019536297768354416,
        0.0011341773206368089,
        0.0017311288975179195
      ],
      "… 5 more"
    ]
  }
}

Example

client.strategy.env_reset("env-1")

env_step#

Take an action · tool env_step

scope: labplan: plussince 1.14.0

Takes one action in a laboratory environment's episode: the position brought to the action's side through the workbench's venue (refused in its words, never clipped into another), then the workbench advanced to the interval's next close. Answers the observation, the reward, terminated (ruin), truncated (the episode's or the tape's end) and info (the ledger hash, the refusal, the equity, the cursor, the participation it was cut to).

Declaration

client.strategy
env_step(env, action)

Parameters

NameTypeWhat it is
envanyrequired
actionanyrequiredThe action: 0, 1 or 2 for a discrete environment, a number in [-1, 1] for a continuous one, {side, size, stop, target} for an order one.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "info": {
    "cursor_ms": 1791154800000,
    "equity": 9998.23,
    "ledger_hash": "db865d84c5c5875ec1bf7ef2d5ba0b26ec224518c9cb1e88270286b61fed3962",
    "refused": null,
    "reward": "dsr_dd_penalty@1"
  },
  "obs": {
    "account": [
      1.0,
      -0.0001770156668499112,
      -0.00017499999376013875
    ],
    "market": [
      [
        0.004607579670846462,
        0.005970589816570282,
        0.003090942045673728,
        0.003090942045673728
      ],
      [
        0.003101060399785638,
        0.0036877605598419905,
        0.0028683082200586796,
        0.0034652596805244684
      ],
      [
        0.0034753745421767235,
        0.0034753745421767235,
        0.0021494701504707336,
        0.0021595980506390333
      ],
      "… 5 more"
    ]
  },
  "reward": 0.0,
  "terminated": false,
  "truncated": false
}

Example

client.strategy.env_step("env-1", 1)

ledger_query#

Read the trial ledger · tool ledger_query

scope: readplan: freesince 1.14.0

Reads the trial ledger: every run, batch cell and re-run written before its result was shown, and each result after it, in order - sequence number, wall clock, kind (trial or result), body (strategy, version, digest, tick model, span start, the batch and its figures; or of, trades and net; or an external family's name, count and description) and the hash chain. With strategy, that strategy's trials and their results only, and trials counts them (the N a multiple-testing correction needs). Always answers union, every trial the ledger holds (a run one, an external line its count), and families, each family's and strategy's count. Says where the chain stops following, if it does. The ledger has no door that removes a line.

Declaration

client.strategy
ledger_query(; from_seq = nothing, limit = nothing, strategy = nothing)

Parameters

NameTypeWhat it is
from_seqanyoptionalThe first line to answer (its sequence number); omitted, from the first.
limitanyoptionalHow many lines at most; omitted, 500.
strategyanyoptionalA strategy, by its name as every other tool takes it (rsi pullback) or its stem (its file name, rsi_pullback), to read that strategy's trials and their results only.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

What the tool's description says.

Example

client.strategy.ledger_query()

ledger_record#

Record trials tried outside a run · tool ledger_record

scope: labplan: freesince 1.17.0

Appends to the trial ledger a family of candidates tried in the person's own code - an event study's cells, a grid searched outside Bentrix - as one line with its count, before any of its result exists (kind trial: family, count, description, digest); or what came of such a trial (kind result: of, result). The family's count joins the ledger's union, the N a correction across everything tried takes, and never leaves it: the ledger has no door that removes a line. A run's own trials are Bentrix's to write and are refused here. Answers the line's sequence number, the family's count and the union.

Declaration

client.strategy
ledger_record(kind; count = nothing, description = nothing, digest = nothing, family = nothing, of = nothing, result = nothing)

Parameters

NameTypeWhat it is
kindanyrequiredtrial: a family of candidates tried outside a run, written before any of its result exists. result: what came of an earlier external trial.
countanyoptionalTrial: how many candidates this line adds to the family, 1 to 10,000,000.
descriptionanyoptionalTrial: what was tried, in words, at most 4,000 characters.
digestanyoptionalTrial: a digest of the pre-registration, at most 128 characters.
familyanyoptionalTrial: the family's name, letters, digits, _, - and ., at most 64.
ofanyoptionalResult: the sequence number of the external trial it answers.
resultanyoptionalResult: what came of it, an object of at most 64 KiB.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the line's sequence number, the family's count and the union.

Example

client.strategy.ledger_record("…")

optimisation_import#

Import a MetaTrader optimisation · tool optimisation_import

scope: labplan: freesince 1.14.0

Reads a MetaTrader optimisation's results table (Pass, Result or Profit, Sharpe Ratio, Trades, and the expert's inputs), writes every pass to the trial ledger as a trial of name with its result, and judges the best pass (the highest Sharpe ratio) over the ledger's N for that name: its probabilistic and deflated Sharpe ratio and the Harvey-Liu haircut. The table carries no return series, so the sample is the pass's trades with a normal's skew and kurtosis, said, and PBO is not computed, said. The Strategies panel's Import optimisation results draws the same.

Declaration

client.strategy
optimisation_import(name, table)

Parameters

NameTypeWhat it is
nameanyrequiredThe expert's name: what its passes are counted under in the trial ledger.
tableanyrequiredThe optimiser's exported table: its Export to XML file's text, or the table as CSV or tab-separated text with its header row.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

What the tool's description says.

Example

client.strategy.optimisation_import("…", "…")

run_episode#

Run an episode · tool run_episode

scope: labplan: plussince 1.14.0

Resets a laboratory environment (with the seed when given) and takes the actions in turn until the episode ends or they run out. Answers each step's reward, refusal and equity, the steps taken, whether it terminated or was truncated, and the ledger hash.

Declaration

client.strategy
run_episode(env, actions; seed = nothing)

Parameters

NameTypeWhat it is
envanyrequired
actionsanyrequiredThe actions, taken in turn until the episode ends or they run out.
seedanyoptional

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers each step's reward, refusal and equity, the steps taken, whether it terminated or was truncated, and the ledger hash.

Example

client.strategy.run_episode(env, "…")

run_get#

Read a run · tool run_get

scope: readplan: freesince 1.0.0

A run's state, its counts, and once it has ended its manifest: the tester report MetaTrader's tester shows, the trades and the equity samples.

Declaration

client.strategy
run_get(run)

Parameters

NameTypeWhat it is
runanyrequiredThe run's uri.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "bench": "bentrix://lab/lab-1/bench/bench-2",
  "counts": {
    "candles": 473,
    "emitted": 2,
    "held_back": 0,
    "not_armed": 0,
    "refused": 0,
    "sent": 2
  },
  "manifest": {
    "armed": true,
    "bench": "Laboratory(LaboratoryId(1)) / bench-2",
    "conditions": {
      "build": "0.1.382+d7ec1b8",
      "cost_edition": "BENTRIX standard costs 2026.1",
      "costs": {},
      "currency": "USD",
      "data": [
        {
          "m1_months": 1,
          "m1_sha256": "d1d4fdd94b1c927d202e9ef4a32f96454be073d7e192179c7a0ce25d15403f44",
          "market": "SYN-DOCS",
          "tick_bytes": 2498934,
          "tick_days": 26,
          "tick_list_sha256": "635122d183d4dba8218133ef30067c18c2cf2e0e7976f9ec9e2fbf3781102d3d"
        },
        {
          "m1_months": 1,
          "m1_sha256": "59de407e183966b0d79280d26f5083ad0b4c4d2d339a23f112ecc1a57fe3d811",
          "market": "SYN-DOCS2",
          "tick_bytes": 4181811,
          "tick_days": 26,
          "tick_list_sha256": "076c16d51e91b0c38bd4281efb403ea14a16dc10ad7e97f74f82d3aa0d929c4a"
        }
      ],
      "document": {
        "entry": {
          "cancel_on_opposite": false,
          "expires_candles": null,
          "from": null,
          "kind": "market",
          "limit_offset": null,
          "offset": null
        },
        "exits": {
          "breakeven": null,
          "first_target": null,
          "stop": {
            "atr": {
              "study": "atr",
              "times": 1.5
            }
          },
          "target": {
            "r": 2.0
          },
          "trail": null
        },
        "interval": "H1",
        "limits": {
          "max_bars": null,
          "max_open": null,
          "one_position_per_market": true,
          "per_day": null
        },
        "made_by": "agent",
        "made_ms": 0,
        "markets": [
          "SYN-DOCS"
        ],
        "name": "docs rsi",
        "notes": "",
        "rules": {
          "buy": {
            "all": [
              {
                "cond": "rsi:level.cross_up:30"
              },
              {
                "compare": {
                  "above": [
                    "price.close",
                    "ema200"
                  ]
                }
              }
            ]
          },
          "close_buys": {
            "any": [
              {
                "compare": {
                  "cross_down": [
                    "rsi",
                    50.0
                  ]
                }
              },
              {
                "bars_in_trade": 48
              }
            ]
          },
          "close_sells": {
            "any": [
              {
                "compare": {
                  "cross_up": [
                    "rsi",
                    50.0
                  ]
                }
              },
              {
                "bars_in_trade": 48
              }
            ]
          },
          "sell": {
            "all": [
              {
                "cond": "rsi:level.cross_down:70"
              },
              {
                "compare": {
                  "below": [
                    "price.close",
                    "ema200"
                  ]
                }
              }
            ]
          }
        },
        "schema": 1,
        "sessions": {
          "desks": [],
          "flat_at": null,
          "window": null
        },
        "sizing": {
          "mode": "lots",
          "value": 0.1
        },
        "studies": {
          "atr": {
            "applied": "close",
            "convention": "mt5",
            "kind": "atr",
            "settings": {
              "period": 14,
              "shape": "period"
            }
          },
          "ema200": {
            "applied": "close",
            "convention": "talib",
            "kind": "ema",
            "settings": {
              "period": 200,
              "shape": "period"
            }

Example

client.strategy.run_get(run)

run_parity#

Compare a run with another engine's trades · tool run_parity

scope: readplan: freesince 1.14.0

Compares an ended run's closed trades with a trade list another engine produced - MetaTrader's tester, another backtester, an earlier run - each put in one canonical form (one line a closed trade: close time in ms, L or S, net at two decimals, in closing order) and hashed with sha256. Answers both hashes and counts, whether they are one list, and the first trade where they part with each side's line. Times are compared as each list writes them. The Run window's Validation tab draws the same.

Declaration

client.strategy
run_parity(run, list)

Parameters

NameTypeWhat it is
runanyrequiredThe run's uri.
listanyrequiredThe other engine's trade list, as its file's text: a JSON list of trades (time_ms or time, long or side, net or profit with commission and swap), a Bentrix run.json, or a CSV with a header naming those columns (a deals report's Direction column keeps its out rows).

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers both hashes and counts, whether they are one list, and the first trade where they part with each side's line.

Example

client.strategy.run_parity(run, "…")

run_pause#

Pause a run · tool run_pause

scope: labplan: plussince 1.0.0

Hands a running run's clock back to the person at the end of its candle, as Pause does. Answers the run.

Declaration

client.strategy
run_pause(run)

Parameters

NameTypeWhat it is
runanyrequiredThe run's uri.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the run.

Example

client.strategy.run_pause(run)

run_resume#

Resume a run · tool run_resume

scope: labplan: plussince 1.0.0

Continues a paused run from wherever its workbench's clock now stands, as Resume does. Answers the run.

Declaration

client.strategy
run_resume(run)

Parameters

NameTypeWhat it is
runanyrequiredThe run's uri.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the run.

Example

client.strategy.run_resume(run)

run_robustness#

Test a run's robustness · tool run_robustness

scope: readplan: freesince 1.14.0

Tests how robust an ended run of this session is, over its trades read with their entries, every draw from one fixed seed: the maximum drawdown over the trades drawn again in another order, the net with a tenth of the trades left out, the net with each trade's fill degraded by up to a tenth of the median absolute trade net (each as 5th, 50th and 95th percentiles of 1,000 draws); the random-entry percentile (the share of random draws - as many trades, each held as long as one of the run's, at a random minute in a random direction on its first market - whose sum of price moves is below the run's); and its trades, net and wins under the quiet, middle and busy days; and its metrics - Van Tharp's SQN, expectancy and its parts, the longest drawdown duration and the market's own trading days a year. Each with its definition; kept as robustness.json beside the run's run.json. The Run window's Validation tab draws the same.

Declaration

client.strategy
run_robustness(run)

Parameters

NameTypeWhat it is
runanyrequiredThe run's uri.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

What the tool's description says.

Example

client.strategy.run_robustness(run)

run_set_pace#

Change a run's pace · tool run_set_pace

scope: labplan: plussince 1.0.0

Switches a run between machine speed and the replay's pace at the cursor, as the Run window's pace does. Answers the run.

Declaration

client.strategy
run_set_pace(run, pace)

Parameters

NameTypeWhat it is
runanyrequired
paceanyrequired

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the run.

Example

client.strategy.run_set_pace(run, "…")

run_stop#

Stop a run · tool run_stop

scope: labplan: plussince 1.0.0

Ends a run at the end of its candle, as the Run window's Stop does; Stop is never refused while a run runs or waits paused. Answers the run.

Declaration

client.strategy
run_stop(run)

Parameters

NameTypeWhat it is
runanyrequiredThe run's uri.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the run.

Example

client.strategy.run_stop(run)

stats_family_test#

Test a family of candidates against chance · tool stats_family_test

scope: readplan: freesince 1.17.0

Tests a family of candidates against a benchmark at once, from each candidate's performance less the benchmark's period by period: Hansen's test for superior predictive ability (the consistent p-value, with the liberal one and the conservative one, which is White's reality check) and each candidate's Romano-Wolf stepdown adjusted p-value, over one stationary bootstrap drawn the same for every candidate. The same series and seed give the same answer. Pure arithmetic: reads and writes nothing; a family larger than candidates x periods x resamples = 200,000,000 is refused with its size.

Declaration

client.strategy
stats_family_test(series; mean_block = nothing, resamples = nothing, seed = nothing)

Parameters

NameTypeWhat it is
seriesanyrequiredEach candidate's performance less the benchmark's, period by period (larger is better), every row the same length: one row a candidate.
mean_blockanyoptionalThe stationary bootstrap's mean block length in periods; omitted, 10.
resamplesanyoptionalBootstrap resamples; omitted, 1,000; at most 20,000.
seedanyoptionalThe bootstrap's seed (the same seed, the same answer); omitted, 1.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

What the tool's description says.

Example

client.strategy.stats_family_test("…")

batch#

Run a strategy over a grid of its figures · tool strategy_batch

scope: labplan: freesince 1.12.0

Runs a saved strategy once per combination of the grid's values, each cell on a workbench of its own made over every condition of the given laboratory workbench (stretch, markets, zone, account, costs) and run from its first moment at machine speed, at most workers at once. A cell the validator refuses is said by field and never run; a batch past Largest batch is refused with the number. Two figures vary the cells' benches rather than the document: tick_model (real, every-tick, ohlc-m1, open-only) and spread_multiplier (numbers above zero, 1 as recorded); a settled batch's record compares the results under each, with a sign-flip flag. With dry, answers the cells and the estimate and makes nothing. Answers the batch's uri; batch_get reads its cells and their runs.

Declaration

client.strategy
batch(strategy, bench, grid; dry = nothing, version = nothing, workers = nothing)

Parameters

NameTypeWhat it is
strategyanyrequiredThe saved strategy's name.
benchanyrequiredThe laboratory workbench whose conditions every cell's own bench copies.
gridanyrequiredEach figure the batch varies, by its path in the document (studies.fast.settings.period, sizing.value, a script's script.inputs.<title>), and the values it takes.
dryanyoptionalPlan only: the cells and the estimate, nothing made.
versionanyoptionalA version; the latest when absent.
workersanyoptionalHow many cells run at once; the computer's cores less two when absent.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the batch's uri; batch_get reads its cells and their runs.

Example

client.strategy.batch(strategy, bench, "…")

get#

Read strategies · tool strategy_get

scope: readplan: freesince 1.0.0

Lists the person's strategies with their versions, or reads one version of one — the latest when none is named — as the file holds it.

Declaration

client.strategy
get(; name = nothing, version = nothing)

Parameters

NameTypeWhat it is
nameanyoptionalThe strategy's name; absent lists every strategy with its versions.
versionanyoptionalA version; the latest when absent.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "strategies": [
    {
      "name": "docs rsi",
      "unreadable": 0,
      "versions": [
        1
      ]
    }
  ]
}

Example

client.strategy.get()

run#

Run a strategy · tool strategy_run

scope: labplan: plussince 1.0.0

Runs a saved strategy version on a laboratory workbench from its cursor, as the Run sheet does — one run per workbench; on a paper workbench at the market's own pace only (pace: replay); on a real account's workbench (with real) the person allows it on a card first, and every order follows the account's Automations mode - answered as a job. Its intents become orders only while the workbench's automation is armed (bench_set_automation). Answers the run's uri; run_get reads it, and its tester report once it ends.

Declaration

client.strategy
run(strategy, bench; pace = nothing, version = nothing)

Parameters

NameTypeWhat it is
strategyanyrequiredThe saved strategy's name.
benchanyrequiredThe laboratory workbench it runs on, from its cursor.
paceanyoptional
versionanyoptionalA version; the latest when absent.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "bench": "bentrix://lab/lab-1/bench/bench-2",
  "counts": {
    "candles": 0,
    "emitted": 0,
    "held_back": 0,
    "not_armed": 0,
    "refused": 0,
    "sent": 0
  },
  "manifest": null,
  "pace": "machine",
  "state": "running",
  "uri": "bentrix://run/2990368"
}

Example

client.strategy.run("docs rsi", bench)

save#

Save a strategy · tool strategy_save

scope: labplan: plussince 1.0.0

Saves a strategy document as its next version — version 1 for a new name — validated first, never over a file; a document the latest version already says is not written again. Answers the version, its digest and the validation.

Declaration

client.strategy
save(document)

Parameters

NameTypeWhat it is
documentanyrequiredThe strategy document, as bentrix://strategy/schema describes it.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "digest": "bd74f65d1a4641b3eca93ccd8df3e303de223a63522baa90def8adb99ffdf49a",
  "name": "docs rsi",
  "validation": {
    "refusals": [],
    "runnable": true,
    "warnings": []
  },
  "version": 1,
  "written": true
}

Example

client.strategy.save("…")

validate#

Validate a strategy · tool strategy_validate

scope: readplan: freesince 1.0.0

Validates a strategy document as the editor does, field by field: whether it can run, what refuses it and what is only warned. Saves nothing.

Declaration

client.strategy
validate(document)

Parameters

NameTypeWhat it is
documentanyrequiredThe strategy document, as bentrix://strategy/schema describes it.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

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

{
  "refusals": [],
  "runnable": true,
  "warnings": []
}

Example

client.strategy.validate("…")

walkforward#

Walk a strategy forward · tool strategy_walkforward

scope: labplan: freesince 1.14.0

Cuts the workbench's days into windows of in_sample_days and the out_of_sample_days after them (anchored: every in-sample stretch starts at the first day; rolling: the in-sample days before), and for each window in turn runs the grid as a batch over its in-sample days, chooses the cell with the highest in-sample net, and runs it as chosen over the out-of-sample days on a bench whose days begin at the in-sample start. Every cell and every out-of-sample run is a trial in the ledger, naming the walk and the window. Answers the walk's uri; walk_get reads its windows and, once ended, its record.

Declaration

client.strategy
walkforward(strategy, bench, grid, in_sample_days, out_of_sample_days, mode; version = nothing, workers = nothing)

Parameters

NameTypeWhat it is
strategyanyrequiredThe saved strategy's name.
benchanyrequiredThe laboratory workbench whose days are walked and whose conditions every bench copies.
gridanyrequiredEach figure the in-sample batches vary, by its path, and its values (strategy_batch's grid; never tick_model).
in_sample_daysanyrequiredDays of each in-sample stretch.
out_of_sample_daysanyrequiredDays of each out-of-sample stretch.
modeanyrequiredAnchored (every in-sample stretch starts at the first day) or rolling (the days before).
versionanyoptionalA version; the latest when absent.
workersanyoptionalHow many in-sample cells run at once; the computer's cores less two when absent.

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the walk's uri; walk_get reads its windows and, once ended, its record.

Example

client.strategy.walkforward(strategy, bench, "…", 1, 1, "…")

walk_get#

Read a walk-forward run · tool walk_get

scope: readplan: freesince 1.14.0

Answers a walk-forward run as it stands: each window's in-sample and out-of-sample stretches, its batch, the figures chosen and their in-sample net, the out-of-sample trades and net, and the efficiency (out-of-sample net a day over in-sample net a day, where the in-sample net is above zero); the out-of-sample total; and once every window settled, where its record was written.

Declaration

client.strategy
walk_get(walk)

Parameters

NameTypeWhat it is
walkanyrequiredThe walk's uri (bentrix://walk/<id>).

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers a walk-forward run as it stands: each window's in-sample and out-of-sample stretches, its batch, the figures chosen and their in-sample net, the out-of-sample trades and net, and the efficiency (out-of-sample net a day over in-sample net a day, where the in-sample net is above zero); the out-of-sample total; and once every window settled, where its record was written.

Example

client.strategy.walk_get("…")

walk_stop#

Stop a walk-forward run · tool walk_stop

scope: labplan: freesince 1.14.0

Stops a walk-forward run as its Stop does: the window's in-sample batch or out-of-sample run stopped, the windows not reached failed as stopped; what settled stays. Answers the walk as walk_get does.

Declaration

client.strategy
walk_stop(walk)

Parameters

NameTypeWhat it is
walkanyrequiredThe walk's uri (bentrix://walk/<id>).

Returns

Dict{String,Any} — the tool’s answer as a Dict.

What it answers

Answers the walk as walk_get does.

Example

client.strategy.walk_stop("…")

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