---
name: indvest-analyser
description: Quantitative mutual fund research and screening skill for Indian mutual funds powered by the INDvest data engine. Use when screening, ranking, or comparing Indian mutual funds, or when evaluating SIP XIRR and rolling-return consistency.
license: MIT
allowed-tools: [Bash, Read, Write, WebFetch]
metadata:
  version: "1.1"
---

# INDvest Mutual Fund Analyser

Use this skill to perform empirical, data-driven research, screening, and comparison of Indian mutual funds. The skill leverages the INDvest analytics API to evaluate funds on true investor cash flows (point-in-time SIP XIRR) and daily rolling return distributions across full market cycles, rather than misleading point-to-point CAGRs.

---

## 1. Operating Objectives

1. **Empirical Cash Flows:** Analyze real-world systematic investment outcomes (SIP XIRR) across arbitrary historical horizons.
2. **Rolling Return Consistency:** Evaluate funds across thousands of rolling observation windows (1, 3, 5, 7, 10, 12, 15 years) to isolate structural manager skill from cyclical luck.
3. **Cross-Sectional Screening:** Filter and rank categories (Large Cap, Mid Cap, Small Cap, Flexi Cap, etc.) by multi-horizon performance, risk metrics, and portfolio character.
4. **Peer & Benchmark Attribution:** Objectively benchmark funds against their category averages and their mapped NSE index. Index data is **price-return** — total-return (TRI) series are not available, so never cite a TRI figure.

---

## 2. Non-Negotiable Rules & Security

1. **Zero Hardcoded Credentials:** Never store or log API keys in prompt text, scripts, or output documents. Always read the API token from the `INDVEST_API_TOKEN` environment variable or fallback to `~/.config/indvest/token`. If neither is found, pause and prompt the user.
2. **Direct-Growth Baseline:** Use `fundOption == "Direct"` and `fundType == "Growth"`. The platform tracks only Direct-Growth schemes (plus ETFs), so Regular and IDCW plans are not in the dataset — never substitute them, and never present a Regular or IDCW figure as if it were available.
3. **Fact vs. Interpretation:** Never fabricate or extrapolate return numbers. Every percentage must cite the exact observation window, start/end dates, or rolling sample size.
4. **No Vague Adjectives:** Avoid marketing fluff ("stellar returns", "massive compounder"). State the rank, the metric, the benchmark spread, and the standard deviation.
5. **No Blind Point-to-Point CAGR:** Always pair point-to-point trailing returns with rolling return distributions. Trailing point-in-time metrics highlight recent momentum; rolling metrics measure long-term durability.
6. **Scale Awareness Without AUM:** The API does **not** expose assets under management. Never state, estimate, or infer an AUM figure from any endpoint. Where scale matters (small-cap and micro-cap capacity constraints), reason only from what the API does provide — portfolio holdings count, top-10 stock concentration, and the depth of available history (`maxAvailableDurationMonths` in the screener payload) — and say explicitly that AUM was not available.

---

## 3. INDvest Data Engine Protocol

- **Base Endpoint:** `https://api.indvested.com/api`
- **Authentication:** Header `x-api-token: <INDVEST_API_TOKEN>`
- **Content Type:** `application/json`
- **Errors:** every failure returns a single `message` field, whatever the status code — never an `error` or `reason` key. A `403` with a `message` means the token is missing, expired, revoked, or over quota. A `404` usually means the metric cache is not populated for that fund, not that the fund is missing.
- **Rate Limit:** 120 requests per minute per IP, applied to every path including `/ping` and `/health`. Exceeding it returns `429` with `{"message": "Too many requests"}`. On a `429`, back off for a minute rather than retrying immediately.

### Core Primitives

