How to Perform Three-Scenario Valuation with AI Berkshire

AI Berkshire computes exact target prices across optimistic, base-case, and pessimistic scenarios using the three-scenario sub-command in tools/financial_rigor.py, leveraging decimal.Decimal arithmetic to eliminate floating-point drift.

The xbtlin/ai-berkshire repository provides a deterministic financial analysis toolkit designed for rigorous investment research. Performing Three-Scenario Valuation with AI Berkshire enables analysts to generate audit-ready price targets by compounding EPS growth rates and applying scenario-specific PE multiples without precision errors.

What is Three-Scenario Valuation?

Three-Scenario Valuation projects future earnings per share (EPS) across three distinct forward-looking assumptions—optimistic (bull), neutral (base), and pessimistic (bear)—then calculates corresponding target prices based on assigned PE multiples. Unlike spreadsheet-based models prone to rounding errors, AI Berkshire implements this logic in tools/financial_rigor.py using a pre-configured decimal Context with 28-digit precision (prec=28), ensuring reproducible results across all computing environments.

The valuation engine resides in the three_scenario_valuation function (lines 33-70 of tools/financial_rigor.py), which iterates through each scenario to compound EPS over a configurable time horizon and compute percentage changes against current market price.

Required Inputs and Parameters

To execute a three-scenario valuation, gather the following fundamental data:

  • Current Price: Trading price per share
  • Current EPS: Trailing twelve-month earnings per share
  • Total Shares: Outstanding share count in billions (as standardized throughout the repository)
  • Growth Rates: Three decimal values representing annual EPS growth for optimistic, neutral, and pessimistic scenarios (e.g., 0.18 0.06 -0.12)
  • Target PE Multiples: Three corresponding PE ratios (e.g., 25 16 9)
  • Forecast Horizon: Number of years to compound growth (default: 3)
  • Currency Label: Optional ticker for display purposes (e.g., "CNY", "USD")

Running the Three-Scenario Valuation Command

CLI Syntax

Invoke the financial rigor tool directly from the repository root:

python3 tools/financial_rigor.py three-scenario \
    --price <current_price> \
    --eps <current_eps> \
    --shares <shares_in_billions> \
    --growth <optimistic> <neutral> <pessimistic> \
    --pe <pe_optimistic> <pe_neutral> <pe_pessimistic> \
    --years <forecast_years> \
    --currency <currency_code>

Practical Example

The following command evaluates a security trading at 74.72 CNY with current EPS of 2.455, projecting three years forward:

python3 tools/financial_rigor.py three-scenario \
    --price 74.72 \
    --eps 2.455 \
    --shares 15.689 \
    --growth 0.18 0.06 -0.12 \
    --pe 25 16 9 \
    --years 3 \
    --currency "CNY"

Output Explanation:

The CLI prints a Markdown-compatible table containing:

  • Scenario: Bull/Base/Bear classification
  • Annual Growth: Compounded yearly rate
  • Target PE: Assigned multiple
  • Projected EPS: Future earnings per share after compounding
  • Target Price: Projected EPS × Target PE
  • Price Change: Percentage delta versus current price

Sample output format:


============================================================
三情景估值模型 (Three-Scenario Valuation)
============================================================
  当前股价: 74.72 CNY
  当前EPS:  2.455
  预测期:   3年

  情景           年增速   目标PE   目标EPS     目标股价   涨跌幅
  ------------  -------  -------  ----------  ---------  -------
  乐观 (Bull)       18%      25x      4.55      113.8     +52.5%
  中性 (Base)        6%      16x      2.92       46.7     -37.5%
  悲观 (Bear)        0%       9x      2.46       22.1    -70.4%

Programmatic Integration

Using the Python Function Directly

Import the valuation logic into notebooks or custom scripts:

from tools.financial_rigor import three_scenario_valuation

three_scenario_valuation(
    current_price=74.72,
    current_eps=2.455,
    shares_billion=15.689,
    growth_optimistic=0.18,
    growth_neutral=0.06,
    growth_pessimistic=-0.12,
    pe_optimistic=25,
    pe_neutral=16,
    pe_pessimistic=9,
    years=3,
    currency="CNY",
)

This executes the same decimal.Decimal-based calculations as the CLI, printing the formatted table to stdout.

Embedding in Research Reports

According to the AI Berkshire workflow specifications in skills/investment-team.md (line 83) and skills/thesis-drift.md (line 85), analysts embed the CLI command directly into research tasks. The deterministic output allows verbatim insertion into Markdown reports, as demonstrated in reports/藏格矿业/藏格矿业投资研究报告.md (line 292), where the valuation table appears alongside the exact command used for generation.

Best Practice Workflow:

  1. Execute the CLI within a sandboxed Bash environment
  2. Copy the output table into the valuation section of your report
  3. Cite the command line for audit purposes: "All values generated via python3 tools/financial_rigor.py three-scenario ..."

Summary

  • Primary Tool: The three-scenario sub-command in tools/financial_rigor.py serves as the single source of truth for multi-scenario valuation in AI Berkshire.
  • Precision Architecture: All calculations use decimal.Decimal with 28-digit precision to prevent floating-point drift and ensure reproducibility.
  • Input Requirements: Current price, EPS, shares (in billions), three growth rates, three PE multiples, and optional forecast period (default 3 years).
  • Workflow Integration: Skill definitions in skills/investment-team.md and skills/thesis-drift.md standardize the command invocation across research teams.
  • Output Format: Markdown-compatible tables suitable for direct insertion into investment reports, with built-in audit trails via the deterministic CLI.

Frequently Asked Questions

What decimal precision does AI Berkshire use for scenario calculations?

AI Berkshire configures a dedicated decimal Context with prec=28 (28 significant digits) in tools/financial_rigor.py. This ensures that even large market-capitalization calculations or high-magnitude EPS figures maintain exact precision without floating-point rounding errors common in standard Python float operations.

How do I adjust the forecast horizon beyond the default 3 years?

Append the --years flag followed by your desired integer. For example, --years 5 extends the EPS compounding period to five annual cycles. If omitted, the three_scenario_valuation function defaults to a 3-year horizon, aligning with standard medium-term equity research conventions.

Can I run Three-Scenario Valuation without installing external dependencies?

Yes. The tools/financial_rigor.py utility relies exclusively on the Python standard library, specifically the decimal and argparse modules. No external APIs, database connections, or third-party packages are required, making the tool fully portable across any Python 3 environment.

Where can I find real-world examples of this valuation method in use?

The repository contains completed research reports demonstrating implementation. Specifically, reports/藏格矿业/藏格矿业投资研究报告.md (line 292) showcases the three-scenario command embedded within a full investment thesis, displaying both the CLI invocation and the resulting valuation table for a Chinese mining sector analysis.

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:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →