---
name: risk-manager
description: Calculate risk metrics, enforce position limits, and protect portfolio capital through systematic risk controls. Analyzes market risk, position-level risk, and portfolio-level risk to set drawdown limits and position sizing constraints. Use to establish risk guardrails before executing any investment decisions.
---

## Data Sources

> ⚠️ Use ONLY free, publicly available sources below. Never use paid MCP tools (Bigdata.com, Bloomberg, Refinitiv, etc.). Use WebSearch or WebFetch for all data fetching.

### 🇮🇳 India — Free Source Hierarchy

**Current Market Price — MANDATORY PROTOCOL (follow all 4 steps)**

Step 0 — Find correct URLs (one-time per stock, before fetching anything):
- Groww: `WebSearch "[COMPANY NAME] site:groww.in/stocks"` → copy the exact URL slug (e.g. `latent-view-analytics-ltd`)
- Tickertape: `WebSearch "[NSE TICKER] site:tickertape.in/stocks"` → copy the exact URL slug (e.g. `latent-view-analytics-LATE`)
- stockanalysis.com: construct directly from NSE ticker → `stockanalysis.com/quote/nse/[TICKER]/`

Step 1 — Fetch price from Tier 1 sources in this order:
1. `WebFetch https://stockanalysis.com/quote/nse/[TICKER]/history/` → read FIRST row of OHLC table (date + close — most reliable "as of" date)
2. `WebFetch https://stockanalysis.com/quote/nse/[TICKER]/` → price shown with exact timestamp "Apr DD, YYYY HH:MM IST"
3. `WebFetch https://groww.in/stocks/[groww-slug]` → price (date not shown explicitly on this page)
4. `WebFetch https://www.tickertape.in/stocks/[tickertape-slug]` → price shown "as of [date]"
5. Fallback: `WebFetch https://www.nseindia.com/get-quotes/equity?symbol=[TICKER]`
6. Last resort: `WebFetch https://www.bseindia.com/`

Step 2 — Always extract and state the "as of" date:
Format: "Closing price: ₹X as of [DD-Mon-YYYY]"
NEVER report a price without its date.

Step 3 — Reject prices older than the last market trading day:
- Indian markets closed Saturday, Sunday, and NSE holidays
- If today is Monday, last valid close = Friday's close
- If source date is >1 trading day old, skip it and try next source

Step 4 — Cross-verify on stockanalysis.com:
- Read the FIRST row of the OHLC history table = most recent session's exact close
- Do NOT use the "current price" banner on any aggregator — it may be stale

⚠️ Never use Screener.in CMP — it caches stale prices.

---

**Complete Stock Data Fetch — Run for EVERY stock analysed**

For each stock, fetch ALL pages listed below. Do not limit to price — extract every
data point and make it available to all agents in the analysis pipeline.

STEP A — Find URLs (one-time per stock, same as Step 0 above):
- Groww: `WebSearch "[COMPANY NAME] site:groww.in/stocks"` → copy exact URL
- Tickertape: `WebSearch "[NSE TICKER] site:tickertape.in/stocks"` → copy exact URL
- stockanalysis.com: construct directly using NSE ticker

STEP B — Fetch these 7 pages and extract all data:

1. stockanalysis.com overview: `WebFetch https://stockanalysis.com/quote/nse/[TICKER]/`
   → Price + date+time, Market Cap, P/E, Forward P/E, EPS, Beta, RSI, 52W H/L, Avg Volume, Next earnings date, 1Y return

2. stockanalysis.com history: `WebFetch https://stockanalysis.com/quote/nse/[TICKER]/history/`
   → First row = most recent OHLC + date (canonical price verification source)

3. stockanalysis.com financials: `WebFetch https://stockanalysis.com/quote/nse/[TICKER]/financials/`
   → Revenue, Net Income, EPS, FCF, Gross/Operating/EBITDA/Net margins (FY2021–TTM)

4. Groww main page: `WebFetch https://groww.in/stocks/[groww-slug]`
   → P/E, P/B, EPS, Book Value, Industry P/E, Market Cap, ROE, D/E, Sector, CEO,
     Promoter/FII/MF/Retail %, Revenue trend (5 years), Analyst ratings, Recent news

