Trend analysis

Take any numeric time series - a stock's daily close, a FRED macro indicator, a treasury yield history - and run it through the full quantitative workup: descriptives, moving averages, trend line, outliers, optional correlation against a benchmark, and a deterministic forecast forward with a 95% prediction interval. Everything an analyst writes a notebook for, in one chain of cheap calls.

$0.018 per call · one payment for the whole workflow
POST /api/skill/trend-analysis
Sample output + API docs →

11 tools run server-side in one request. You pay once, settle once, and get a single response - no orchestration, no per-step payments, and a partial-success envelope if any step fails. USDC over x402 on any supported chain.

When to use this pack

You have a question like "is AAPL trending up over the last year - and what does the next quarter look like?" or "is unemployment a leading indicator for fed-funds moves?" and want a deterministic numerical answer (slope, r², outlier dates, point forecast + 95% interval) instead of a hand-wavy LLM summary or hallucinated projection. The stats + forecast steps are pure-CPU and free over PoW; only the upstream data fetch (finance/macro) is paid.

Tools in this pack

All 11 run inside the single $0.018 call above. Each is also callable on its own if you only need one part.

Bought one at a time, these 11 tools cost $0.019 together; the pack is that sum less a 10% bundle discount, rounded up to the $0.001 settlement floor, which is $0.018.

Workflow

  1. Fetch the series. For an equity ticker, call stock-history with range=horizon (or "1y" if unspecified) and pull the array of `close` prices in chronological order. For a macro indicator, call fred-series with the series id (UNRATE, CPIAUCSL, FEDFUNDS, etc.) and pull the array of `value`s.
  2. Run stats-summary on the values to get the full descriptive panel (mean, median, stddev, min, max, q1/q3, IQR). This is the one-line "what does this series even look like" answer - agents that skip this step end up reporting trends without context.
  3. Smooth the noise with moving-average. A 20-day SMA is the textbook short-term trend smoother for daily prices; a 12-month MA suits monthly macro data. Use which="both" so you can compare SMA (lagging but stable) with EMA (responsive but jittery).
  4. Fit linear-regression with x = [0, 1, ..., n-1] (just the index) and y = values. Slope tells you direction + magnitude per unit time; r² tells you how clean the trend is (>0.7 = strong trend, <0.3 = mostly noise). Pass `predict` for next-N-period extrapolation if the user wants a projection.
  5. Flag anomalies with outliers method="iqr" - Tukey fences (1.5·IQR) are the conservative default. Report the indices + values; agents should then map indices back to dates from the original fetch so the answer says "2024-03-14: $187.23 outlier" not just "index 142".
  6. If the user asked a comparison question ("is AAPL correlated with the S&P?", "do CPI and fed funds move together?"), fetch the benchmark series the same way, align the two on their most recent shared length, then call correlation with the two equal-length arrays. r above 0.7 = strong same-direction move; near 0 = independent; negative = inverse. Use the `interpretation` field as your one-line answer.
  7. Pick a forecast method honestly by backtesting. Call forecast-eval three times - once each with method="drift", "ses", "holt" - passing the same values + testSize (≈ 20% of the series, capped at half). Compare RMSE; the lowest wins. Check `warnings` - non-empty means treat the result as indicative not predictive. Skip the bake-off only if you already know the series shape (e.g. holt-winters for clearly seasonal data with a known period).
  8. Forecast forward with the winning method. Call forecast-naive / forecast-ses / forecast-holt (whichever won) with the full values + the user's horizon. Return the point forecast AND lower95/upper95 - never report a point estimate without its interval; that's the whole reason these tools exist instead of an LLM guess. Combine summary + trend + outliers + optional correlation + forecast into a single JSON object. That's the deterministic analyst-grade reply.

Arguments

NameRequiredDescriptionExample
seriesyesWhat to analyze - a ticker (AAPL), a FRED series id (UNRATE), or a treasury maturity (10Y)AAPL
horizonnoLookback window for the fetch - e.g. "1y", "5y", "6mo". Maps to the upstream tool's range parameter.1y
benchmarknoOptional second series to correlate against - a ticker (SPY) or a FRED series id. Without it the correlation step is skipped.SPY

What one call returns

A JSON object with pack, args, steps, summary; steps holds one entry per tool (stock-history, fred-series, stats-summary, moving-average, linear-regression, outliers, correlation, forecast-eval, ...), each with its own result or error. Full example on the API page.

Call it directly

Any x402 client pays the 402 and gets the whole workflow back in one response. With the agent402-client SDK (npm i agent402-client, an ES module):

import { Agent402 } from "agent402-client";
// payFetch: an x402-wrapped fetch your wallet signs (@x402/fetch).
// Tools on the free tier need no options: new Agent402() pays them by proof-of-work.
// an existing prepaid credits key also works: new Agent402({ creditsKey })
const client = new Agent402({ fetch: payFetch });
const result = await client.call("skill-trend-analysis", {"series":"AAPL","horizon":"1y","benchmark":"SPY"});

Run it in Claude

claude mcp add agent402 -s user -- npx -y agent402-mcp@latest

Then paste this prompt into Claude:

Run a full trend analysis on AAPL over the last 1y using Agent402, then project the next quarter forward. (1) Fetch the daily closes via stock-history (ticker=AAPL, days=250). (2) Run stats-summary on the closes for the descriptive panel. (3) Run moving-average with window=20, which="both" - compare SMA vs EMA. (4) Run linear-regression with x=[0..n-1], y=closes; report slope (annualized = slope·252), intercept, r². (5) Run outliers method="iqr" and map the flagged indices back to actual dates from the fetch, then fetch SPY's daily closes the same way, align both series on their most recent shared length and run correlation on them. (6) Pick a forecast method: call forecast-eval three times with method="drift", "ses", "holt" and testSize=50 (≈ 20% of a 252-day year); pick the lowest RMSE. (7) Forecast the next ~63 trading days using the winning method (forecast-naive / forecast-ses / forecast-holt) and report both point and 95% interval. (8) Return a single JSON object: {summary, trend, outlierDates, forecastMethod, forecastWithIntervals, oneLineConclusion}. The stats + forecast steps are free over PoW; only the stock-history fetch is paid.

← All skill packs