Skip to main content
Glama

price_history_ranking

Read-onlyIdempotent

Ranks every bond in the active Tesouro Direto catalog by where its latest published rate sits within its own history — in ONE call. Prefer this for questions like "which bonds have rates near their historical highs?", "how does today's rate compare with the past, across the catalog?", or any cross-bond comparison of rate levels. Do NOT loop price_history_series per paper for that.

For each catalog paper and each requested window it returns rate stats for one side: min/max, nearest-rank percentiles p10/p25/p50/p75/p90 (always actually published rates), last (most recent published rate on or before to) and lastPercentile (0-100: share of the window strictly below last — 92 means the current rate is above 92% of the period, i.e. near the top of its historical range).

Inputs (all optional):

  • windows: 1-3 of '30d' | '90d' | '1y' | '5y' | 'max', default ['1y']. Ranking is ordered by the FIRST window's lastPercentile (desc); extra windows add context (e.g. ['1y','max']).

  • side: 'investorBuy' (default — investor PURCHASE rate, STN's Taxa de Compra; the standard quoted rate) or 'investorSell' (sell-back). Only papers currently available for that side are ranked.

  • productId: filter to one family. Only the seven catalog families are rankable — 'igpm-mais-com-juros-semestrais' has history but no active catalog entries; for it use price_history_series. On 'selic' the percentiles are coarse: the published rate is a spread over the Selic, near zero and rounded to two decimals of a percent, so a window holds few distinct values.

  • to: anchor date YYYY-MM-DD (default today in Brasília time, BRT) — set a past date for "how did the ranking look then?".

Output: ranking[] with productId, maturityDate, year (label year — CONVERSION year for renda-mais/educa-mais) and per-window stats; meta.missing lists catalog papers with no data in any window (e.g. just launched).

Caveats: this is a statistical description of published rates, NOT investment advice, a return forecast, or a recommendation — never present the ranking as "best bonds to buy". lastPercentile compares each paper against ITS OWN history only; a high percentile means the rate is high relative to that paper's past, nothing more. Comparing entries across families is meaningful only in that relative sense (a prefixado percentile reflects nominal rates; an ipca-mais percentile reflects real rates).

Rates are decimal fraction strings (same as price_history_series, simulate_bond, live_quotes_lookup).

Tool call template

This tool declares no required parameters. Add optional parameters from the input schema as needed.

{
  "id": 1,
  "jsonrpc": "2.0",
  "method": "tools/call",
  "params": {
    "arguments": {},
    "name": "price_history_ranking"
  }
}

Input Schema

NameRequiredDescriptionDefault
toNoAnchor date YYYY-MM-DD for all windows (inclusive end). Default: today in Brasília time (BRT). Set a past date to ask 'how did the ranking look on that day?'.
sideNoWhich rate to rank: 'investorBuy' (default — the rate at which the investor buys from the Treasury, the standard quoted rate) or 'investorSell' (sell-back rate).
windowsNoLookback windows ending at `to` (1-3, default ['1y']): '30d' | '90d' | '1y' | '5y' | 'max' (full history). The ranking is ordered by the FIRST window; extra windows add context (e.g. ['1y','max']).
productIdNoOptional filter to a single product family. Omit to rank the whole active catalog. Only catalog families are rankable (no 'igpm-mais-com-juros-semestrais' — it has history but no active catalog entries).

Output Schema

NameRequiredDescriptionDefault

No arguments

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedInput schema / properties / to / description
      Previous value: -"Anchor date YYYY-MM-DD for all windows (inclusive end). Default: today (UTC). Set a past date to ask 'how did the ranking look on that day?'."New value: +"Anchor date YYYY-MM-DD for all windows (inclusive end). Default: today in Brasília time (BRT). Set a past date to ask 'how did the ranking look on that day?'."
  2. Changed2 schema fields changed
    • changedInput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
    • changedOutput schema / $schema
      Previous value: -"http://json-schema.org/draft-07/schema#"New value: +"https://json-schema.org/draft/2020-12/schema"
  3. Changed2 schema fields changed
    • changedInput schema / properties / productId / description
      Previous value: -"Optional filter to a single product family. Omit to rank the whole active catalog. Only catalog families are rankable (no 'selic' / 'igpm-mais-com-juros-semestrais' — those have history but no active catalog entries)."New value: +"Optional filter to a single product family. Omit to rank the whole active catalog. Only catalog families are rankable (no 'igpm-mais-com-juros-semestrais' — it has history but no active catalog entries)."
    • changedInput schema / properties / productId / enum
      Previous value: -[
      -  "prefixado",
      -  "prefixado-com-juros-semestrais",
      -  "ipca-mais",
      -  "ipca-mais-com-juros-semestrais",
      -  "renda-mais",
      -  "educa-mais"
      -]New value: +[
      +  "prefixado",
      +  "prefixado-com-juros-semestrais",
      +  "ipca-mais",
      +  "ipca-mais-com-juros-semestrais",
      +  "renda-mais",
      +  "educa-mais",
      +  "selic"
      +]
  4. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations already declare readOnly/idempotent/non-destructive, and the description goes well beyond them: it discloses output shape (`ranking[]`, `meta.missing`), the meaning of `lastPercentile`, per-window percentile semantics, a data-quality caveat for 'selic' (coarse, rounded spreads), and an explicit not-investment-advice constraint. This is behavior an agent could not get from the 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?

Front-loaded with the one-sentence purpose and the alternative, then organized into Inputs/Output/Caveats blocks with a clear trailing format note. It is long, and some parameter prose restates the schema verbatim, which is the main avoidable weight.

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?

Even though an output schema exists, the description supplies what matters for correct interpretation — percentile definition, ranking order, missing-data field, and the cross-family comparability caveat. For a four-optional-parameter aggregation tool, an agent has everything needed to call and read it correctly.

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 much of the description's parameter text (defaults, enum values, first-window ordering) duplicates the schema rather than extending it. It does add genuine meaning the schema lacks: the 'selic' percentile coarseness caveat and the fact that only papers available for the chosen `side` are ranked.

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 and resource with scope: 'Ranks every bond in the active Tesouro Direto catalog by where its latest published rate sits within its own history'. It also names the sibling it replaces ('Do NOT loop `price_history_series` per paper'), so an agent can distinguish it without opening a 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?

Gives explicit when-to-use examples ('which bonds have rates near their historical highs?', cross-bond comparison), an explicit anti-pattern (looping the series tool per paper), and a named exception route for 'igpm-mais-com-juros-semestrais' pointing at `price_history_series`. Nothing about tool selection is left to inference.

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.

Resources