# How AI Berkshire Handles Currency Unit Confusion in Market Cap Verification

> AI Berkshire prevents currency unit confusion like HKD RMB USD in market cap verification. Ensure accuracy with explicit labels and targeted warnings for deviations exceeding 5%.

- Repository: [Xbt Lin/ai-berkshire](https://github.com/xbtlin/ai-berkshire)
- Tags: how-to-guide
- Published: 2026-06-26

---

**AI Berkshire prevents currency unit errors by requiring explicit currency labels in the `verify-market-cap` command and emitting targeted warnings that prompt analysts to verify HKD, RMB, or USD units when deviations exceed 5%.**

The xbtlin/ai-berkshire repository provides a financial rigor toolkit that explicitly guards against currency unit confusion during market cap verification. By treating currency labels as mandatory metadata rather than implicit assumptions, the system ensures that discrepancies between Hong Kong Dollar, Chinese Yuan, and US Dollar figures surface before they corrupt valuation models.

## Explicit Currency Parameter in Verification Commands

The verification logic in [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py) requires analysts to declare the currency unit upfront via the `--currency` argument. This parameter records whether the reported market cap is denominated in HKD, CNY, or USD, and the label is echoed in the console output alongside calculated values【/cache/repos/github.com/xbtlin/ai-berkshire/main/tools/financial_rigor.py#L61-L74】.

When invoking the `verify-market-cap` command, the system expects:

```bash
python3 tools/financial_rigor.py verify-market-cap \
    --price 510 \
    --shares 9.11e9 \
    --reported 4.65e12 \
    --currency HKD

```

This explicit labeling prevents silent mismatches by forcing the analyst to commit to a unit before the calculation begins. The console output then displays both calculated and reported figures with the currency suffix attached, making unit discrepancies immediately visible.

## Deviation Thresholds and Unit-Check Warnings

After computing **price × shares outstanding** using exact decimal arithmetic, the tool calculates the percentage deviation between the computed and reported market cap. If this deviation exceeds **5%**, the system emits a warning that specifically lists three potential error sources, including the prompt: **"单位是否一致（港币 vs 人民币 vs 美元）?"** (Are the units consistent?【/cache/repos/github.com/xbtlin/ai-berkshire/main/tools/financial_rigor.py#L80-L84】).

This design treats currency unit confusion as a first-class validation failure rather than a hidden calculation error. Even when the numerical deviation is small—such as the 0.08% variance in the Tencent example below—the explicit currency mismatch triggers the warning system, forcing manual verification before the data proceeds to downstream valuation models.

## Real-World Example: Tencent’s Dual-Currency Reporting

The repository documentation in [`README_EN.md`](https://github.com/xbtlin/ai-berkshire/blob/main/README_EN.md) records a concrete case where Tencent’s market cap was reported in both "HKD billions" and "CNY billions"【/cache/repos/github.com/xbtlin/ai-berkshire/main/README_EN.md#L99-L105】. Running the verification with `--currency HKD` confirmed a negligible 0.08% deviation, demonstrating how the workflow surfaces unit inconsistencies before they affect analysis.

Conversely, invoking the same command with `--currency CNY` (deliberately mismatched to the actual HKD reporting) triggers the warning sequence:

```bash
python3 tools/financial_rigor.py verify-market-cap \
    --price 510 \
    --shares 9.11e9 \
    --reported 4.65e12 \
    --currency CNY

```

Output:

```

❌ 警告: 偏差 0.08% > 5%, 请检查:
   - 股本是否为最新（回购/增发）?
   - 单位是否一致（港币 vs 人民币 vs 美元）?
   - 股价是否为最新?

```

The warning appears because the currency label does not match the implicit unit of the reported figure, requiring the analyst to either convert the reported value or adjust the currency flag.

## Consistent Formatting and Cross-Source Validation

The helper function `fmt_number` (defined at lines 40-52 in [`financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/financial_rigor.py)) appends the appropriate currency suffix—such as "HKD", "CNY", or "$"—when rendering numerical output【/cache/repos/github.com/xbtlin/ai-berkshire/main/tools/financial_rigor.py#L40-L52】. This prevents silent unit mismatches in generated reports by ensuring every figure carries its denomination visibly.

For additional safety, the toolkit provides a `cross-validate` command that accepts market cap figures from multiple sources【/cache/repos/github.com/xbtlin/ai-berkshire/main/tools/financial_rigor.py#L66-L73】. Analysts must normalize currencies to a common unit before comparison, ensuring that any conversion is performed deliberately rather than assumed by the software.

## Summary

- **Explicit labeling**: The `--currency` parameter in `verify-market-cap` forces declaration of HKD, CNY, or USD before calculation.
- **Threshold warnings**: Deviations exceeding 5% trigger explicit prompts to verify currency unit consistency.
- **Real-world validation**: The Tencent case study demonstrates detection of dual-currency reporting scenarios.
- **Output formatting**: The `fmt_number` helper ensures all printed values include their currency denomination.
- **Manual conversion**: The `cross-validate` command requires deliberate currency normalization, preventing automatic conversion errors.

## Frequently Asked Questions

### How does AI Berkshire detect currency unit mismatches?

The system detects potential mismatches through the deviation threshold mechanism in [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py). When the percentage difference between calculated and reported market cap exceeds 5%, the tool emits a warning that explicitly asks analysts to verify whether units are consistent between HKD, RMB, and USD【/cache/repos/github.com/xbtlin/ai-berkshire/main/tools/financial_rigor.py#L80-L84】.

### What threshold triggers a currency unit warning?

The tool uses a **5% deviation threshold** as the trigger for detailed warnings. However, the warning system activates based on the combination of numerical deviation and currency label mismatches, ensuring that even small numerical errors (like 0.08%) are flagged when the `--currency` parameter does not align with the reported figure's actual denomination.

### Can the tool automatically convert between HKD, RMB, and USD?

No, the toolkit deliberately avoids automatic currency conversion. The `cross-validate` command requires analysts to normalize values to a common unit before comparison, ensuring that any exchange rate calculations are performed consciously and explicitly rather than assumed by the software【/cache/repos/github.com/xbtlin/ai-berkshire/main/tools/financial_rigor.py#L66-L73】.

### Where is the currency parameter defined in the source code?

The `--currency` argument is defined in the command-line interface logic within [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py), specifically at lines 61-74, where it is passed to the verification function and subsequently echoed in the console output to ensure visible unit tracking throughout the validation process.