Bentrix Docs
HomePricingDashboard

A model Bentrix runs for you

A Python file in your models folder that Bentrix runs at each close of its interval, in a process of its own, with your own interpreter.

01The file

Put a .py file in your models folder (its path is on Settings › Forecast). It declares one model:

import bentrix

@bentrix.model(name="drift", interval="M15", frames=["M15", "H1"], lookback=64, steps=4, form="line")
def predict(window):
    closes = window.close(window.symbol, "M15")
    drift = (closes[-1] - closes[-17]) / 16
    return [{"close": closes[-1] + drift * k} for k in range(1, 5)]

name is its label (lower-case letters, digits and _, up to 32); interval the close it runs at; frames, markets and lookback the window it is handed (the workbench's market alone when markets is left out); steps how many it answers; form the chart type it is drawn as. The function answers a list of steps — each a number (the close) or a dict with open, high, low, close, bands, quantiles, samples — or None to say nothing at this close.

02Starting it

From the chart. Right-click the chart of the market you want it on and choose Run a model…. A window lists the models in your models folder — each Python file that declares a model, and each ONNX model's folder. Press Run beside one: it starts on this chart's workbench and market, and its row then says Running. If the folder is empty, the window says so and Open the models folder opens it; put a file in, then press Refresh. A model an assistant installed waits for your tick in Settings › Forecast before it can run.

From a program or an assistant. model_start does the same, naming the file and the market. Bentrix finds your own Python the way it does for your indicators, writes the small bentrix package the file imports, and runs the file in a process of its own, isolated: nothing beside the file is imported, and no Bentrix variable is passed to it, so a model cannot pair itself with Bentrix.

03What happens at each close

At each close of its interval the model is handed the window cut at that close — nothing later — and its answer is put as its forecast when the answer comes back, stamped at the workbench's clock then. A slow model arrives late exactly as a live program would, so the record of a model Bentrix runs is the record it would have live.

A model that has not answered within five seconds is counted late, and its answer still lands when it comes. One that stops answering for a minute, dies, or answers something that is not a forecast is ended, and its legend row and its state say why.

Pause and Resume are on its legend row: a paused model is asked nothing until resumed. Settings › Forecast lists every model running, with its market, state, runs and late answers.

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