What Programming Language Does AI-Berkshire Use? A Deep Dive into the Python-Powered Architecture

AI-Berkshire is built almost entirely in Python, with every core module, data pipeline, and analysis tool implemented as Python scripts leveraging async I/O and data science libraries.

The xbtlin/ai-berkshire repository is a quantitative financial research platform that relies on Python for its entire stack. From web scraping to rigorous financial validation, the codebase demonstrates how Python's ecosystem supports end-to-end investment research workflows. Every executable file in the tools/ and scripts/ directories is a Python module, confirming the language's role as the sole programming language powering the project.

Python as the Core Language

The repository contains exclusively Python source files (.py) that handle data ingestion, quantitative analysis, and report generation. According to the source code, the project organizes its logic into discrete modules that follow Pythonic patterns—plain functions for deterministic calculations, asynchronous coroutines for I/O-bound tasks, and command-line interfaces for workflow orchestration.

Financial Validation Utilities

The [tools/financial_rigor.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py) module implements core validation logic that checks market-cap consistency and valuation metrics. This file defines deterministic functions that perform floating-point arithmetic and percentage-based tolerance checks.


# Example from tools/financial_rigor.py

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 %

Stock Screening and Momentum Analysis

In [tools/stock_screener.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/stock_screener.py), Python handles time-series calculations for investment signals. The module uses standard library functions and list operations to compute momentum indicators without external dependencies for basic math.


# Example from tools/stock_screener.py

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

Asynchronous Web Scraping

The [tools/xueqiu_scraper.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/xueqiu_scraper.py) module leverages Python's async/await syntax to perform non-blocking I/O operations with Playwright. This pattern allows concurrent fetching of financial data from Chinese stock forums while maintaining clean, readable code structure.


# Example from tools/xueqiu_scraper.py (async workflow)

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)

Supporting Scripts and Workflow Automation

Beyond analysis tools, Python also powers the repository's development workflow. The [scripts/sync-codex-skills.py](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py) and [scripts/sync-codex-prompts.py](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-prompts.py) files generate Codex-compatible skill packages from markdown definitions. These scripts demonstrate Python's utility for build automation and text processing, reading files from the skills/ directory and packaging them into structured JSON outputs.

Key Files and Their Roles

Summary

  • AI-Berkshire uses Python exclusively for all executable logic, from data scraping to quantitative analysis.
  • Async Python patterns power the web scraping workflows, enabling concurrent data retrieval without blocking operations.
  • Pure Python functions handle financial validation and momentum calculations, leveraging basic arithmetic and list operations.
  • Helper scripts automate the packaging of markdown skills into Codex-compatible formats, demonstrating Python's flexibility for build tooling.
  • Zero compiled languages or JavaScript are present in the executable codebase; Markdown is used only for documentation and skill definitions.

Frequently Asked Questions

Is AI-Berkshire written entirely in Python?

Yes. Every script, module, and utility in the repository is implemented as Python source code. The project uses Python 3 for all operations, including web scraping with Playwright, financial calculations, and command-line tooling.

Does AI-Berkshire use any other programming languages besides Python?

No. While the repository contains Markdown files (.md) in the skills/ directory for documentation and workflow definitions, these are not executable code. The runtime environment is exclusively Python, with no JavaScript, TypeScript, C++, or other languages present in the source tree.

What Python libraries does AI-Berkshire rely on?

The codebase utilizes standard data science and web scraping libraries typical of quantitative finance projects. Based on the import patterns and function signatures, the project relies on playwright for async browser automation, json for data parsing, and standard libraries like math and statistics for calculations. The README.md indicates installation via pip, suggesting dependencies managed through Python's packaging ecosystem.

How does AI-Berkshire handle concurrent web scraping?

The project uses Python's native async/await syntax combined with Playwright's asynchronous API. Functions like browser_fetch_json in [tools/xueqiu_scraper.py](https://github.com/xbtlin/ai-berkshire/blob/main/tools/xueqiu_scraper.py) demonstrate this pattern, allowing multiple page requests to run concurrently without blocking the main thread, which is essential for efficiently gathering financial data from multiple sources.

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 →