Skip to main content
Glama
zomma-dev

QuantContext

by zomma-dev

backtest_strategy

Read-onlyIdempotent

Run historical backtests on stock screening strategies. Automates rebalancing, sizing, and risk management to return equity curve, trade log, and performance metrics.

Instructions

Run a historical backtest on a stock screening strategy. Uses a rebalance-loop engine that re-runs the screening pipeline on each rebalance date, sizes positions, enforces risk limits, and tracks daily P&L.

Returns equity curve, trade log, and performance metrics including CAGR, Sharpe ratio, maximum drawdown, Calmar ratio, win rate, and turnover.

The backtest is fully deterministic — same inputs always produce identical results.

After backtesting, use factor_analysis on the equity_curve to decompose returns into Fama-French factors (market, size, value, momentum) and estimate true alpha.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
stagesYesPipeline stages defining the strategy. Each stage is an object with: order (int), type ('screen'|'analyze'|'signal'), skill (skill name), config (dict). Example: [{order: 1, type: 'screen', skill: 'fundamental_screen', config: {pe_lt: 15}}, {order: 2, type: 'signal', skill: 'momentum_screen', config: {lookback_days: 200, top_pct: 0.3}}]
universeNoStock universe. Options: sp500, russell2000, nasdaq100sp500
rebalanceNoRebalance frequency. Options: daily, weekly, monthly, quarterlymonthly
sizingNoPosition sizing method. Options: equal_weight, inverse_volatilityequal_weight
start_dateNoBacktest start date in YYYY-MM-DD format2023-01-01
end_dateNoBacktest end date in YYYY-MM-DD format. Defaults to today.
max_position_sizeNoMaximum weight per position (0-1). E.g., 0.1 = 10% max per stock
stop_lossNoPer-position stop loss (0-1). E.g., 0.15 = sell if position drops 15%
max_drawdownNoMaximum portfolio drawdown before going to cash (0-1). E.g., 0.2 = 20%

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

Discloses key behaviors beyond annotations: fully deterministic, rebalance-loop engine, risk enforcement, and output details (equity curve, trade log, performance metrics). No contradiction with annotations.

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

Conciseness5/5

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

Succinct and well-structured, with the main purpose front-loaded. Includes all necessary information without redundancy. Uses clear breaks for outputs and usage guidance.

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?

Given the existence of an output schema, the description sufficiently covers return values and behavioral context. It explains the engine, determinism, and provides post-backtest guidance, making it complete for agent use.

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

Parameters3/5

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

Schema description coverage is 100%, so the schema already documents all parameters adequately. The description adds no extra parameter-level information, meeting the baseline expectation.

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 description clearly states the tool runs a historical backtest on a stock screening strategy, specifying the engine type, outputs, and determinism. It distinguishes from siblings like screen_stocks (screening) and factor_analysis (post-backtest decomposition).

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

Usage Guidelines4/5

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

Provides guidance on when to use this tool (for backtesting) and a clear next step to use factor_analysis. However, it doesn't explicitly state when not to use it or mention alternatives for live trading.

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

Install Server

Other Tools

Latest Blog Posts

MCP directory API

We provide all the information about MCP servers via our MCP API.

curl -X GET 'https://glama.ai/api/mcp/v1/servers/zomma-dev/quantcontext-mcp-server'

If you have feedback or need assistance with the MCP directory API, please join our Discord server