Skip to content

MngMutateChartCandles

Previews or applies an edit or deletion to a bounded set of stored one-minute candles for one symbol. Use dry_run: true to inspect the selected rows and the revision token before applying a change. The preview never mutates history.

Only closed candles are eligible. Timestamps are Unix seconds in UTC and must be aligned to a minute. The currently forming minute and future minutes are rejected. preview contains at most the first 20 rows; selected and affected describe the complete operation.

This command leaves existing chart commands unchanged. In particular, DeleteChartCandle retains its legacy [open, high, low, close, time, volume] array order.

Access control

Available to SESSION_ADMIN, SESSION_MANAGER, and SESSION_DEALER. Requires the manager access_backoffice scope and set_accounts permission.

Request fields

Field Type Required Description
symbol string Yes Existing symbol whose one-minute history will be changed.
action string Yes update to edit selected candles, or delete to remove them.
selector object Yes Select either exact times or an inclusive from/to range.
selector.times array of int64 Conditional One to 10,000 unique, positive, minute-aligned UTC Unix timestamps in seconds. Each timestamp must identify an existing closed candle. Supported for update and delete.
selector.from int64 Conditional Inclusive range start in positive UTC Unix seconds, minute-aligned. Use with to for range deletion.
selector.to int64 Conditional Inclusive range end in positive UTC Unix seconds, minute-aligned. Use with from for range deletion.
changes object For update Nonempty set of fields to change. Allowed keys: open, high, low, close, and volume. Not accepted for delete.
changes.<field>.mode string For each changed field set, add, or percent. Every operation uses the original field value. percent computes original * (1 + value / 100).
changes.<field>.value number For each changed field Finite numeric value used by the selected mode. Final OHLC values must be finite and satisfy low <= open/close <= high; volume must be finite and nonnegative.
dry_run boolean Yes true returns a preview and revision without writing. false applies the operation and requires expected_revision.
expected_revision string For apply The 64-character lowercase hexadecimal revision returned by the preview for the same normalized operation. Applying fails if the selected candles changed after preview.

Provide exactly one selector form. Exact timestamps are for selected candle operations. A time range is supported for deletion only; range updates are rejected. An exact timestamp selection is limited to 10,000 entries. If any requested timestamp is missing, the request fails as a whole.

For an update, each configured field operation is calculated from the candle's original value, then the resulting candle is validated. For example, open set to 1.10 and close set to 1.11 are both applied to the original candle; the order of keys in changes does not affect the result. Values can be negative where the final candle remains valid; the server does not impose a general positive-price rule. Finite legacy candles with inconsistent OHLC or negative volume can be deleted, or repaired by an update whose complete result passes validation. Non-finite stored values cannot be previewed and return CANDLE_STORAGE_ERROR.

Preview request

This example previews a 1% increase to high and close for two selected closed minutes:

{
  "command": "MngMutateChartCandles",
  "extID": "preview-001",
  "data": {
    "symbol": "EURUSD",
    "action": "update",
    "selector": {
      "times": [1794900000, 1794900060]
    },
    "changes": {
      "high": {"mode": "percent", "value": 1},
      "close": {"mode": "percent", "value": 1}
    },
    "dry_run": true
  }
}

Preview response

The response includes all selected and affected counts, a revision for the operation, and up to 20 before/after rows. For a delete preview, after is null. affected counts rows that would actually change (or be deleted), so an update that computes the existing values can have affected: 0.

{
  "extID": "preview-001",
  "status": 200,
  "data": {
    "symbol": "EURUSD",
    "action": "update",
    "dry_run": true,
    "selected": 2,
    "affected": 2,
    "revision": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef",
    "preview": [
      {
        "time": 1794900000,
        "before": {"open": 1.0800, "high": 1.0810, "low": 1.0790, "close": 1.0805, "volume": 12},
        "after": {"open": 1.0800, "high": 1.09181, "low": 1.0790, "close": 1.091305, "volume": 12}
      },
      {
        "time": 1794900060,
        "before": {"open": 1.0805, "high": 1.0820, "low": 1.0800, "close": 1.0815, "volume": 8},
        "after": {"open": 1.0805, "high": 1.09282, "low": 1.0800, "close": 1.092315, "volume": 8}
      }
    ]
  }
}

The revision shown above is an example value. Use the exact value returned by the server for the apply request; it is bound to the operation and selected source candles.

Apply request

Repeat the preview operation and provide its revision with dry_run: false. The server checks the revision again before changing the history.

{
  "command": "MngMutateChartCandles",
  "extID": "apply-001",
  "data": {
    "symbol": "EURUSD",
    "action": "update",
    "selector": {
      "times": [1794900000, 1794900060]
    },
    "changes": {
      "high": {"mode": "percent", "value": 1},
      "close": {"mode": "percent", "value": 1}
    },
    "dry_run": false,
    "expected_revision": "0123456789abcdef0123456789abcdef0123456789abcdef0123456789abcdef"
  }
}

Successful apply response uses the same response structure, with dry_run: false; affected is the number of records actually changed. Repeating an apply after an ambiguous network failure is unsafe: first request a new preview and inspect the current rows and revision.

Delete request examples

Delete exact selected times:

{
  "command": "MngMutateChartCandles",
  "extID": "delete-selected-preview",
  "data": {
    "symbol": "EURUSD",
    "action": "delete",
    "selector": {"times": [1794900000, 1794900060]},
    "dry_run": true
  }
}

Delete an inclusive UTC minute range:

{
  "command": "MngMutateChartCandles",
  "extID": "delete-range-preview",
  "data": {
    "symbol": "EURUSD",
    "action": "delete",
    "selector": {"from": 1794900000, "to": 1794903600},
    "dry_run": true
  }
}

Apply either delete preview by repeating the same request with dry_run: false and its returned expected_revision. Range deletion uses inclusive minute-aligned endpoints and fails if the range selects no stored candles.

Errors

Status Error Meaning
400 INVALID_DATA Invalid selector, action, change, timestamp, or candle values.
404 CANDLES_NOT_FOUND A selected timestamp is missing or a delete range contains no candles.
404 SYMBOL_NOT_FOUND The requested symbol does not exist.
409 CANDLE_REVISION_CONFLICT Selected source candles/operation changed, or history was replaced during apply preparation. Request a new preview.
409 CANDLE_NOT_CLOSED The selection includes the live forming minute or a current/future wall-clock minute.
413 CANDLE_SELECTION_TOO_LARGE The operation selects more than 10,000 candles.
500 CANDLE_STORAGE_ERROR The server could not safely persist the change.

All validation happens before mutation. A storage error after replacement (for example directory synchronization failure), like a lost response, can leave the operation committed: reload and preview again instead of blindly retrying. Apply rechecks the revision and writes the resulting candle file atomically while preserving rows outside the selection. A failed validation or revision check leaves history unchanged.