What Programming Language Is Used in AI Berkshire? Inside the Python‑Powered Financial Research Stack

AI Berkshire is built entirely in Python, with every data pipeline, quantitative analysis tool, and automation script implemented as Python modules leveraging the language’s data‑science ecosystem.

The AI Berkshire repository (xbtlin/ai-berkshire) is an open‑source financial research platform that utilizes Python as its sole programming language. The codebase demonstrates how Python’s rich ecosystem for data analysis and web automation powers modern quantitative investment workflows, from stock screening to rigorous financial validation.

Core Architecture and Language Choice

Python as the Foundation

All executable logic in AI Berkshire resides in .py files distributed across the tools/ and scripts/ directories. The project does not rely on compiled languages or JavaScript frontends; instead, it uses Python’s interpreted nature for rapid iteration on financial models. Key entry points such as [tools/financial_rigor.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py) and [tools/stock_screener.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/stock_screener.py) define the core analytical capabilities.

Key Modules and File Structure

The repository organizes its Python codebase into functional groups:

Implementation Patterns in AI Berkshire’s Python Code

Synchronous Financial Validation

The codebase uses standard Python functions for deterministic calculations. In [tools/financial_rigor.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py), the verify_market_cap function validates reported market capitalization against computed values:

def verify_market_cap(price, shares, reported_cap, currency=""):
    """Validate that the market‑cap computed from price × shares
    matches the reported market‑cap within a tolerance."""
    computed = price * shares
    diff_pct = abs(computed - reported_cap) / reported_cap * 100
    return diff_pct < 2.0   # passes if within 2 %

Asynchronous Data Acquisition

For I/O‑bound operations like web scraping, AI Berkshire employs Python’s asyncio and Playwright. The browser_fetch_json function in [tools/xueqiu_scraper.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/xueqiu_scraper.py) demonstrates this pattern:

async def browser_fetch_json(page, url, timeout_s=15):
    await page.goto(url, timeout=timeout_s * 1000)
    content = await page.content()
    return json.loads(content)

Quantitative Analysis Helpers

The [tools/stock_screener.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/stock_screener.py) file implements momentum calculations using pure Python with data‑science patterns:

def check_momentum(prices):
    """Calculate a simple momentum signal from historic price series."""
    if len(prices) < 20:
        return None
    recent = prices[-1]
    past = prices[-20]
    return (recent - past) / past

Automation and Build Scripts

Beyond analytical tools, the repository uses Python for DevOps‑style automation. The [scripts/sync-codex-skills.py](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py) file processes markdown workflow definitions from the skills/ directory and converts them into Codex‑compatible JSON skill packages. This demonstrates Python’s utility as a build and automation language alongside its analytical capabilities.

Summary

Frequently Asked Questions

Is AI Berkshire written in Python 3?

Yes, the codebase targets Python 3 and utilizes modern language features including async/await syntax for asynchronous web scraping, as seen in [tools/xueqiu_scraper.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/xueqiu_scraper.py). The code relies on contemporary standard library modules compatible with Python 3.8+.

Does AI Berkshire use any other programming languages besides Python?

No, the core repository is exclusively Python. All data processing, scraping, and automation logic is contained in .py files. While the project outputs markdown reports and interacts with JavaScript‑rendered web pages via Playwright, the orchestration and business logic remain strictly Python‑based.

Which Python libraries does AI Berkshire depend on?

The codebase leverages standard data science libraries including pandas, NumPy, and requests for data manipulation, along with playwright for browser automation in the scraping modules. The financial validation functions rely on pure Python with minimal external dependencies for core calculations.

Why was Python chosen for this financial research platform?

Python was selected for its dominant ecosystem in quantitative finance and data science. The language’s readability supports rapid prototyping of valuation algorithms, while its async capabilities enable efficient web scraping. This combination makes Python ideal for research pipelines that blend rigorous statistical analysis with automated data acquisition.

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 →