Skip to main content
Glama
jihjihk

QuantContext

by jihjihk

backtest_strategy

Read-onlyIdempotent

Run historical backtests on stock screening strategies. Uses a rebalance-loop engine with risk limits and returns equity curve, trade log, and performance metrics including CAGR and Sharpe ratio.

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
sizingNoPosition sizing method. Options: equal_weight, inverse_volatilityequal_weight
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}}]
end_dateNoBacktest end date in YYYY-MM-DD format. Defaults to today.
universeNoStock universe. Options: sp500, russell2000, nasdaq100sp500
rebalanceNoRebalance frequency. Options: daily, weekly, monthly, quarterlymonthly
stop_lossNoPer-position stop loss (0-1). E.g., 0.15 = sell if position drops 15%
start_dateNoBacktest start date in YYYY-MM-DD format2023-01-01
max_drawdownNoMaximum portfolio drawdown before going to cash (0-1). E.g., 0.2 = 20%
max_position_sizeNoMaximum weight per position (0-1). E.g., 0.1 = 10% max per stock

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior5/5

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

The description adds value beyond annotations by stating the backtest is fully deterministic (idempotent) and lists return metrics. It aligns with readOnlyHint and destructiveHint, with no contradictions.

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?

The description is concise (5 sentences) with a clear front-loaded purpose. Each sentence adds distinct value, including deterministic behavior, outputs, and follow-up guidance.

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

Completeness4/5

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

Given the tool's complexity (9 params) and presence of an output schema, the description covers the core purpose, return types, and behavior adequately. It could mention more about the rebalance-loop engine details, but is still reasonably complete.

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 coverage is 100%, so the description adds no extra parameter meaning beyond what the schema already provides. The description only mentions return values, not parameter details, so baseline 3 is appropriate.

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, with specific outputs (equity curve, trade log, performance metrics) and mentions a rebalance-loop engine. It distinguishes from sibling tools by suggesting factor_analysis for subsequent use.

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?

The description explains when to use the tool (for backtesting) and provides a follow-up step (use factor_analysis). However, it does not explicitly state when not to use it or compare to alternatives like screen_stocks, though the sibling context implicitly differentiates.

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/jihjihk/quantcontext-mcp-server'

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