{"uid":"cap_W3BRLJVlhG9Zh2IbJA0zO","slug":"portfolio-stats-rolling-mean-return-annualized-volatility-85afb00e","name":"Portfolio Stats – Rolling Mean Return & Annualized Volatility","description":"Rolling mean return and rolling annualized volatility over a window, from a price or return series you supply.","url":"https://portfolio-stats.x402tookit.com/rolling?utm_source=zero.xyz","method":"GET","headers":{},"bodySchema":{"type":"object","$schema":"https://json-schema.org/draft/2020-12/schema","required":["input"],"properties":{"input":{"type":"object","required":["type","method"],"properties":{"type":{"type":"string","const":"http"},"method":{"enum":["GET"],"type":"string"},"queryParams":{"type":"object","required":["window"],"properties":{"unit":{"type":"string","description":"decimal (default, 0.01 = 1%) or percent (1 = 1%); applies to returns only"},"prices":{"type":"string","description":"Price series, oldest first, JSON like [100,101,99.5] or 100,101,99.5 (up to 1000). Give prices OR returns"},"window":{"type":"integer","description":"Window length in periods, 2 up to the number of returns (at most 500)"},"returns":{"type":"string","description":"Period returns, oldest first, decimals by default (0.01 = 1%). Give returns OR prices"},"periodsPerYear":{"type":"integer","description":"Periods per year for annualising: 252 daily (default), 52 weekly, 12 monthly"}}}},"additionalProperties":false},"output":{"type":"object","required":["type"],"properties":{"type":{"type":"string"},"example":{"type":"object","properties":{"asOf":{"type":["null","string"]},"source":{"type":["null","string"]},"window":{"type":["null","number"]},"reasons":{"type":["array","null"],"items":{"type":"string"}},"summary":{"type":["null","string"]},"verdict":{"type":["null","string"]},"degraded":{"type":["boolean","null"]},"disclaimer":{"type":["null","string"]},"notChecked":{"type":["array","null"],"items":{"type":"string"}},"fullWindows":{"type":["null","number"]},"observations":{"type":["null","number"]},"periodsPerYear":{"type":["null","number"]},"educationalOnly":{"type":["null","string"]},"latestMeanReturn":{"type":["null","number"]},"rollingMeanReturn":{"type":["array","null"],"items":{"type":["null","number"]}},"maxAnnualizedVolatilityPct":{"type":["null","number"]},"minAnnualizedVolatilityPct":{"type":["null","number"]},"latestAnnualizedVolatilityPct":{"type":["null","number"]},"rollingAnnualizedVolatilityPct":{"type":["array","null"],"items":{"type":["null","number"]}}}}}}}},"responseSchema":null,"example":null,"exampleRequest":null,"tags":["x402"],"displayCostAmount":"0.02","displayCostAsset":"USDC","priceDynamic":false,"priceHint":null,"priceStatus":"priced","priceSource":"probe","requiresHandshake":false,"reviewCount":0,"rating":{"score":"0.00","successRate":"0.00","reviews":0,"stars":null,"state":"unrated"},"availabilityStatus":"unknown","priceObserved":null,"sessionDeposit":null,"pricing":{"kind":"static","summary":"$0.02/call","primary":{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"},"accepted":[{"kind":"static","protocol":"x402","network":"base","amountUsd":"0.02","per":"call","confidence":"exact"}]},"paymentMethods":[{"uid":"pm_JYflLWg6d_nZUKIHUQtbJ","protocol":"x402","methodType":"crypto","chain":"base","mode":"charge","costAmount":"0.02","costPer":"request","priority":0,"asset":"0x833589fCD6eDb6E08f4c7C32D4f71b54bdA02913","unit":"request","depositMicros":null,"planRef":null}],"brandName":null,"brandSlug":null,"brandBaseUrl":null,"brandDocsUrl":null,"whatItDoes":"Computes rolling mean return and rolling annualized volatility over a sliding window from a user-supplied price or return series.","exampleAgentPrompt":"Calculate the rolling mean return and annualized volatility for these daily closing prices [100, 101, 99.5, 102, 103, 101.5, 104] using a 5-period window, with 252 periods per year.","exampleUseCases":[{"title":"Daily stock rolling volatility check","prompt":"I have these 30 daily closing prices for AAPL: [150,151,149,152,153,150,148,151,154,155,153,156,157,155,158,159,157,160,161,159,162,163,161,164,165,163,166,167,165,168]. Can you give me rolling mean return and annualized volatility using a 10-day window, annualized with 252 trading days?"},{"title":"Monthly portfolio return smoothing","prompt":"Here are 24 monthly returns for my portfolio (in percent, so use percent mode): [1.2,-0.8,2.1,0.5,-1.1,1.8,0.9,-0.3,2.4,1.0,-0.5,1.6,0.7,-0.9,2.2,0.8,-0.2,1.9,1.1,-0.6,2.3,0.6,-0.4,1.7]. Compute rolling mean return and annualized volatility with a 6-month window and 12 periods per year."},{"title":"Crypto weekly return risk analysis","prompt":"I've got weekly returns for Bitcoin over the past year as decimals: [0.05,-0.03,0.08,0.02,-0.06,0.10,-0.04,0.07,0.01,-0.02,0.09,-0.05,0.06,0.03,-0.07,0.11,-0.01,0.04,-0.03,0.08,0.02,-0.05,0.09,0.03,-0.08,0.12,-0.02,0.05,-0.04,0.07,0.01,-0.06,0.10,-0.03,0.08,0.02,-0.04,0.09,0.01,-0.07,0.11,-0.02,0.06,0.03,-0.09,0.13,-0.01,0.04,-0.05,0.07,0.02,-0.08]. Use a 12-week rolling window annualized to 52 periods per year."}],"resultDescription":"Returns an array of rolling mean returns and rolling annualized volatility percentages, plus the latest values of each, the min/max annualized volatility seen across all windows, the number of complete windows, total observations, and metadata including window size, periods per year, and any disclaimers or educational notes.","failureModes":["Missing required 'window' parameter returns a 400 error","Supplying both prices and returns simultaneously causes a validation error","Window length larger than the number of returns (or greater than 500) is rejected","Fewer data points than the window size produces no full windows (empty rolling arrays)","Invalid JSON in prices or returns query parameter causes a parse error","Returns denominated in percent without specifying unit=percent yields incorrect calculations"],"whenToPreferThis":"Choose this endpoint when you need time-series risk monitoring over a sliding window rather than a single aggregate stat. It's ideal for charting how volatility or mean return evolves through time, detecting regime changes, or feeding rolling inputs into downstream models like rolling Sharpe. Prefer this over the single-pass volatility endpoint when temporal structure of risk matters.","instructions":null,"reviewSummary":null,"reviewSummaryHighlights":null,"reviewSummaryConcerns":null,"reviewSummaryGeneratedAt":null,"activationCount":0,"lastUsedAt":null,"lastSuccessfullyRanAt":null,"lastHealthCheckAt":"2026-10-29T13:11:23.271Z","isFirstParty":false,"canonicalSlug":"portfolio-stats-rolling-mean-return-annualized-volatility-85afb00e"}