# How the Portfolio-Review Skill Manages and Optimizes Investment Portfolios

> Discover how the portfolio-review skill optimizes investment portfolios. Learn about its six-stage pipeline for data normalization, risk analysis, and rebalancing recommendations.

- Repository: [Xbt Lin/ai-berkshire](https://github.com/xbtlin/ai-berkshire)
- Tags: deep-dive
- Published: 2026-07-25

---

**TLDR:** The **portfolio-review** skill implements a structured six-stage pipeline that normalizes holdings, enriches market data, evaluates position health, analyzes portfolio-level risks, and generates actionable rebalancing recommendations.

The **portfolio-review** skill in the `xbtlin/ai-berkshire` repository delivers an automated framework for disciplined portfolio management. Defined in [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md), this skill transforms raw holding lists into data-driven analyses aligned with Buffett-style concentration principles and Li Lu's deep-dive methodology.

## Structured Input Handling and Data Acquisition

The skill accepts three distinct input formats as defined in lines 5-12 of [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md): percentage allocations, share-count lists with entry prices, or previously saved portfolio files. All inputs normalize into a structured table containing *symbol, code, quantity, cost, market price, market value, weight*, and *P/L*.

Once normalized, a background **Task** agent launches parallel web-searches for each holding to retrieve current valuations, quarterly financial changes, recent material events, and analyst consensus data including forward PE and target prices (lines 37-44). The `tools/financial_rigor.py verify‑valuation` utility validates this raw data, assigning each holding an information-richness grade of A, B, or C (lines 45-46).

## Position-Level Health Verification

Every holding undergoes a rapid health-check against three binary criteria, including the critical question: "Would you still buy at today's price?" (lines 56-60). The skill evaluates current PE ratios, investment thesis validity, and assigns a "paper health" score alongside specific position-size recommendations (lines 49-55). This position-level granularity ensures each individual holding meets quality thresholds before portfolio-level optimization begins.

## Comprehensive Risk Assessment

The skill executes four parallel analytical streams to assess aggregate portfolio health as implemented in lines 65-121 of [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md).

**Concentration Metrics** calculate the largest holding weight, top-three concentration percentage, total position count, and cash ratio. The skill compares these metrics against strict Buffett- and Li Lu-style thresholds to detect dangerous over-concentration or excessive diversification (lines 65-72).

**Correlation Detection** identifies hidden linkages between holdings through industry overlap, supply chain dependencies, and shared macro exposure to flag unseen risk concentrations (lines 78-86).

**Opportunity Cost Analysis** leverages `tools/financial_rigor.py three‑scenario` to estimate expected annualized returns for each position. The skill compares low-ranked holdings against a 4% cash benchmark to identify capital reallocation opportunities (lines 94-110).

**Macro Stress-Testing** simulates qualitative scenarios including global recession, US-China tensions, interest rate hikes, and tech bubble bursts to estimate maximum drawdown and portfolio resilience (lines 113-121).

## Actionable Optimization and Rebalancing

Based on the diagnostic outputs, the skill generates a concrete rebalancing table categorizing each position as **add**, **reduce**, **liquidate**, **new position**, or **hold**, complete with specific rationale (lines 127-145). For underperforming "cash-like" slots, the skill suggests alternative targets via `/industry-research` or `/investment-checklist` invocations. Cash-level management advice accompanies specific position recommendations to maintain optimal liquidity buffers.

## Persistent Reporting

The final output follows a fixed markdown template comprising an overview, single-position health check, portfolio analysis, action plan, and next review date (lines 52-66, 74-81). This structured report writes permanently to [`reports/portfolio-latest.md`](https://github.com/xbtlin/ai-berkshire/blob/main/reports/portfolio-latest.md), enabling incremental updates and historical tracking for subsequent reviews.

## Practical Usage Examples

You can invoke the **portfolio-review** skill through natural language commands in the chat interface. For percentage-based allocations:

```text
/portfolio-review 腾讯30%, 美团20%, 茅台20%, 英伟达15%, 现金15%

```

For share-count notation with cost basis:

```text
/portfolio-review 腾讯 500股 @480港元, 美团 1000股 @130港元

```

To re-use the most recent saved portfolio:

```text
/portfolio-review 我的持仓

```

For programmatic access from external scripts:

```python
import requests, json

payload = {
    "model": "gpt-4o",
    "messages": [
        {"role": "user", "content": "/portfolio-review 腾讯30%, 美团20%, 茅台20%, 英伟达15%, 现金15%"}
    ]
}
response = requests.post("https://api.openai.com/v1/chat/completions",
                         headers={"Authorization": "Bearer YOUR_KEY"},
                         json=payload)
print(response.json()["choices"][0]["message"]["content"])

```

The generated report follows a structured markdown format:

```text
一、组合概览
| 标的 | 持仓量 | 成本价 | 现价 | 市值 | 占比 | 盈亏 |
|------|--------|--------|------|------|------|------|
| 腾讯 | 500   | 480   | 520 | $260k | 30% | +8% |
| ……

二、单仓位体检
| 标的 | 当前PE | 买入逻辑是否变化 | 论文健康度 | 仓位建议 |
|------|--------|-------------------|------------|----------|
| 美团 | 25x   | 竞争加剧          | 6/10       | 偏高，考虑减仓 |

```

## Summary

- The **portfolio-review** skill in [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md) provides a six-stage pipeline covering data normalization, market retrieval, position health checks, portfolio risk analysis, optimization, and persistent reporting.
- **Data validation** occurs through `tools/financial_rigor.py verify‑valuation` with A/B/C grading, while **return projections** use the `three‑scenario` function.
- The skill enforces **Buffett- and Li Lu-style concentration discipline** through threshold-based concentration metrics and opportunity cost analysis against a 4% cash benchmark.
- **Stress-testing** covers macro scenarios including global recession, US-China tensions, rate hikes, and tech bubble bursts.
- Output persists to [`reports/portfolio-latest.md`](https://github.com/xbtlin/ai-berkshire/blob/main/reports/portfolio-latest.md) for incremental review cycles.

## Frequently Asked Questions

### What input formats does the portfolio-review skill accept?

The skill accepts percentage allocations (e.g., "腾讯30%"), share-count notation with prices (e.g., "腾讯 500股 @480港元"), or references to saved portfolio files (e.g., "我的持仓"). All formats normalize into a standardized table containing symbol, quantity, cost basis, and current market data as defined in [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md) lines 5-12.

### How does the skill validate financial data quality?

A background Task agent retrieves market data, then `tools/financial_rigor.py verify‑valuation` validates the raw inputs and assigns each holding an information-richness grade of A, B, or C. This validation ensures that subsequent PE calculations and scenario analyses rest on verified fundamentals rather than stale or speculative data.

### What criteria determine position-specific recommendations?

The skill applies three binary checklist items including "Would you still buy at today's price?" to each holding. Combined with current PE ratios, thesis validity checks, and "paper health" scores from [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md) lines 56-60, these criteria determine whether to categorize a position as add, reduce, liquidate, or hold.

### How does the portfolio-review skill calculate opportunity costs?

The skill calls `tools/financial_rigor.py three‑scenario` to estimate expected annualized returns for each position, then ranks holdings against a 4% risk-free cash benchmark. Positions projected to underperform this threshold trigger reallocation recommendations toward higher-conviction opportunities identified via `/industry-research` or `/investment-checklist`.