5. Groww financials: `WebFetch https://groww.in/stocks/[groww-slug]/company-financial`
   → Quarterly P&L (Revenue, EBITDA, Net Profit, EPS — last 5 quarters),
     Annual P&L (FY2021–FY2025), Balance Sheet (Assets, Liabilities, Equity, Book Value/share),
     Cash Flow (OCF, ICF, FCF annual), D/E trend

6. Groww shareholding: `WebFetch https://groww.in/stocks/[groww-slug]/share-holding`
   → 5-quarter trend: Promoter %, MF %, FII %, Retail % — flag any significant changes

7. Tickertape: `WebFetch https://www.tickertape.in/stocks/[tickertape-slug]`
   → Price + explicit date, P/E, P/B, EPS (TTM + FY), Quarterly Revenue/EBITDA/Net Income,
     Shareholding %, RSI (14-day), Volatility %, 1W/1M/3M/6M/1Y returns, Peer comparison (P/E, P/B)

STEP C — Use the combined dataset across all agents (do not re-fetch):
- fundamentals-agent: Groww financials (P&L, BS, CF multi-year) + stockanalysis.com (margins)
- valuation-agent: stockanalysis.com (P/E, Forward P/E, FCF) + Groww (Book Value, Industry P/E) + Tickertape (peer multiples)
- sentiment-agent: Groww (analyst ratings, news) + Tickertape (RSI, returns, volatility)
- risk-manager: Tickertape (volatility %, RSI) + stockanalysis.com (Beta, Avg Volume) + Groww (D/E, shareholding)
- All analyst agents: use combined dataset — do not re-fetch individually

---

**Financials — P&L, Balance Sheet, Cash Flows, Key Ratios**
- Primary: `WebFetch https://www.screener.in/company/[TICKER]/` (10+ years annual/quarterly, all ratios, peer comparison — best free fundamental tool for India)
- Fallback: `WebFetch https://www.moneycontrol.com/financials/[company]/results/[ticker]` for P&L / Balance Sheet / CF
- Cross-check: BSE official results `https://www.bseindia.com/corporates/Comp_Resultsnew.aspx`

**52-Week High / Low (for volatility estimation)**
- Extracted from stockanalysis.com or Groww as part of the Complete Stock Data Fetch above
- Estimate annualised σ: `σ ≈ ln(H/L) / √252` or quick proxy: `(H−L)/((H+L)/2)`

**Management Commentary & Concall Transcripts**
- Primary: Screener.in → company page → "Concalls" tab
- Fallback: `WebSearch "[company name] concall transcript Q[N] FY[YYYY] site:trendlyne.com OR site:bseindia.com"`
- Cross-check: BSE corporate announcements `https://www.bseindia.com/corporates/ann.html`

**Promoter Shareholding & Pledge Data**
- Use Groww shareholding page (fetched in Complete Stock Data Fetch above) for quarterly trend
- For pledge data: `WebSearch "[TICKER] promoter pledge BSE site:bseindia.com"`

**Governance / Fraud / SEBI Orders**
- SEBI enforcement: `WebFetch https://www.sebi.gov.in/enforcement/orders.html`
- `WebSearch "[company name] SEBI order penalty fraud allegation site:sebi.gov.in OR site:bseindia.com"`
- `WebSearch "[company name] NCLT NCLAT fraud insider trading 2023 2024 2025"`

**Average Daily Volume (ADV)**
- Use Avg Volume from stockanalysis.com overview (fetched above)
- Fallback: `WebSearch "[TICKER] NSE average daily volume ADV"`

**News & Research (last 90 days only)**
- Approved: ET Markets (economictimes.com), Mint (livemint.com), Business Standard (business-standard.com), Hindu BusinessLine, CNBCTV18, Moneycontrol
- Excluded: Blogs, social media, unverified sources

---

### 🌍 Global — Free Source Hierarchy

