Skip to main content
Glama

Backtesting Arena

Run a Grid-Trading Backtest

arena_run_grid_backtest

Would a grid bot have made money here? Simulate a GRID BOT (buy-low / sell-high ladder inside a fixed price range) on historical candles. Returns final value, return %, CAGR, trade count, fees paid and a Buy & Hold comparison — plus zerlegung (spot runs): decomposition splits the result into ladder P&L from completed buy→sell cycles, allocation P&L of the starting coins, open grid buys and fees (identity_check_usd must be ~0); benchmarks anchors buy-and-hold, the never-touched starting split (static_allocation, with coin_share_start) and an arithmetic 50/50 at the entry price — grid_vs_static_pp is the number that says whether the ladder added anything over just holding the split; fee_economics gives the break-even spacing (2 × fee) and flags below_breakeven. Note: buyhold_return/outperformance keep their legacy anchor (first→last candle close); benchmarks anchor at entry. This is a different machine from the strategy backtester: grid bots earn from oscillation inside a range, not from trend — for signal-based strategies use arena_run_backtest instead. The result depends heavily on the range you choose (low_price / high_price); a range the price left early makes the bot idle (by default the grid pauses outside the range and resumes when price returns; set stop_on_range_exit to end the run at the first close outside it instead, selling all coins there), so treat range choice as part of the hypothesis, not a detail — arena_suggest_grid_range proposes a defensible range. Each run is saved to your account (the returned id is the run_id); publish a public snapshot page with arena_share_grid_backtest. grid_mode picks neutral (default) or long. Optional leverage (2/3/5, grid_mode long only, Pro) with funding_mode (conservative default / historical BTCUSDT / none): simulates an isolated-margin futures long grid — margin = total_investment, the grid trades margin × leverage, funding accrues daily on the open position, liquidation is checked per candle at the low. It simulates, it does not recommend: the result can be a total loss of the margin. Free tier limited to BTCUSDT/ETHUSDT. Per-day quota: Free=5, Pro=50, Power=500. [Free / Pro / Power tier]

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
pairYesCrypto pair symbol, e.g. BTCUSDT. Free tier: BTCUSDT or ETHUSDT only.
end_dateYesSimulation end, YYYY-MM-DD.
fee_rateYesPer-trade fee fraction, e.g. 0.001 for 0.1% (Binance spot taker).
leverageNoOptional, default 1 (spot grid, unchanged). 2/3/5 = isolated-margin long grid (grid_mode must be long; Pro). Adds liquidated, liquidation_time/price, funding_cost_usd and max_notional_exposure to the result; final_value/total_return are then on the margin.
grid_modeNo'neutral' (default): buys coins for every level above the entry at the start (the coin share follows the entry's position in the range — measured 2–83 %, NOT a fixed 50/50; see benchmarks.static_allocation.coin_share_start), then buys and sells around the entry. 'long': starts 100% in cash, buys dips below the entry, sells on recovery — required for leverage.
grid_typeYesLevel spacing: 'arithmetic' = equal price steps, 'geometric' = equal percentage steps (usually the better fit for crypto).
low_priceYesLower bound of the grid range, in quote currency. Below it the bot is fully invested and stops buying.
grid_countYesNumber of grid levels between low_price and high_price (2–200). More levels = more, smaller trades = more fees.
high_priceYesUpper bound of the grid range, in quote currency. Above it the bot is fully in cash and stops selling. Must exceed low_price.
start_dateYesSimulation start, YYYY-MM-DD.
entry_priceNoOptional price at which the bot starts; default is the OPEN of the first candle (must lie inside low_price..high_price).
funding_modeNoOnly with leverage > 1. 'conservative' (default): flat 0.05%/day on the open position. 'historical': recorded daily average of three exchanges, BTCUSDT from 2019-09-08 only — otherwise falls back to conservative and flags funding_fell_back_to_conservative. 'none': no funding (optimistic).
stop_loss_priceNoOptional: liquidate the whole grid and stop once price falls to this level.
total_investmentYesCapital in USDT spread across the grid; min 100.
take_profit_priceNoOptional: liquidate the whole grid and stop once price rises to this level.
stop_on_range_exitNoOptional (default false): stop once a candle CLOSES outside low_price..high_price — sell all coins at that close, stop_reason range_exit_high/low. Default: the grid pauses outside the range and resumes when price returns.

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • addedInput schema / properties / stop_on_range_exit
      Added value: +{
      +  "description": "Optional (default false): stop once a candle CLOSES outside low_price..high_price — sell all coins at that close, stop_reason range_exit_high/low. Default: the grid pauses outside the range and resumes when price returns.",
      +  "type": "boolean"
      +}
  2. Changed2 schema fields changed
    • changedInput schema / properties / entry_price / description
      Previous value: -"Optional price at which the bot starts; default is the first close in the range."New value: +"Optional price at which the bot starts; default is the OPEN of the first candle (must lie inside low_price..high_price)."
    • changedInput schema / properties / grid_mode / description
      Previous value: -"'neutral' (default): starts half in coins, buys and sells around the entry. 'long': starts 100% in cash, buys dips below the entry, sells on recovery — required for leverage."New value: +"'neutral' (default): buys coins for every level above the entry at the start (the coin share follows the entry's position in the range — measured 2–83 %, NOT a fixed 50/50; see benchmarks.static_allocation.coin_share_start), then buys and sells around the entry. 'long': starts 100% in cash, buys dips below the entry, sells on recovery — required for leverage."
  3. Changed3 schema fields changed
    • addedInput schema / properties / funding_mode
      Added value: +{
      +  "description": "Only with leverage > 1. 'conservative' (default): flat 0.05%/day on the open position. 'historical': recorded daily average of three exchanges, BTCUSDT from 2019-09-08 only — otherwise falls back to conservative and flags funding_fell_back_to_conservative. 'none': no funding (optimistic).",
      +  "enum": [
      +    "none",
      +    "conservative",
      +    "historical"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / grid_mode
      Added value: +{
      +  "description": "'neutral' (default): starts half in coins, buys and sells around the entry. 'long': starts 100% in cash, buys dips below the entry, sells on recovery — required for leverage.",
      +  "enum": [
      +    "neutral",
      +    "long"
      +  ],
      +  "type": "string"
      +}
    • addedInput schema / properties / leverage
      Added value: +{
      +  "description": "Optional, default 1 (spot grid, unchanged). 2/3/5 = isolated-margin long grid (grid_mode must be long; Pro). Adds liquidated, liquidation_time/price, funding_cost_usd and max_notional_exposure to the result; final_value/total_return are then on the margin.",
      +  "enum": [
      +    1,
      +    2,
      +    3,
      +    5
      +  ],
      +  "type": "number"
      +}
  4. Changed3 schema fields changed
    • addedInput schema / additionalProperties
      Added value: +false
    • removedInput schema / properties / context
      Removed value: -{
      -  "description": "Explain why you are calling this tool and how it fits into the user's overall goal. This parameter is used for analytics and user intent tracking. YOU MUST provide 15-25 words (count carefully). NEVER use first person ('I', 'we', 'you') - maintain third-person perspective. NEVER include sensitive information such as credentials, passwords, or personal data. Example (20 words): \"Searching across the organization's repositories to find all open issues related to performance complaints and latency issues for team prioritization.\"",
      -  "type": "string"
      -}
    • changedInput schema / required
      Previous value: -[
      -  "pair",
      -  "start_date",
      -  "end_date",
      -  "total_investment",
      -  "low_price",
      -  "high_price",
      -  "grid_count",
      -  "grid_type",
      -  "fee_rate",
      -  "context"
      -]New value: +[
      +  "pair",
      +  "start_date",
      +  "end_date",
      +  "total_investment",
      +  "low_price",
      +  "high_price",
      +  "grid_count",
      +  "grid_type",
      +  "fee_rate"
      +]
  5. Changed12 schema fields changed
    • addedInput schema / properties / end_date / description
      Added value: +"Simulation end, YYYY-MM-DD."
    • addedInput schema / properties / entry_price / description
      Added value: +"Optional price at which the bot starts; default is the first close in the range."
    • changedInput schema / properties / fee_rate / description
      Previous value: -"Per-trade fee fraction, e.g. 0.001 for 0.1%."New value: +"Per-trade fee fraction, e.g. 0.001 for 0.1% (Binance spot taker)."
    • addedInput schema / properties / grid_count / description
      Added value: +"Number of grid levels between low_price and high_price (2–200). More levels = more, smaller trades = more fees."
    • addedInput schema / properties / grid_type / description
      Added value: +"Level spacing: 'arithmetic' = equal price steps, 'geometric' = equal percentage steps (usually the better fit for crypto)."
    • addedInput schema / properties / high_price / description
      Added value: +"Upper bound of the grid range, in quote currency. Above it the bot is fully in cash and stops selling. Must exceed low_price."
    • addedInput schema / properties / low_price / description
      Added value: +"Lower bound of the grid range, in quote currency. Below it the bot is fully invested and stops buying."
    • addedInput schema / properties / pair / description
      Added value: +"Crypto pair symbol, e.g. BTCUSDT. Free tier: BTCUSDT or ETHUSDT only."
    • addedInput schema / properties / start_date / description
      Added value: +"Simulation start, YYYY-MM-DD."
    • addedInput schema / properties / stop_loss_price / description
      Added value: +"Optional: liquidate the whole grid and stop once price falls to this level."
    • addedInput schema / properties / take_profit_price / description
      Added value: +"Optional: liquidate the whole grid and stop once price rises to this level."
    • changedInput schema / properties / total_investment / description
      Previous value: -"USDT amount; min 100."New value: +"Capital in USDT spread across the grid; min 100."
  6. First observed

TDQS

A4.8/5.0
Behavior5/5

Does the description disclose side effects, auth requirements, rate limits, or destructive behavior?

With no annotations, the description carries the full load and does so: it discloses the returned fields, the zerlegung sub-reports, that runs persist to the account with a run_id, tier/quota limits, the simulation-not-advice caveat ('can be a total loss of the margin'), and range-exit pausing semantics with stop_on_range_exit as the override.

Agents need to know what a tool does to the world before calling it. Descriptions should go beyond structured annotations to explain consequences.

Conciseness4/5

Is the description appropriately sized, front-loaded, and free of redundancy?

It is long, but the length is justified by a 16-parameter tool with no output schema, and the value proposition is front-loaded in the first sentence. A few clauses (tier tags, T&C-style caveats) sit near the end and could be trimmed, keeping it short of a 5.

Shorter descriptions cost fewer tokens and are easier for agents to parse. Every sentence should earn its place.

Completeness5/5

Given the tool's complexity, does the description cover enough for an agent to succeed on first attempt?

With no output schema or annotations, the description compensates fully: it enumerates return values and the decomposition/benchmarks/fee_economics breakdown, explains the legacy vs entry-price anchoring discrepancy, and covers leverage, funding, quotas and persistence. Nothing needed to invoke it correctly is missing.

Complex tools with many parameters or behaviors need more documentation. Simple tools need less. This dimension scales expectations accordingly.

Parameters4/5

Does the description clarify parameter syntax, constraints, interactions, or defaults beyond what the schema provides?

Schema coverage is 100% and the schema descriptions are already rich, so the baseline is 3. The description still adds real meaning beyond the schema for leverage ('margin = total_investment, the grid trades margin × leverage, funding accrues daily ... liquidation is checked per candle at the low') and reinforces the low_price/high_price range dependency.

Input schemas describe structure but not intent. Descriptions should explain non-obvious parameter relationships and valid value ranges.

Purpose5/5

Does the description clearly state what the tool does and how it differs from similar tools?

The opening states a concrete verb and resource ('Simulate a GRID BOT ... on historical candles') and defines the mechanism (buy-low/sell-high ladder inside a fixed range). It explicitly distinguishes itself from the sibling strategy backtester ('This is a different machine ... for signal-based strategies use arena_run_backtest instead'), so an agent can route without opening either schema.

Agents choose between tools based on descriptions. A clear purpose with a specific verb and resource helps agents select the right tool.

Usage Guidelines5/5

Does the description explain when to use this tool, when not to, or what alternatives exist?

It names the alternative (arena_run_backtest) and the condition selecting it, points to arena_suggest_grid_range when range choice is unresolved, and to arena_share_grid_backtest for publishing. It also frames when the grid archetype applies ('earn from oscillation inside a range, not from trend') and warns that range choice is part of the hypothesis.

Agents often have multiple tools that could apply. Explicit usage guidance like "use X instead of Y when Z" prevents misuse.

Try in Browser

Glama MCP Gateway

Add one secure layer between your agents and this server.