81trust / 100

Moving Average

by Moving average (SMA + EMA) in Other

x402 APIPassing, checked 12 min ago

Compute simple (SMA) and exponential (EMA) moving averages over a numeric series. Returns one value per input position - the first (window-1) SMA values are null since there isn't enough history. EMA uses the standard alpha = 2/(window+1) smoothing factor used in technical analysis.

POST https://agent402.tools/api/moving-average

Last 30 days

All checks passedSome failedAll failedNot checked
Uptime
100%
Response time
187 ms typical, 187 ms slowest 5%
Last check
12 min ago
Next check
in 21 min

How to call it

# See the payment challenge (nothing is charged)
curl -i -X POST "https://agent402.tools/api/moving-average" \
  -H "content-type: application/json" \
  -d '{"values":[10,11,12,13,14,15,16,17,18,19],"window":3}'
import { wrapFetchWithPayment } from "@x402/fetch";
import { x402Client } from "@x402/core/client";
import { ExactEvmScheme } from "@x402/evm/exact/client";
import { privateKeyToAccount } from "viem/accounts";

const client = new x402Client().register(
  "eip155:8453",
  new ExactEvmScheme(privateKeyToAccount(process.env.AGENT_KEY)),
);
const pay = wrapFetchWithPayment(fetch, client);

// Not sure it's safe to pay? Preflight it first for $0.005:
// GET https://toolvet.app/api/v1/check?url=https%3A%2F%2Fagent402.tools%2Fapi%2Fmoving-average
const res = await pay("https://agent402.tools/api/moving-average", {
  method: "POST",
  headers: { "content-type": "application/json" },
  body: JSON.stringify({"values":[10,11,12,13,14,15,16,17,18,19],"window":3}),
});
console.log(await res.json());

Example input

{
  "values": [
    10,
    11,
    12,
    13,
    14,
    15,
    16,
    17,
    18,
    19
  ],
  "window": 3
}

Example output

{
  "count": 10,
  "ema": [
    10,
    10.5,
    11.25,
    12.125,
    13.0625,
    14.0312,
    15.0156,
    16.0078,
    17.0039,
    18.002
  ],
  "sma": [
    null,
    null,
    11,
    12,
    13,
    14,
    15,
    16,
    17,
    18
  ],
  "window": 3
}

Security scan

  • No findings. We scan names, descriptions and tool definitions for hidden instructions and other prompt-injection patterns.

Recent checks

WhenResultHTTPTimePrice
12 min agoPassed402187 ms$0.001
5 h agoPassed402187 ms$0.001