How AI Berkshire Automates Portfolio Management and Rebalancing: A Complete Technical Workflow
AI Berkshire transforms raw holding data into concrete rebalancing plans through a multi-step workflow that normalizes inputs, enriches live market data, evaluates asset health, and ranks positions by opportunity cost.
AI Berkshire treats portfolio management and rebalancing as a data-driven pipeline rather than an occasional manual task. According to the xbtlin/ai-berkshire source code, the core logic resides in skills/portfolio-review.md, which orchestrates validation, analysis, and recommendation generation into a reproducible process. This workflow helps investors maintain concentration discipline, identify correlation risks, and optimize cash allocation.
Input Normalization
The workflow accepts three distinct input formats defined in skills/portfolio-review.md (lines 26-33). Investors can submit holdings as percentage allocations, share quantities with prices, or reference a previously saved portfolio file. The system normalizes these disparate formats into a unified tabular holding model before proceeding to analysis.
Live Data Enrichment and Validation
For each position, AI Berkshire launches background tasks to fetch current market data via WebSearch operations (lines 37-44). The tools/financial_rigor.py verify-valuation utility then classifies each holding's data richness as A, B, or C-grade, flagging low-confidence items that require additional scrutiny (lines 45-46).
Single-Asset Health Diagnostics
Every holding undergoes a binary health assessment that evaluates current PE ratios, validates the original buying thesis, and assigns a "paper health" score (lines 49-55). The workflow answers three critical questions for each position: whether to buy today, hold for five years, and whether the investment thesis remains valid (lines 56-60).
Portfolio-Level Risk Analysis
The system aggregates individual asset data into comprehensive risk metrics.
Concentration Metrics
AI Berkshire measures portfolio concentration against Buffett- and Li-Lu-style targets, calculating the largest single holding's share, the top-three holdings' combined weight, total position count, and cash ratio (lines 65-72).
Correlation and Theme Exposure
A cross-holding correlation matrix identifies hidden risks, such as regulatory exposure shared between Tencent and Kuaishou, while checking for currency or sector over-concentration (lines 78-86).
Opportunity Cost Ranking
Positions are ranked by expected annualized return using tools/financial_rigor.py three-scenario calculations (line 106). The workflow compares the lowest-ranked holdings against cash-return benchmarks to identify capital reallocation opportunities (lines 94-108).
Stress Testing
The pipeline runs qualitative scenario analyses for global recession, US-China conflict, interest rate spikes, and tech bubble conditions, estimating impact on individual positions and the overall portfolio (lines 113-122).
Rebalancing Recommendations
Based on diagnostic outputs, the skill generates a concrete action table specifying add, reduce, clear, new, or hold directives for each ticker (lines 129-140). Each recommendation includes current percentage weights, target allocations, and a concise rationale grounded in the prior analysis.
Cash Management Integration
When positions underperform cash returns, the workflow recommends cash allocation ranges of 10-30%, treating liquidity as a legitimate portfolio component rather than a temporary holding (lines 145-151). This reflects the Buffett principle that cash optionality provides strategic advantage.
Report Persistence and Incremental Updates
All analysis results are rendered into a structured markdown report and saved to reports/portfolio-latest.md (line 174). This persistent file maintains the portfolio state for future incremental reviews and tracks historical rebalancing decisions.
Invoking the Portfolio Review Skill
Users trigger the workflow through the command line interface. The following examples demonstrate the three supported input formats:
# Percentage allocation format
ai-berkshire /portfolio-review "腾讯30%, 美团20%, 茅台20%, 现金30%"
# Share quantity format with prices
ai-berkshire /portfolio-review "腾讯 500股 @480HKD, 美团 1000股 @130HKD, 茅台 200股 @1700CNY"
# Reference to saved portfolio
ai-berkshire /portfolio-review "我的持仓"
Each command triggers the full pipeline defined in skills/portfolio-review.md, including validation via tools/financial_rigor.py verify-valuation and scenario modeling via three-scenario.
Summary
- AI Berkshire normalizes percentage lists, share quantities, or saved files into a unified holding model via
skills/portfolio-review.md. - The
tools/financial_rigor.py verify-valuationutility grades data confidence whilethree-scenariocalculates expected returns. - Single-asset health checks evaluate PE ratios, thesis validity, and five-year hold potential.
- Portfolio-level analysis tracks concentration against Buffett-style targets, correlation matrices, and stress scenarios.
- Concrete rebalancing actions specify exact percentage adjustments with written rationales.
- Reports persist to
reports/portfolio-latest.mdfor incremental future reviews.
Frequently Asked Questions
What input formats does AI Berkshire accept for portfolio management?
The system accepts three formats: percentage allocations (e.g., "腾讯30%, 美团20%"), detailed share quantities with prices (e.g., "腾讯 500股 @480HKD"), and references to saved portfolio files. All inputs normalize to a tabular holding model in skills/portfolio-review.md (lines 26-33).
How does AI Berkshire determine which holdings to rebalance?
The workflow ranks positions by expected annualized return using tools/financial_rigor.py three-scenario, then tests the lowest-ranked holdings against cash-return benchmarks. It outputs specific actions—add, reduce, clear, new, or hold—based on concentration limits, correlation risks, and opportunity cost analysis (lines 94-140).
What stress scenarios does the portfolio review workflow test?
The skill evaluates four qualitative scenarios: global recession, US-China conflict, interest rate spikes, and tech bubble conditions. It estimates qualitative impact on each position and the portfolio aggregate to surface hidden vulnerability correlations (lines 113-122).
Where does AI Berkshire store the generated rebalancing reports?
The system writes structured markdown reports to reports/portfolio-latest.md, which includes the overview, single-asset health tables, portfolio analysis, rebalance actions, and next-review schedule. This file serves as the persistent state for incremental updates (lines 152-166).
Have a question about this repo?
These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:
curl -s "https://instagit.com/install.md" Maintain an open-source project? Get it listed too →