Skip to main content
Glama
zomma-dev

QuantContext

by zomma-dev

factor_analysis

Read-onlyIdempotent

Decompose portfolio returns into Fama-French factors to identify alpha versus factor exposure. Use after backtesting to understand return sources.

Instructions

Decompose strategy or portfolio returns into Fama-French factors using OLS regression.

Breaks down returns into exposures to four systematic factors:

  • Mkt-RF (market risk premium): how much return comes from overall market movement

  • SMB (small minus big): size factor exposure

  • HML (high minus low): value factor exposure

  • Mom (momentum): momentum factor exposure

Also estimates alpha (excess return not explained by factors) with t-statistic for statistical significance. A |t-stat| > 2 suggests statistically significant alpha.

Returns alpha (daily and annualized), factor loadings with t-statistics, R-squared (how much of return variance is explained by factors), and residual volatility.

Use this after backtest_strategy to understand WHERE your returns come from — is it genuine alpha or just factor exposure?

Input Schema

TableJSON Schema
NameRequiredDescriptionDefault
equity_curveYesEquity curve as a list of {date, value} objects. Typically from the output of backtest_strategy. Needs at least 30 data points. Example: [{date: '2023-01-03', value: 100000}, {date: '2023-01-04', value: 100500}, ...]

Output Schema

TableJSON Schema
NameRequiredDescriptionDefault
resultYes
Behavior4/5

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

Annotations already indicate read-only, non-destructive, and idempotent behavior. The description adds value by detailing the OLS regression process, factor interpretation, statistical significance thresholds, and the set of outputs (alpha, loadings, R-squared, residual vol). This goes beyond what annotations provide.

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 and well-organized: it opens with the main action, breaks down factors, explains significance, lists outputs, and places the tool in context. Every sentence is informative with no redundancy.

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 tool's complexity (statistical regression with multiple outputs), the description covers inputs, process, outputs, and usage scenario. The presence of an output schema (as indicated by context signals) reduces the need to detail return values, leaving the description sufficiently complete for an agent to invoke correctly.

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% and the equity_curve parameter is well-described with format, source, requirement, and example. The tool description does not add further parameter details beyond what the schema already provides, so a baseline of 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 decomposes returns into Fama-French factors using OLS regression, lists four factors, and explains alpha. It also specifies its place relative to siblings: 'Use this after backtest_strategy to understand WHERE your returns come from.' This distinguishes it from the sibling tools.

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 explicitly directs usage after backtest_strategy and notes the requirement of at least 30 data points in the equity curve parameter description. It does not explicitly cover when not to use or contrast with screen_stocks, but the context is clear enough for typical use.

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