Skip to main content
Glama
jasonwu001t

marketlens-mcp

by jasonwu001t

Drawdown

analytics_drawdown
Read-onlyIdempotent

Calculate drawdown for stored price or equity results: get max drawdown, peak/trough/recovery timing, or drawdown at every observation.

Instructions

Drawdown of each series in a stored result of prices or equity, computed locally in DuckDB: running peak = the highest value so far, drawdown = value / peak - 1 (0 at a new peak, negative below it). mode max (default): one row per series with max_drawdown, peak_t, trough_t, recovery_t (the first time back at the peak; None if not recovered), peak_to_trough_days and n_obs. mode series: the drawdown at every observation. NULL, NaN, infinite and non-positive values are skipped. Drawdowns are fractions (-0.25 = 25 % below the peak). Use split-adjusted bars. Large outputs are stored and you get a result_id.

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
modeNomax: one summary row per series; series: the drawdown at every observation.max
result_idYesA stored result of prices or account equity (bars, portfolio history, ...).
value_columnNoNumeric column of positive values. Default: the model's first value column (close, equity).
series_columnNoColumn naming each series. Default: the result's group column.

Schema Changelog

Changes observed during successful MCP inspections.

  1. First observedv0.1.0

TDQS

A4.2/5.0
Behavior5/5

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

Annotations already cover safety (readOnly, idempotent, non-destructive), and the description adds substantial context beyond them: NULL/NaN/infinite/non-positive values are skipped, drawdowns are fractions, and large outputs are persisted with a returned result_id. That output-storage behavior is genuinely useful and not derivable from annotations.

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?

Dense but front-loaded: the core computation comes first, then mode outputs, then edge-case handling and output persistence. No filler sentences, though the run-on structure packs many clauses per sentence.

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, the description carries the return-shape burden and does so: it enumerates the max-mode columns (max_drawdown, peak_t, trough_t, recovery_t, peak_to_trough_days, n_obs) and explains series mode. An agent has what it needs to call and interpret results.

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 mode, result_id, value_column, and series_column. The description largely restates the mode semantics and defaults already present in the schema, adding little new parameter-level meaning. 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?

States a specific verb (compute drawdown) and resource (each series in a stored result of prices/equity), and defines the computation precisely (running peak, value/peak - 1). This distinguishes it cleanly from sibling analytics tools like analytics_returns and analytics_volatility without needing to name them.

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

Usage Guidelines3/5

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

Gives implied usage guidance through the mode descriptions (max for summary, series for per-observation) and the note 'Use split-adjusted bars,' but never states when to prefer this over alternatives or any prerequisites/exclusions. Usage is inferable but not explicit.

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