| Endpoint | Method | Purpose | Input / Payload | Key Output Fields |
| :--- | :---: | :--- | :--- | :--- |
| `/mf/get_all_mutual_funds` | `GET` | Catalog discovery & category filtering | None | `id`, `fundName`, `ISINCode`, `assetClass`, `assetClassSubCategory`, `fundOption`, `fundType`, `metaData` (`TER`, `NAV`, `NAVDate`) |
| `/mf/compare_mutual_funds` | `POST` | Batch rolling and SIP-XIRR statistics | `{"schemeCodes": ["ISIN1", "ISIN2", ...]}` | `funds[].rollingReturnSummary` (rolling CAGR statistics per duration), `funds[].xirrSummary` (SIP XIRR statistics per duration: `xirr`, `xirrMedian`, `xirrMin`, `xirrMax`) |
| `/mf/get_mutual_fund_details/{id}` | `GET` | Full metric set for one fund | Path param `id` (scheme ID from the catalog) | `xirrMetricsFromDailyNAVData`, `drawdownMetrics`, `benchmarkComparisonMetrics`, `metaData` |
| `/mf/get_mutual_fund_nav_history/{isin}` | `GET` | Published + adjusted NAV history | Path param ISIN; query `mode` (`daily` or `monthly`), `limit`, `from`, `to` | `history[]`, `navAdjustment` |
| `/mf/screen` | `GET` | Server-side filter by metric thresholds | Query params: `subcategory`, `amc`, `max_ter`, `min_alpha`, `max_beta`, `min_history_years`, `min_rolling_return_{1y,3y,5y}`, `sort_by`, `limit` | `funds[]` incl. `maxAvailableDurationMonths`, `TER` |
| `/mf/fund_overlap` | `POST` | Pairwise holdings overlap, 2–10 funds | `{"fundIds": [123, 456, ...]}` | `overlapMatrix`, `sharedHoldings`, `fundSummaries` |
| `/mf/portfolio_overlap` | `POST` | Stock and sector concentration of a portfolio | `{"portfolio": [{"fundId": 123, "allocationPercentage": 40}, ...]}` | `effectiveStockExposure`, `concentrationMetrics.top10StockConcentration`, `sectorExposure` |
| `/mf/get_ai_insights/{id}` | `GET` | Weekly AI-generated fund synthesis | Path param `id` (scheme ID) | `performanceSummary`, `riskAnalysis`, `portfolioComposition`, `categoryPositioning`, `investorSuitability`, `keyStrengths`, `keyConcerns` |

### Two different "return" numbers — do not conflate them

- **Rolling return** (`rollingReturnSummary`) is the CAGR of point-to-point holding windows (buy at the start, sell at the end), with `meanReturn`, `medianReturn`, `minReturn`, `maxReturn`, `standardDeviation`, `sharpeRatio`, `sortinoRatio`, `percentOfWindowsWithPositiveReturn`.
- **SIP XIRR** (`xirrSummary`) is the money-weighted return on a monthly systematic investment, with `xirr`, `xirrMedian`, `xirrMin`, `xirrMax` — it has **no** standard deviation field.

Never label a rolling-return figure as a "rolling SIP return", or vice versa.

### Agent Engineering Guidelines

- **Batching Constraint:** `/mf/compare_mutual_funds` requires at least 2 ISINs and accepts at most 10 per request — an 11th ISIN is a `400`. Chunk larger universes into batches of 10.
- **Request Budget:** You have 120 requests per minute per IP. Screening a 200-fund universe costs about 20 `/mf/compare_mutual_funds` calls, which is comfortable; the expensive mistake is calling `/mf/get_mutual_fund_details` once per fund. Compare the whole universe first, then fetch details only for the 10–20 funds you will actually report on. If you do hit a `429`, wait a minute — immediate retries just burn the window again.
- **Large Response:** `/mf/get_mutual_fund_details/{id}` returns **one large JSON document, not a stream** — roughly half a megabyte, and it grows with fund age. Its per-window `dataset` arrays hold thousands of rows across the seven durations (the compute caps each duration at 365 × its year count). Read the series you need directly: `xirrMetricsFromDailyNAVData.dataset["12"]`. Each row is a *window aggregate* — `fromDate` / `toDate` (format `DD-MM-YYYY`), `totalActualInvestedAmount`, `finalNav`, `presentInvestmentValue`, `xirr` — not per-instalment cash flows. Rows are newest-first, so `dataset["12"][0]` is the most recent trailing 12-month SIP XIRR. If all you need is NAV rows, call `/mf/get_mutual_fund_nav_history/{isin}?limit=N` instead.
- **NAV is a pair:** every NAV surface returns `publishedNAV` (what AMFI published, possibly `null`) beside `adjustedNAV` (the rescaled series used for all metrics). `NAV` is a legacy alias of the adjusted value. Cite the adjusted series for any return claim.

