Skip to main content
Glama

Valuein — SEC EDGAR Fundamentals & Smart-Money Data

Run Bounded Factor Backtest

run_backtest
Read-onlyIdempotent

A SMALL, BOUNDED, in-Worker sanity-check backtest — NOT a full-universe backtesting engine. Answers a quick question like 'does this factor actually work on these 5 names over the last year' inline, mid-conversation, without leaving MCP. Composes two existing tools (get_pit_universe + get_pit_valuation_ratios) across up to 10 tickers x 12 rebalance dates (120 cells): for each rebalance date, checks which requested tickers were in the survivorship-free PIT universe on that date (dropping — never erroring on — a ticker not yet listed or already delisted), then pulls each surviving ticker's point-in-time valuation multiples and computes the forward return to the NEXT rebalance date from the raw (unadjusted) close. Returns a flat {rebalance_date, ticker, factor_values, forward_return_pct} grid plus a small factor<->forward-return correlation per requested factor — a quick cross-sectional signal check, NOT a transaction-cost-aware portfolio simulation or a statistically validated backtest result. If the requested grid exceeds 120 cells, this tool does NOT silently truncate — it returns a stream_fallback response (signed Parquet download URLs, same shape as get_compute_ready_stream) and tells you to use those URLs. For a REAL full-universe, multi-date, survivorship-free backtest, use the Python SDK's AlphaEngine (pip install valuein-sdk) looped over as_of dates client-side — this tool is explicitly the small complement to that, not a replacement for it. Pro and Institutional only: it composes get_pit_valuation_ratios, which reads the daily price series the free tiers do not carry (licensed market data), so the free plans receive an ENTITLEMENT_DENIED upgrade envelope before any read. Coverage follows your plan tier same as the two tools it composes.

Input Schema

NameRequiredDescriptionDefault
factorsNoWhich of get_pit_valuation_ratios's own output fields to include as factor_values. One or more of: pe_ratio, ps_ratio, pb_ratio, ev_ebitda, ev_revenue, fcf_yield_pct, gross_margin_pct, operating_margin_pct, net_margin_pct. Omit to include all of them.
tickersYes1-10 stock ticker symbols, e.g. ["AAPL","MSFT"].
rebalance_datesYes1-12 historical dates (YYYY-MM-DD) to snapshot valuation multiples on. Order does not matter — the tool sorts them chronologically. Forward return is computed from each date to the NEXT one in the sorted list.

Output Schema

NameRequiredDescriptionDefault
noteYes
_metaYesProvenance envelope — data lineage for every MCP response
cellsNo
cappedYes
methodYes
caveatsYes
droppedYes
factorsYes
streamsNo
summaryNo
tickersYes
pit_safeYes
next_stepNo
grid_cellsYes
cells_computedYes
rebalance_datesYes
source_tools_usedYes

Schema Changelog