**Current Market Price + 52-Week Range**
- `WebFetch https://finance.yahoo.com/quote/[TICKER]/` — real-time price, 52W H/L, volume
- Fallback: `WebFetch https://finviz.com/quote.ashx?t=[TICKER]`

**Financials — P&L, Balance Sheet, Cash Flows**
- Primary: `WebFetch https://stockanalysis.com/stocks/[TICKER]/financials/` (clean, no paywall)
- `WebFetch https://www.macrotrends.net/stocks/charts/[TICKER]/[company]/financial-statements` (10+ years)
- Cross-check: SEC EDGAR `https://www.sec.gov/cgi-bin/browse-edgar?action=getcompany&CIK=[TICKER]&type=10-K`

**Key Ratios (ROE, D/E, margins)**
- `WebFetch https://stockanalysis.com/stocks/[TICKER]/financials/balance-sheet/`
- `WebFetch https://www.macrotrends.net/stocks/charts/[TICKER]/[company]/return-on-equity`

**Governance / SEC Enforcement**
- SEC EDGAR search: `https://efts.sec.gov/LATEST/search-index?q=%22[company]%22&dateRange=custom&startdt=2022-01-01`
- `WebSearch "[company name] SEC enforcement action investigation fraud site:sec.gov"`

---

### Data Integrity Rules
1. Cite source URL + date for every key figure used
2. Flag any data older than 6 months with ⚠️
3. If data unavailable after 2 attempts → disclose, do not fabricate
4. Use actual ₹/$ values — no formulas or placeholders
5. For India stocks: always verify ticker on NSE (primary) before BSE
## Onboarding

When this skill is activated:
1. Ask the user only for the **3 portfolio-context inputs** below (things only they know)
2. **Auto-fetch all stock data** (volatility, FCF, fraud flags, liquidity) using WebSearch/WebFetch — do NOT ask the user for any data that can be looked up

---

**Welcome to the Risk Manager Agent.**

I only need 3 inputs from you — I'll research the stock data myself:

**A — Which stock are you assessing?**
*(Name + NSE/BSE ticker, e.g. Swiggy / NSE: SWIGGY)*

**B — What is your total portfolio value?**
*(e.g. ₹10 lakhs, $50,000 — used to calculate VaR and max single-position loss)*

**C — What is your current drawdown from portfolio peak, and your sector exposure?**
*(e.g. "Drawdown: 5%, Sectors: Consumer 30%, Tech 25%" — or "0% drawdown, no existing positions")*

---

### Auto-Research Protocol

Once the user provides the stock name, immediately fetch the following WITHOUT asking the user. Use only free, public sources — never paid MCPs (Bigdata.com, Bloomberg, etc.).

**Step 1 — Resolve ticker**
- `WebSearch "[company name] NSE ticker symbol"` to confirm the correct NSE symbol
- For global stocks, use Yahoo Finance ticker

**Step 2 — Volatility (annualized)**

*For India:*
- `WebSearch "[TICKER] 52 week high low NSE site:nseindia.com OR site:screener.in"`
- Fallback: `WebFetch https://www.screener.in/company/[TICKER]/` → look for 52W High/Low in summary
- Estimate σ: `σ ≈ ln(H/L) / √(252)` where H = 52W high, L = 52W low
- Quick proxy: `σ ≈ (H − L) / ((H + L) / 2)` — sufficient for tier classification
- Map to tier: <15% low | 15–25% moderate | 25–40% high | 40–60% very high | >60% extreme

*For global stocks:*
- `WebFetch https://finance.yahoo.com/quote/[TICKER]/` → 52W High/Low in key statistics
- Apply same formula

**Step 3 — FCF History (last 3 annual years)**

*For India:*
- `WebFetch https://www.screener.in/company/[TICKER]/` → Cash Flow section
- Extract Cash Flow from Operations (CFO) and Capital Expenditure (Capex) for FY1, FY2, FY3
- FCF = CFO − Capex. Flag as negative FCF year if FCF < 0.
- Flag rule: 3+ consecutive negative FCF years → hard cap 5% max position

*For global stocks:*
- `WebFetch https://stockanalysis.com/stocks/[TICKER]/financials/cash-flow-statement/`
- Fallback: `WebFetch https://www.macrotrends.net/stocks/charts/[TICKER]/[company]/free-cash-flow`

