Bentrix Docs
HomePricingDashboard

Rust: data

Every method of client.data() in the Rust SDK.

bars_get#

Read a workbench's bars · tool bars_get

scope: readplan: freesince 1.0.0

Answers a workbench's bars of one market and interval, up to its cursor and never past it, the same candles its chart draws: the newest limit bars (at most 5000) before before_ms, oldest first. Earlier_before_ms asks for the page before.

Declaration

client.data()
pub fn bars_get(&self, args: DataBarsGetArgs) -> Result<Value

Parameters

NameTypeWhat it is
benchimpl Into<String>requiredThe workbench's uri, as get_state gives it.
symbolimpl Into<String>requiredOne of the workbench's markets.
timeframeimpl Into<String>requiredAn interval's label: M1, H4, D1, a custom one such as M95.
before_msi64optionalOnly bars that opened before this instant (UTC milliseconds) — the page before a page.
limiti64optionalHow many, newest first counted, at most 5000.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

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

{
  "bars": [
    [
      1791878400000,
      0.96726,
      0.96759,
      0.96623,
      0.96722,
      1411,
      9
    ],
    [
      1791882000000,
      0.96721,
      0.96763,
      0.96661,
      0.9674,
      1039,
      10
    ],
    [
      1791885600000,
      0.96741,
      0.96811,
      0.96712,
      0.96743,
      1002,
      10
    ],
    "… 2 more"
  ],
  "columns": [
    "time_ms",
    "open",
    "high",
    "low",
    "close",
    "tick_volume",
    "spread_points"
  ],
  "cursor_ms": 1791892903523,
  "earlier_before_ms": 1791878400000,
  "last_forming": true,
  "symbol": "SYN-DOCS",
  "timeframe": "H1"
}

Example

client.data().bars_get(mcp::DataBarsGetArgs::new(bench.clone(), "SYN-DOCS", "H1"))?

bars_window#

Read several markets and frames at one instant · tool bars_window

scope: readplan: freesince 3.3.0

Answers the closed bars of several of a workbench's markets in several frames (1-16: intervals, or a chart's elements as {chart}) cut at ONE instant: the cursor, or aligned_to an interval's last close, so every frame ends where that bar ended. A bar is a row when it closed at or before the cut; the newest limit rows per frame (200 when omitted, at most 5000; symbols x frames x limit at most 200000), oldest first, in columns time_ms, open, high, low, close, tick_volume, spread_points; nothing past the cursor. Include_forming hands an interval's forming bar beside its rows. A frame not ready refuses the call by name unless partial, which answers what is ready and lists not_ready. Zone cuts every interval frame in a time zone of the caller's choosing (a day at its midnight, H4 on its grid), folded from the workbench's finer candles, the screen untouched; time_ms stays the workbench's own stamps. The input a forecasting model reads.

Declaration

client.data()
pub fn bars_window(&self, args: DataBarsWindowArgs) -> Result<Value

Parameters

NameTypeWhat it is
benchimpl Into<String>requiredThe workbench's uri, as get_state gives it.
framesimpl Into<Value>requiredThe frames, 1 to 16: intervals' labels, or {"chart": uri} for a chart's elements.
aligned_toimpl Into<String>optionalWhere every frame is cut: "cursor" (the default), or an interval's label — that interval's last close.
include_formingbooloptionalTrue hands each interval's bar still forming beside its rows, marked forming; it is never a row.
limiti64optionalClosed bars per frame per market, newest kept: 200 when omitted, at most 5000. Symbols × frames × limit is at most 200000.
partialbooloptionalTrue answers what is ready and lists the rest in not_ready; omitted or false, a frame not ready refuses the call.
symbolimpl Into<String>optionalOne market, in place of symbols.
symbolsVec<String>optionalThe markets, 1 to 64, each one of the workbench's.
zoneimpl Into<String>optionalThe time zone every interval frame is cut in, aligned_to read in too: a code from zones_list, an IANA name, system, or display (the workbench's charts' zone). Omitted, the workbench's own cut, as its venue reads it.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

Answers the closed bars of several of a workbench's markets in several frames (1-16: intervals, or a chart's elements as {chart}) cut at ONE instant: the cursor, or aligned_to an interval's last close, so every frame ends where that bar ended.

Example

client.data().bars_window(mcp::DataBarsWindowArgs::new(bench.clone(), "…"))?

calendar_closures#

A banking centre's holiday closures over a span · tool calendar_closures

scope: readplan: freesince 1.20.0

The weekdays a centre's banks are shut between two days, as the clock's holidays computes them from each centre's rule: each closure's date, name, whether it stands in for a weekend holiday (substitute) and whether it is a day no rule gives - moved or declared by a government, from a table (declared). For each year: said (false before the centre's history, where nothing is answered rather than an empty year), and verified (checked against the authority's own list; every other year a projection by rule, blind to a day declared and not in the table). The US and the UK reach back to 2003 (Juneteenth from 2022), T2 to 2002, Japan to 2022, Sydney to 2023.

Declaration

client.data()
pub fn calendar_closures(&self, args: DataCalendarClosuresArgs) -> Result<Value

Parameters

NameTypeWhat it is
centreimpl Into<String>required
fromimpl Into<String>requiredThe first day, YYYY-MM-DD.
toimpl Into<String>requiredThe last day, YYYY-MM-DD; at most 60 years after from.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

What the tool's description says.

Example

client.data().calendar_closures(mcp::DataCalendarClosuresArgs::new("…", "…", "…"))?

chart_elements_get#

Read a chart's elements · tool chart_elements_get

scope: readplan: freesince 1.4.0

