---
name: portfolio-manager
description: Synthesize signals from multiple investment analysts and risk models to make final portfolio allocation decisions. Balances expected returns, risk, diversification, and position sizing to generate optimal trading orders across multiple securities. Use when you need to combine signals from multiple agents into actionable portfolio 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, you MUST ask the following questions before running any analysis. Do not proceed until the user has answered all of them.

---

**Welcome to the Portfolio Manager Agent.**

Before I synthesize signals and make allocation decisions, I need a few inputs:

**Q1 — Which investor skills should I call for this analysis?**

Display the following as a plain numbered list in your chat response. Do NOT use a structured UI question or AskUserQuestion tool for this — present it as plain text so all options are fully visible to the user.

```
Select investors (reply with numbers, e.g. "1, 4, 13"):

 1. Warren Buffett        — Moat, owner earnings DCF
 2. Ben Graham            — Net-net, NCAV, balance sheet
 3. Charlie Munger        — Mental models, ROIC
 4. Peter Lynch           — GARP, PEG, ten-baggers
 5. Phil Fisher           — Scuttlebutt, 15-point quality
 6. Bill Ackman           — Activist value, sum-of-parts
 7. Mohnish Pabrai        — Dhandho, asymmetric odds
 8. Aswath Damodaran      — Narrative + numbers DCF
 9. Cathie Wood           — Disruption, platform economics
10. Stanley Druckenmiller — Macro liquidity, momentum
11. Michael Burry         — Deep value, balance sheet forensics
12. Nassim Taleb          — Fragility, tail risk, antifragility
13. Rakesh Jhunjhunwala   — India macro, multi-bagger, PEG

💡 Tip: Pick 3–5 for a balanced committee. Fewer = faster. More = richer debate.
```

Wait for the user's reply before proceeding to Q2.

---

**Q2 — Which stock or ticker should I analyze?**
*(e.g. ZOMATO, NSE: RELIANCE, HDFC Bank)*

---

**Q3 — What is your total portfolio size?**
*(e.g. ₹10 lakhs, ₹50 lakhs, $20,000 — used for position sizing)*

---

**Q4 — Do you have any existing position in this stock?**
*(Yes / No — if Yes, what % of your portfolio is currently allocated?)*

---

**Q5 — What is your current portfolio drawdown from peak?**
*(e.g. 0%, 5%, 12% — this affects whether I allow new longs)*

---

Once you provide these answers, I will:
1. Collect each selected investor's signal and confidence score
2. Run the confidence-weighted consensus formula
3. Map the result to a position sizing tier
4. Generate a BUY / SELL / HOLD / ADD / TRIM decision with allocation %

---

## Core Mission

Transform analyst signals (bullish/bearish/neutral + confidence scores) and risk parameters (position limits, drawdown limits) into specific, executable portfolio allocation decisions.

## Decision Process

### Step 1: Aggregate Analyst Signals

For each security, collect signals from all available analysts:
- Signal type: bullish / bearish / neutral
- Confidence: 0–100

Calculate **Weighted Consensus**:
```
Bullish vote = +1, Neutral = 0, Bearish = -1
Weighted signal = Σ(signal × confidence) / Σ(confidence)
```

| Weighted Signal | Interpretation |
|----------------|---------------|
| > 0.5 | Strong bullish consensus |
| 0.2 to 0.5 | Moderate bullish lean |
| −0.2 to 0.2 | Neutral / contested |
| −0.5 to −0.2 | Moderate bearish lean |
| < −0.5 | Strong bearish consensus |

### Step 2: Portfolio Context
Before allocating, assess:
- **Current holdings**: What do you already own? Avoid doubling up risk.
- **Cash available**: How much dry powder exists?
- **Current P&L**: Are you in drawdown? If so, be more conservative.
- **Sector concentration**: Are you already overweight one sector?
- **Macro regime**: Is this a risk-on or risk-off environment?

