For AI›Gym

Train a learning agent on a venue that fills.

A reinforcement-learning environment over any laboratory workbench: observations of the closed candles and the account, three kinds of action, eight rewards, episodes drawn by seed — and every step filled by the same venue a person trades on.

3
action kinds
8
rewards
9
languages
Gymillustration
The Gym's loop: observe the closed candles, act, the venue fills with its costs, and the reward comes back.

Gym

What it does, part by part.

The loop

Observe, act, fill, reward

env_reset starts an episode; env_step takes an action, moves the clock to the next close and answers the observation, the reward and whether the episode ended — the shape every learning library expects.

  • Discrete, continuous or order actions
  • Ruin ends an episode; its end truncates it
  • Up to 64 environments at once
  • Plus an environment through the application
In the Docs
Sixty-four environments stepped together, and the three kinds of action.

Honest fills

A policy cannot learn a fill that does not exist

Every action is an order on the simulated venue — spread, commission, swap, the volume step and the stops level — and the observation holds only closed candles, so look-ahead is impossible.

  • Eight rewards, from P&L to the differential Sharpe
  • A participation cap and an impact charge, as a setting
  • Refused orders said, never changed into others
In the Docs
Only what is left of the clock.

Seeds and the ledger hash

Every episode can be checked

An episode's start is drawn from its seed, the same on every machine; the same seed and the same actions give the same deals, and the ledger hash proves it.

  • Window, session or tape episodes
  • A curriculum of lengthening episodes
  • Your own sampler of starts
In the Docs
Two equal runs and one different.

With your library

Gymnasium, Stable-Baselines3, or your own

In Python the environment is a Gymnasium environment; in the other eight languages it is the same calls. Train PPO, or write Q-learning in a page, and test on seeds the training never saw.

  • bentrix.gym.TradingEnv
  • Evaluate by the interquartile mean
  • A labelled dataset for supervised models
In the Docs
A training curve.

In code

One episode

Make an environment over the selected workbench, run one episode to its end — in each of the nine languages.

state = client.workspace.get_state(depth="benches")
bench = state["selected"]
made = client.strategy.env_make(bench, episode_bars=24, interval="H1", reward="pnl@1", window=8)
env = made["env"]
now = client.strategy.env_reset(env, seed=7)
total = 0.0
for _ in range(1000):
    now = client.strategy.env_step(env, 1)
    r = now["reward"]
    total += r
    if now["terminated"] or now["truncated"]: break
print("total reward:", total)

How it works

Four steps, in order.

  1. Give it a workbenchA laboratory workbench of its own.
  2. Make the environmentInterval, window, actions, reward, episodes.
  3. TrainIn any language, or with Gymnasium.
  4. Test honestlyOn seeds and windows it never saw.

Packages

Learn on Free. Trade on Plus. Build on Pro.

What each package holds of this page. While the beta lasts, Plus and Pro are free to take: you choose your package on your account page, with no payment.

On this pageFreePlusPro
Environments at once, through the application—1∞

∞ is no limit. What exceeds a package is locked, never deleted.Every package side by side

Good to know

What to expect, plainly.

A laboratory instrument

A reward is a training signal. Nothing an agent does here is ranked or published.

Rewinds its workbench

Each episode rewinds the workbench and undoes its deals; give the environment a workbench of its own.

A model is a model

A policy that did well on history has done well on history. The Docs show how to evaluate it honestly.

Bentrix is in beta. Plus and Pro are free to take.

One download for Windows. Choose your package on your account page, with no payment, while the beta lasts; a feature of Plus or Pro carries its badge in the application, so nothing changes by surprise.