What Are the Dependencies for the AI Berkshire Project?

The AI Berkshire project requires only Python 3.8+ and the Playwright library, relying exclusively on the standard library for all other data processing and automation tasks.

The AI Berkshire project, hosted at xbtlin/ai-berkshire, is a Python-based financial research toolkit designed for minimal dependency overhead. Understanding the dependencies for the AI Berkshire project is straightforward: the codebase intentionally avoids heavy data science stacks in favor of lightweight, standard-library solutions. This design choice makes the project portable and easy to deploy without complex environment management.

Core Dependencies

Analysis of the source code reveals a strict two-tier dependency structure: the Python standard library handles all data manipulation, while a single external package manages web automation.

Python Standard Library

Every utility module in the repository imports exclusively from the standard library. According to the source analysis, these imports include:

  • argparse, sys, and subprocess for CLI interfaces and process management
  • json and csv for configuration files and data serialization
  • os and pathlib for cross-platform file system operations
  • datetime, decimal, and collections.OrderedDict for time-series calculations and exact financial arithmetic
  • urllib.request and re for HTTP requests and regular expression parsing
  • asyncio for asynchronous execution patterns

In tools/stock_screener.py (lines 20-25), imports are limited to standard library components:


# tools/stock_screener.py – Standard library imports only

import json
import os
from datetime import datetime, timedelta

Similarly, tools/financial_rigor.py (lines 18-22) imports decimal and collections to handle precise currency calculations without floating-point errors, while tools/ashare_data.py (lines 16-21) leverages urllib.request and csv for API interaction.

Playwright (Third-Party)

The only non-standard dependency is Playwright, specifically the playwright.async_api module. This appears solely in tools/xueqiu_scraper.py (lines 38-39) to handle JavaScript-rendered content on Chinese financial websites.


# tools/xueqiu_scraper.py – The sole third-party import

from playwright.async_api import async_playwright

async def fetch_page(url: str) -> str:
    async with async_playwright() as p:
        browser = await p.chromium.launch(headless=True)
        page = await browser.new_page()
        await page.goto(url)
        content = await page.content()
        await browser.close()
        return content

Dependency Usage by Module

Each tool maintains the minimal-dependency philosophy, with specific standard library modules serving distinct purposes across the codebase:

Web Scraping

  • tools/xueqiu_scraper.py (lines 31-39): Combines asyncio with playwright.async_api for asynchronous browser automation

Data Screening

Financial Calculations

  • tools/financial_rigor.py (lines 18-22): Employs decimal.Decimal and collections.OrderedDict for rigorous financial validation
  • tools/ashare_data.py (lines 16-21, 46): Leverages urllib.request for API calls and csv for local data storage

Report Validation

  • tools/report_audit.py (lines 24-31): Utilizes argparse for CLI arguments and re for text pattern matching

Fair Value Analysis

Installation Guide

To install the dependencies for the AI Berkshire project, run a single pip command followed by Playwright's browser setup:

pip install playwright
playwright install chromium

No requirements.txt, pyproject.toml, or setup.cfg files exist in the repository, confirming that the standard library provides all necessary functionality outside of browser automation. The codebase explicitly excludes common packages like pandas, numpy, requests, or tqdm.

Summary

  • The AI Berkshire project depends on Python 3.8+ and Playwright only, with zero additional third-party packages required for core functionality.
  • Standard library modules handle CSV parsing, JSON serialization, HTTP requests, and decimal arithmetic across all tool modules.
  • Playwright (playwright.async_api) is isolated to tools/xueqiu_scraper.py for headless browser automation of JavaScript-heavy websites.
  • No pandas, numpy, or requests dependencies exist in the repository, making the project suitable for lightweight, containerized deployments.

Frequently Asked Questions

Does the AI Berkshire project require pandas or numpy?

No. The project intentionally avoids pandas and numpy dependencies. Instead, tools/ashare_data.py uses the standard library's csv module for tabular data, while tools/financial_rigor.py relies on decimal.Decimal for precise calculations. This eliminates the need for heavy numerical computing libraries.

What Python version is required for AI Berkshire?

The project requires Python 3.8 or newer. This version requirement supports the async/await syntax used in tools/xueqiu_scraper.py and ensures compatibility with pathlib and other modern standard library features utilized throughout the codebase.

How do I install the dependencies for the AI Berkshire project?

Install only Playwright via pip: pip install playwright && playwright install chromium. Since the project uses no requirements.txt or pyproject.toml, you do not need to install pandas, numpy, or any other data science stack components. The standard library handles all data processing needs.

Why does the project use Playwright instead of requests?

The tools/xueqiu_scraper.py module requires Playwright because the target financial websites render content dynamically with JavaScript. Standard HTTP requests via urllib.request cannot execute JavaScript, so Playwright's async_playwright API provides headless Chromium automation to fetch fully rendered pages.

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 →