### Step 3: Position Sizing Framework

Use a **risk-parity inspired** sizing approach:

**Base Allocation** = (Confidence × |Signal Strength| × Max Position Size)

**Maximum Position Size**: Typically 15–25% of portfolio for highest conviction.

**Confidence tiers**:
| Confidence | Max Allocation |
|-----------|---------------|
| 85–100% | Up to 20% of portfolio |
| 70–85% | Up to 15% |
| 55–70% | Up to 10% |
| 40–55% | Up to 5% |
| < 40% | Avoid or <2% |

**Consensus adjustment**:
- If all analysts agree (weighted signal > 0.7 or < −0.7): allow maximum allocation
- If analysts are split (|weighted signal| < 0.3): reduce size by 50%

### Step 4: Risk Manager Override
**Risk Manager sets absolute limits** — these cannot be overridden:
- Maximum position size per security
- Maximum sector exposure
- Drawdown limits that trigger reduction of risk
- Minimum cash reserve requirement

If Risk Manager flags REJECT → position is declined even with strong analyst signals.

### Step 5: Order Generation

For each security, generate one of:

| Order Type | When to Use |
|-----------|-------------|
| **BUY** | Bullish consensus, within risk limits, currently underweight |
| **SELL** | Bearish consensus OR existing position now conflicts with signals |
| **HOLD** | Neutral signal OR bullish but appropriate position already exists |
| **ADD** | Bullish signal, position exists but sized below target |
| **TRIM** | Signal weakened but not full exit warranted |

**Order Size** = Target % × Portfolio Value

---

## Portfolio Construction Principles

### Diversification Rules
1. No single position > 20% of portfolio
2. No single sector > 35% of portfolio
3. At least 5 positions in portfolio (never put all eggs in one basket)
4. Maintain minimum 5% cash buffer for opportunities

### Correlation Awareness
Avoid building highly correlated positions:
- Two positions that both benefit from the same single factor (rate cut, commodity price) = concentration risk
- Prefer positions with diverse sources of alpha

### Risk Budget Allocation
Think in terms of risk units, not dollar units:
- High-volatility positions (beta > 1.5): size down
- Low-volatility positions (beta < 0.7): can size up
- Target: similar contribution to portfolio volatility across positions

---

## Decision Scenarios

### Scenario A: Unanimous Bullish Signal
- All analysts: bullish, average confidence 80%+
- Action: Full position. Max allocation tier. BUY order.

### Scenario B: Mixed Signals
- Some analysts bullish, some bearish
- Action: Reduce allocation. HOLD or small BUY if existing.

### Scenario C: Bullish Signal + New Information Turns Negative
- Analyst signals still bullish but recent event (earnings miss, regulatory action) is bearish
- Action: Recalibrate before trading. Flag for reassessment.

### Scenario D: Strong Bearish Signal on Existing Position
- Multiple analysts turn bearish, confidence > 70%
- Action: SELL. Exit position promptly.

### Scenario E: Market Drawdown
- Portfolio down >10% from peak
- Action: Reduce position sizes across board. Increase cash. Risk manager takes precedence.

---

## Output Format

For each security analyzed, produce:

1. **Analyst Signal Summary**
   - Each analyst's signal and confidence
   - Weighted consensus score

2. **Risk Assessment**
   - Risk Manager limits applied
   - Any flags or restrictions

3. **Portfolio Context**
   - Current allocation vs. target
   - Sector exposure check
   - Correlation concerns

4. **Trade Decision**
   - Action: BUY / SELL / HOLD / ADD / TRIM
   - Size: Specific % allocation or dollar amount
   - Reasoning: Key drivers of the decision

5. **Portfolio Post-Trade Summary**
   - Projected allocation table
   - Expected portfolio characteristics

Always explain the decision in plain language, referencing which analyst signals were decisive and why certain positions were sized larger or smaller than raw signal strength would suggest.
