AI Berkshire Three-Scenario Valuations: Implementation and Usage Guide
Yes, AI Berkshire generates three-scenario valuations through a dedicated engine that computes optimistic, base-case, and pessimistic target prices using exact decimal arithmetic.
The xbtlin/ai-berkshire repository includes a sophisticated financial analysis toolkit featuring a three-scenario valuation system. This functionality enables investors to model equity valuations across bullish, neutral, and bearish market conditions using precise decimal arithmetic. The implementation resides primarily in tools/financial_rigor.py and is integrated throughout the AI Berkshire skill layer for reproducible investment analysis.
How Three-Scenario Valuations Work
The Valuation Methodology
The valuation engine projects future earnings per share (EPS) growth across three distinct market scenarios over a configurable time horizon—defaulting to 3 years. For each scenario, the system applies scenario-specific price-to-earnings (PE) multiples to derive intrinsic value estimates. As implemented in tools/financial_rigor.py, the three_scenario_valuation function uses exact decimal arithmetic to eliminate floating-point rounding errors, ensuring auditable financial outputs.
Scenario Parameters
Each valuation requires scenario-specific inputs:
- Growth rates: Annual EPS growth percentages for optimistic, neutral, and pessimistic cases
- PE multiples: Target exit multiples corresponding to each scenario's market sentiment
- Current fundamentals: Current stock price, trailing EPS, and shares outstanding (in billions)
Implementation Details
Core Function Location
The three_scenario_valuation function is defined in tools/financial_rigor.py (lines 33-38). This module handles the assembly of three scenarios, applies the growth projections and PE multiples, and formats the results into a structured table. The feature is also documented in the repository’s README.md (line 394) under the "Three-Scenario Valuation" entry.
Decimal Precision
According to the source code, the implementation emphasizes exact decimal arithmetic rather than floating-point math. This precision ensures that valuation outputs remain reproducible and auditable—critical requirements for investment decision-making workflows.
Command-Line and Programmatic Usage
CLI Execution
AI Berkshire exposes the valuation engine through the three-scenario sub-command. Execute the analysis from the repository root using:
python3 tools/financial_rigor.py three-scenario \
--price 8.00 \
--eps 0.5000 \
--shares 15.0 \
--growth 0.18 0.06 -0.12 \
--pe 25 16 9
Python API Integration
For custom analytical workflows, import the function directly from the tools module:
from tools.financial_rigor import three_scenario_valuation
three_scenario_valuation(
current_price=8.00,
current_eps=0.5000,
shares_billion=15.0,
growth_optimistic=0.18,
growth_neutral=0.06,
growth_pessimistic=-0.12,
pe_optimistic=25,
pe_neutral=16,
pe_pessimistic=9,
years=3,
currency="USD"
)
Integration with AI Berkshire Skills
The three-scenario valuation system is deeply embedded in the AI Berkshire skill layer architecture, providing standardized valuation capabilities across different analyst workflows.
Investment Team Skill
As referenced in skills/investment-team.md (line 83), the Investment Team skill invokes the three_scenario_valuation tool to provide analysts with reproducible valuation outputs during equity research and due diligence processes.
Portfolio Review Skill
The valuation engine is also utilized in skills/portfolio-review.md (line 106), where it supports expected portfolio return calculations. This integration enables systematic risk assessment across holdings by applying consistent three-scenario methodology to position sizing and concentration analysis.
Summary
- AI Berkshire generates three-scenario valuations (optimistic, base-case, and bearish) via the
three_scenario_valuationfunction intools/financial_rigor.py - The engine employs exact decimal arithmetic for financial precision and accepts configurable growth rates, PE multiples, and projection horizons (default 3 years)
- Users can access valuations via CLI (
three-scenariosub-command) or Python API, with seamless integration into the Investment Team and Portfolio Review skills - The implementation is documented in the README and produces auditable outputs suitable for institutional investment workflows
Frequently Asked Questions
Where is the three-scenario valuation function implemented in AI Berkshire?
The core implementation lives in tools/financial_rigor.py, specifically the three_scenario_valuation function (lines 33-38). This module handles the decimal arithmetic, scenario assembly, and result formatting for all valuation outputs.
What parameters does the three_scenario_valuation function require?
The function requires current_price, current_eps, shares_billion, three growth rates (growth_optimistic, growth_neutral, growth_pessimistic), three PE multiples (pe_optimistic, pe_neutral, pe_pessimistic), projection years (default 3), and currency code. These inputs generate distinct target prices for each market scenario.
How do I run three-scenario valuations from the command line?
Use the three-scenario sub-command with python3 tools/financial_rigor.py, passing flags for --price, --eps, --shares, --growth (three space-separated values), and --pe (three space-separated values). The CLI prints a formatted table of optimistic, base-case, and bearish valuations directly to standard output.
Can I customize the projection period for valuations?
Yes, the years parameter in both the CLI and Python API allows customization of the EPS growth horizon. While the default is 3 years, analysts can adjust this value to match specific investment timelines or business cycle considerations.
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 →