Reads the elements a chart built by price or activity (Renko, Range bars, Line break, Point & Figure, Kagi, Volume bars) drew last, up to its cursor, each read as a bar: its candle's open and its ordinal among that candle's elements — the address study_series_put names it by — its open, high, low and close, the volume of the candles it holds, and whether it is still forming. Refused on a chart drawn in time bars, which bars_get reads.

Declaration

client.data()
pub fn chart_elements_get(&self, args: DataChartElementsGetArgs) -> Result<Value

Parameters

NameTypeWhat it is
chartimpl Into<String>requiredThe chart's uri.
limiti64optionalThe newest elements kept (at most 5000; 500 when omitted).

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

What the tool's description says.

Example

client.data().chart_elements_get(mcp::DataChartElementsGetArgs::new(chart.clone()))?

export_bars#

Export a workbench's bars to a file · tool export_bars

scope: readplan: freesince 1.0.0

Writes a workbench's bars of one market and interval, up to its cursor and never past it, as CSV into the export folder set on Settings > Agents, under this agent's name; answers the file's path, uri, rows and bytes, never the rows. For a span too long to read in pages.

Declaration

client.data()
pub fn export_bars(&self, args: DataExportBarsArgs) -> Result<Value

Parameters

NameTypeWhat it is
benchimpl Into<String>requiredThe workbench's uri, as get_state gives it.
symbolimpl Into<String>required
timeframeimpl Into<String>requiredAn interval's label: M1, H4, D1, M95.
from_msi64optionalOnly bars that opened at or after this instant (UTC ms); omitted, every bar held.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

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

{
  "bytes": 58401,
  "columns": [
    "time_ms",
    "open",
    "high",
    "low",
    "close",
    "tick_volume",
    "spread_points"
  ],
  "path": "C:\\Users\\mohaa\\AppData\\Local\\Temp\\bx-docs-answers-11gvyak4\\LocalAppData\\BENTRIX\\exports\\bentrix-python-sdk\\SYN-DOCS-H1-1795453178074.csv",
  "rows": 733,
  "uri": "file:///C:/Users/mohaa/AppData/Local/Temp/bx-docs-answers-11gvyak4/LocalAppData/BENTRIX/exports/bentrix-python-sdk/SYN-DOCS-H1-1795453178074.csv"
}

Example

client.data().export_bars(mcp::DataExportBarsArgs::new(bench.clone(), "SYN-DOCS", "H1"))?

export_ticks#

Export a day of a workbench's ticks to a file · tool export_ticks

scope: readplan: freesince 1.0.0

Writes one market's ticks of one day that have happened at the workbench's cursor, never one past it, as CSV into the export folder under this agent's name; answers the file's path, uri, rows and bytes. Only a day the replay holds in memory is written.

Declaration

client.data()
pub fn export_ticks(&self, args: DataExportTicksArgs) -> Result<Value

Parameters

NameTypeWhat it is
benchimpl Into<String>required
symbolimpl Into<String>required
dayimpl Into<String>optionalThe day, YYYY-MM-DD; omitted, the day at the workbench's cursor.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

What the tool's description says.

Example

client.data().export_ticks(mcp::DataExportTicksArgs::new(bench.clone(), "SYN-DOCS"))?

extract_dataset#

Extract a labelled dataset · tool extract_dataset

scope: readplan: freesince 1.14.0

Writes a workbench's closed candles of one market up to its cursor - never past it, never the one still forming - with triple-barrier labels (the Python SDK's bentrix.data.triple_barrier) as CSV into the export folder under this agent's name: a position entered at the next candle's open (a long at its ask, a short at its bid), a target and a stop in points, a horizon in candles; label 1 the target met first, -1 the stop, 0 neither, and ambiguous where one candle touched both (the stop's). Answers the file's path, uri, rows and bytes.

Declaration

client.data()
pub fn extract_dataset(&self, args: DataExtractDatasetArgs) -> Result<Value

Parameters

NameTypeWhat it is
benchimpl Into<String>required
symbolimpl Into<String>required
timeframeimpl Into<String>requiredThe interval (M1 to W1).
target_pointsf64requiredThe target, in points from the entry.
stop_pointsf64requiredThe stop, in points from the entry.
horizoni64requiredThe candles a position lives.
from_msi64optionalOnly the candles from this open time on.
sideimpl Into<String>optionalLong (the default) or short.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

Answers the file's path, uri, rows and bytes.

Example

client.data().extract_dataset(mcp::DataExtractDatasetArgs::new(bench.clone(), "SYN-DOCS", "H1", 1.0, 1.0, 1))?

extract_windows#

Write training windows · tool extract_windows

scope: readplan: freesince 3.3.0

Writes a window_spec's window at every close of the interval between from_ms and to_ms (the workbench's clock at most) as one CSV in the export folder under this agent's name, in long form - window, close_ms, role (input, or target for the bars of the interval after the close), symbol, frame, then the bar's time_ms, open, high, low, close, tick_volume, spread_points. Every input frame ends where its close is: a bar that closed later, or one still forming, is in no window; a target bar that has not closed by the clock is not written. Stride keeps one window in N. No row bound: the answer says the rows and bytes written.

Declaration

client.data()
pub fn extract_windows(&self, args: DataExtractWindowsArgs) -> Result<Value

Parameters

NameTypeWhat it is
benchimpl Into<String>requiredThe workbench's uri.
specimpl Into<Value>requiredThe window, as window_spec describes it.
from_msi64optionalThe first close written, UTC ms; omitted, the first the history allows a whole window at.
stridei64optionalOne window every stride closes; 1 when omitted.
to_msi64optionalThe last close written, UTC ms, never past the workbench's clock; omitted, the clock.

Returns

Result<Value, Error> — the tool’s answer as a serde_json::Value.

What it answers

What the tool's description says.

Example

client.data().extract_windows(mcp::DataExtractWindowsArgs::new(bench.clone(), "…"))?

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