Changes observed during successful MCP inspections.

  1. Changed1 schema field changed
    • changedOutput schema / properties / _meta / properties / cost_usd / properties / basis / description
      Previous value: -"payg_charge = real charge (agent-pay or your balance). payg_rate_card = indicative price, not billed."New value: +"payg_charge = real pay-per-call charge (a card or MPP payment through agent-pay). payg_rate_card = indicative price, not billed."
  2. Changed2 schema fields changed
    • changedOutput schema / properties / _meta / properties / cost_usd / properties / basis / description
      Previous value: -"payg_charge = real agent-pay charge. payg_rate_card = indicative price, not billed."New value: +"payg_charge = real charge (agent-pay or your balance). payg_rate_card = indicative price, not billed."
    • changedOutput schema / properties / _meta / properties / cost_usd / properties / billed / description
      Previous value: -"true = this amount was actually charged via PAYG for this call. false = indicative PAYG-equivalent value; your plan already covers this call for free."New value: +"true = this amount was actually charged via PAYG for this call. false = indicative PAYG-equivalent value only: no charge was made for this call (it was within your plan)."
  3. Added
  4. Removed
  5. Changed1 schema field changed
    • changedOutput schema / properties / _meta / properties / fundamentals_as_of / description
      Previous value: -"ISO timestamp when the FINANCIAL STATEMENTS were last rebuilt. Use THIS — not `last_updated` — when telling a user how current the fundamentals are. The snapshot is republished on every weekday price refresh while the statements are carried forward unchanged, so `last_updated` can be far more recent than the numbers it sits next to."New value: +"ISO timestamp when the FINANCIAL STATEMENTS were last rebuilt in bulk. Use THIS — not `last_updated` — when telling a user how current the cross-sectional fundamentals are. The snapshot is republished on every weekday price refresh while the statements are carried forward unchanged, so `last_updated` can be far more recent than the numbers it sits next to. It is a floor for a single filer, not a ceiling: a filer with a live partition receives its filing, facts and ratios intraday (minutes after EDGAR dissemination), so an entity-scoped read may carry a filing newer than this; cross-sectional ranks (factor scores, earnings signals) refresh with the weekly bulk export."
  6. Changed1 schema field changed
    • changedInput schema / properties / tickers / items / pattern
      Previous value: -"^[A-Za-z][A-Za-z0-9.\\-]{0,9}$"New value: +"^([A-Za-z][A-Za-z0-9.\\-]{0,9}|\\d{1,10})$"
  7. Changed2 schema fields changed
    • addedOutput schema / properties / _meta / properties / fundamentals_as_of
      Added value: +{
      +  "description": "ISO timestamp when the FINANCIAL STATEMENTS were last rebuilt. Use THIS — not `last_updated` — when telling a user how current the fundamentals are. The snapshot is republished on every weekday price refresh while the statements are carried forward unchanged, so `last_updated` can be far more recent than the numbers it sits next to.",
      +  "type": "string"
      +}
    • addedOutput schema / properties / _meta / properties / price_as_of
      Added value: +{
      +  "description": "ISO timestamp when the price surfaces were last refreshed.",
      +  "type": "string"
      +}
  8. Changed2 schema fields changed
    • addedOutput schema / properties / _meta / properties / cost_usd
      Added value: +{
      +  "additionalProperties": false,
      +  "description": "Per-call cost transparency. Omitted for subscription-only tools that have no PAYG-equivalent price.",
      +  "properties": {
      +    "amount_usd": {
      +      "minimum": 0,
      +      "type": "number"
      +    },
      +    "basis": {
      +      "description": "payg_charge = real agent-pay charge. payg_rate_card = indicative price, not billed.",
      +      "enum": [
      +        "payg_charge",
      +        "payg_rate_card"
      +      ],
      +      "type": "string"
      +    },
      +    "billed": {
      +      "description": "true = this amount was actually charged via PAYG for this call. false = indicative PAYG-equivalent value; your plan already covers this call for free.",
      +      "type": "boolean"
      +    }
      +  },
      +  "required": [
      +    "amount_usd",
      +    "billed",
      +    "basis"
      +  ],
      +  "type": "object"
      +}
    • addedOutput schema / properties / _meta / properties / latency_ms
      Added value: +{
      +  "description": "Wall-clock milliseconds this tool call took, measured server-side around the handler.",
      +  "minimum": 0,
      +  "type": "integer"
      +}
  9. Added

TDQS

A4.8/5.0
Behavior5/5

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

Annotations (readOnlyHint true, idempotent, non-destructive) are consistent and the description adds substantial context beyond them: tickers absent on a date are silently dropped rather than erroring, forward return is computed from raw unadjusted close, grids over 120 cells return a stream_fallback with signed Parquet URLs instead of truncating, and free-tier callers hit an ENTITLEMENT_DENIED envelope before any read. That is exactly the auth/limit/degradation detail annotations cannot carry.

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?

The critical constraint ('SMALL, BOUNDED ... NOT a full-universe backtesting engine') is front-loaded in the first clause. It is longer than needed, though: the not-a-real-backtest caveat and the 'small complement' framing are restated in three separate places (opening, middle, closing), which costs tokens without adding decision-relevant information.

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?

For a composed, tier-gated analytical tool the description covers the full decision surface: inputs, output grid shape, correlation output, overflow behavior, entitlement failure mode, and the correct alternative for heavier workloads. An output schema exists, yet the description still sketches the return shape, which is a bonus rather than a gap.

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%, so the baseline is 3. The description still adds interpretive value: the 10x12=120 cell budget frames how to choose tickers vs dates, the factors list maps to get_pit_valuation_ratios' own output fields with an all-included default, and the delisted/not-yet-listed drop rule tells the agent what an unmatched ticker on a date actually yields.

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+resource with explicit scope: a bounded in-Worker factor sanity-check over up to 10 tickers x 12 rebalance dates. It names exactly which sibling tools it composes (get_pit_universe + get_pit_valuation_ratios) and explicitly contrasts itself with a full-universe backtesting engine, so an agent can distinguish it from get_valuation_metrics or the SDK path without opening any 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 an explicit when-to-use scenario ('does this factor actually work on these 5 names over the last year' inline, mid-conversation) and an explicit when-not-to-use plus alternative (real full-universe survivorship-free backtest → Python SDK AlphaEngine looped over as_of dates). It also states the escalation path when the grid overflows.

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.