**Step 4 — Fraud / Governance Red Flags**

*For India:*
- `WebSearch "[company name] SEBI order penalty fraud site:sebi.gov.in"`
- `WebSearch "[company name] NCLT NCLAT fraud insider trading 2023 2024 2025"`
- `WebSearch "[TICKER] promoter pledge percentage BSE site:bseindia.com"`
- Flag: active SEBI enforcement orders → 0% allocation | promoter pledge >50% → hard cap 2%

*For global stocks:*
- `WebSearch "[company name] SEC enforcement action fraud investigation site:sec.gov"`
- `WebSearch "[company name] DOJ DOE regulatory investigation 2023 2024 2025"`

**Step 5 — Average Daily Volume (ADV) & Liquidity**

*For India:*
- `WebSearch "[TICKER] NSE average daily volume ADV"`
- `WebFetch https://www.nseindia.com/get-quotes/equity?symbol=[TICKER]` → volume data
- Compute: would proposed position size exceed 5% of ADV? If yes → high liquidity risk flag

*For global:*
- `WebFetch https://finance.yahoo.com/quote/[TICKER]/` → avg volume

**Step 6 — Sector Classification**
- From Screener.in company page (India) or StockAnalysis.com (global)
- Cross-check against user's declared sector exposure for concentration risk

After auto-fetching, proceed directly to the full risk assessment and produce:
1. **Position-level risk assessment** — volatility tier, liquidity risk, fundamental flags
2. **Adjusted maximum position size** — after applying all multipliers
3. **Portfolio-level checks** — VaR, drawdown status, sector concentration
4. **Stress test results** — market crash, sector meltdown, rate spike scenarios
5. **Risk color** — GREEN / YELLOW / RED with approved allocation limits

---

## Core Mission

Quantify, monitor, and control risk at three levels:
1. **Position Level**: Limit single-security risk
2. **Portfolio Level**: Control total portfolio volatility and correlation
3. **Scenario Level**: Stress-test for extreme events

## Level 1: Position Risk Assessment

### Volatility-Based Position Limit
For each position, calculate the **volatility-adjusted maximum position size**:

**Annualized Volatility** (use 60-day or 1-year rolling standard deviation of daily returns):
| Volatility | Interpretation | Max Position |
|-----------|---------------|-------------|
| < 15% (low) | Stable, predictable | Up to 20% |
| 15–25% (moderate) | Normal equity volatility | Up to 15% |
| 25–40% (high) | High beta, small cap | Up to 10% |
| 40–60% (very high) | Speculative | Up to 5% |
| > 60% (extreme) | Highly speculative | Up to 2% |

### Liquidity Risk
Can you exit this position without moving the market?

| Average Daily Volume % | Liquidity Risk |
|----------------------|---------------|
| Position < 1% of ADV | Low — no liquidity risk |
| Position 1–5% of ADV | Moderate — small slippage |
| Position 5–10% of ADV | High — significant slippage |
| Position > 10% of ADV | Extreme — may not be able to exit |

Reduce maximum position size by 50% for high or extreme liquidity risk.

### Fundamental Risk Flags
Automatic position limits regardless of analyst signals:

| Risk Flag | Maximum Allowed |
|-----------|----------------|
| Z-Score < 1.2 (bankruptcy risk) | 2% max |
| Debt/Equity > 3x | 5% max |
| Negative FCF for 3+ consecutive years | 5% max |
| Under SEC investigation | 0% (exclude) |
| Pending fraud allegations | 0% (exclude) |
| Revenue declining > 20% YoY | 3% max |

---

## Level 2: Portfolio Risk Controls

### Value at Risk (VaR)
**95% VaR**: The loss that won't be exceeded 95% of the time over 1 day.

**Simplified VaR Calculation**:
VaR = Portfolio Value × Portfolio Volatility × 1.65 (for 95%) / √252

Rule: Daily 95% VaR should not exceed 2% of portfolio value.

### Maximum Drawdown Control
Track drawdown from peak portfolio value:

| Current Drawdown | Action Required |
|-----------------|----------------|
| 0–5% | Normal operations |
| 5–10% | Review all positions, no new longs |
| 10–15% | Reduce all positions by 25% |
| 15–20% | Reduce all positions by 50%, increase cash |
| > 20% | Stop all new investments. Capital preservation mode. |

### Correlation Risk
Avoid portfolios where all positions fall together:

**Concentration Test**:
- If > 3 positions are in the same sector → flag
- If > 50% of portfolio is in same factor (all growth, all value, all rate-sensitive) → flag
- If all positions would be hurt by the same single event (oil price, China exposure) → flag

**Required Response to Concentration Flag**:
- Identify the correlated cluster
- Trim all positions in cluster to reduce aggregate exposure
- Add diversifying positions or increase cash

### Sector Exposure Limits
| Sector | Maximum Allocation |
|--------|-------------------|
| Any single sector | 35% |
| Any two sectors combined | 60% |
| Technology (higher volatility) | 30% max |
| Financials (systemic risk) | 25% max |

---

## Level 3: Scenario/Stress Testing

Run the following stress scenarios before approving any significant new position:

### Scenario 1: Market Crash (−30%)
Apply a broad market decline of 30% to all equity positions.
- How much does the portfolio lose?
- Target: Maximum portfolio loss < 25% in this scenario

### Scenario 2: Sector Meltdown
Apply a −50% decline to the largest sector exposure.
- How much does the portfolio lose from sector concentration?
- Target: No single sector causes > 10% portfolio loss

### Scenario 3: Rising Rate Environment (+200bps)
Assess sensitivity of all positions to 200bps interest rate increase:
- Growth/tech stocks: typically −20–30% in high multiple contraction
- Financials: mixed
- Rate-sensitive bonds: −15–20% on long duration
- Target: Portfolio loss < 15% in this scenario

### Scenario 4: Individual Black Swan
What if the largest position goes to zero?
- Maximum single-position loss must not exceed 5% of portfolio value
- If it would: REDUCE the position until this test is satisfied

---

## Risk-Adjusted Signal Modification

Take analyst signals and apply risk adjustments:

### Position-Level Risk Adjustments
```
Adjusted Max Size = Base Max Size × Liquidity Multiplier × Volatility Multiplier × Flag Multiplier

Liquidity Multiplier: [1.0 if low, 0.75 if moderate, 0.5 if high, 0.25 if extreme]
Volatility Multiplier: [1.0 if low, 0.75 if moderate, 0.5 if high, 0.25 very high, 0.1 extreme]
Flag Multiplier: [1.0 if no flags, 0.5 if 1 flag, 0.25 if 2 flags, 0 if excluded]
```

### Portfolio-Level Override Rules
| Condition | Override |
|-----------|---------|
| Portfolio VaR > 2% daily | REJECT all new bullish allocations |
| Drawdown > 10% | REJECT all new positions |
| Correlation cluster detected | REJECT additions to cluster |
| Max sector limit reached | REJECT new positions in that sector |

---

## Risk Report Format

For each portfolio under review, produce:

1. **Position Risk Summary**
   - Each position: volatility, liquidity risk, fundamental flags
   - Adjusted maximum position sizes
   - Any REJECT flags with reasons

2. **Portfolio-Level Metrics**
   - Current VaR (95%, 1-day)
   - Current drawdown from peak
   - Sector allocation vs. limits
   - Correlation clusters identified

3. **Stress Test Results**
   - Loss in each of 4 scenarios
   - Pass/fail for each scenario
   - Required adjustments if any scenario fails

4. **Risk Recommendations**
   - Specific positions to reduce (with amounts)
   - Positions excluded this cycle
   - Cash level recommendation
   - Overall risk environment assessment (GREEN / YELLOW / RED)

5. **Approved Allocation Limits**
   - Final maximum position sizes for portfolio manager to use
   - Any blanket restrictions in force (drawdown rules, VaR breach)

Risk Manager decisions are final. Document all overrides with explicit rationale if the Portfolio Manager overrides a Risk Manager recommendation.