---

## 4. Execution Workflow

When tasked with researching, screening, or reviewing funds:

### Phase 1: Universe Definition & Ingestion
1. Verify the `INDVEST_API_TOKEN` environment variable.
2. Query `/mf/get_all_mutual_funds` and filter to the relevant subcategory (e.g., `assetClassSubCategory == "Flexi Cap Fund"`).
3. Confirm `fundOption == "Direct"` and `fundType == "Growth"`.

### Phase 2: Quantitative Extraction
1. **Multi-Horizon Rolling Returns and SIP XIRR:** Query `/mf/compare_mutual_funds` in batches of up to 10 ISINs to extract both `rollingReturnSummary` (rolling CAGR mean, median, min, max, standard deviation) and `xirrSummary` (SIP XIRR mean, median, min, max) across 1Y (12m), 3Y (36m), 5Y (60m), and 7Y (84m).
2. **Point-in-Time Trailing SIP Window:** For the funds that matter, read `xirrMetricsFromDailyNAVData.dataset["12"][0]` from `/mf/get_mutual_fund_details/{id}` — the newest 12-month trailing SIP window. Fetch details only for a shortlist, never for the whole universe.
3. **Risk and Quality Data:** Pull `drawdownMetrics` (max drawdown, recovery days, Calmar by duration) and `benchmarkComparisonMetrics` (beta, alpha, upside/downside capture) for the shortlist. Both come from the same details payload.

### Phase 3: Matrix Screening & Triangulation
1. Rank funds across composite metrics:
   - Trailing 1Y SIP XIRR (recent momentum / cash flow reality)
   - Rolling 1Y / 3Y / 5Y return (cycle-neutral manager skill, mean CAGR)
   - Downside capture / minimum rolling windows (drawdown defense)
2. Reconcile with institutional quality signals (e.g., CRISIL rankings for volatility/concentration, Morningstar Medalist ratings for team/process durability). These ratings are **external** — the API does not provide them. Label them as third-party and do not imply INDvest computed them.
3. Check pairwise portfolio overlap with `/mf/fund_overlap` to avoid recommending funds with high portfolio commonality. Say so plainly when overlap data is unavailable for a fund, rather than assuming low overlap.
4. Where scale is relevant, note that AUM is not available from the API and reason from holdings concentration and history depth instead (see Rule 6).

### Phase 4: Structured Output
Always present findings in clean Markdown tables formatted as follows:

| # | Fund Name | Trailing 1Y SIP XIRR | 1Y Rolling Return (mean CAGR) | 5Y Rolling Return (mean CAGR) | TER (%) | Institutional Rating |
| :-: | :--- | :---: | :---: | :---: | :---: | :--- |
| 1 | Scheme A | X.XX% | X.XX% | X.XX% | 0.XX | CRISIL R1 / Morningstar Silver |

Conclude with:
- **Key Empirical Takeaways:** Bulleted findings highlighting momentum-vs-rolling consistency gaps, style divergence, or concentration risk. Do not discuss AUM drag — the data is unavailable.
- **Data Freshness Notice:** Explicit as-of date for all metrics (use `metaData.NAVDate`).
- **Data Attribution:** Standard citation crediting INDvest (`https://indvest.io`) for rolling calculation and point-in-time SIP infrastructure.
