Dependencies for the AI Berkshire Project: Complete Installation Guide

The AI Berkshire project depends primarily on Python 3's standard library and a single third-party package, Playwright, for asynchronous web scraping capabilities.

The xbtlin/ai-berkshire repository is a collection of financial research utilities designed to operate with minimal external dependencies. Understanding the exact dependencies for the AI Berkshire project is essential for setting up a clean environment and ensuring all scraping, screening, and auditing tools function correctly without version conflicts.

Core Dependencies Overview

The codebase is intentionally lightweight, relying almost exclusively on Python's built-in modules to reduce installation overhead and maintenance complexity.

Python Standard Library

All core scripts import extensively from the standard library. Modules used across the codebase include:

  • argparse and sys for command-line interfaces
  • json and csv for data serialization and parsing
  • os, subprocess, and pathlib for system operations and file path handling
  • datetime and decimal for temporal calculations and precise numeric operations
  • urllib.request for HTTP requests
  • asyncio for asynchronous programming patterns
  • collections.OrderedDict for ordered dictionary structures
  • re for regular expression operations

These imports appear consistently in tools/stock_screeper.py, tools/report_audit.py, tools/financial_rigor.py, and tools/ashare_data.py.

Third-Party: Playwright

The only external dependency required is Playwright, specifically the playwright.async_api module. This is used exclusively in tools/xueqiu_scraper.py to automate browser interactions with the Xueqiu financial platform, as the site requires JavaScript execution that standard HTTP libraries cannot handle.

Dependency Analysis by Module

Breaking down the requirements by file reveals exactly where each dependency is utilized in the xbtlin/ai-berkshire source code.

Web Scraping (xueqiu_scraper.py)

The tools/xueqiu_scraper.py file contains the only non-standard import in the entire repository:

from playwright.async_api import async_playwright

This import enables headless browser automation to fetch dynamic content from Chinese financial portals. The implementation uses async_playwright() to launch Chromium instances and navigate pages that require JavaScript rendering.


# Example pattern from the scraper implementation

import asyncio
from playwright.async_api import async_playwright

async def fetch_dynamic_content(url: 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

Data Processing (stock_screener.py and ashare_data.py)

Files like tools/stock_screener.py and tools/ashare_data.py rely solely on standard library imports for data handling:

import json
import os
from datetime import datetime, timedelta
import csv
from decimal import Decimal
import random

These modules handle JSON configuration files, CSV data processing, and precise decimal arithmetic without requiring pandas or numpy.

Financial Calculations (financial_rigor.py)

The tools/financial_rigor.py script performs exact-arithmetic validations using high-precision decimal math:

from decimal import Decimal, ROUND_HALF_UP
import re
import json
from collections import OrderedDict

This approach ensures financial calculations maintain precision without floating-point errors, eliminating the need for external numeric libraries like numpy.

System Integration (morningstar_fair_value.py)

The tools/morningstar_fair_value.py module utilizes subprocess to invoke external commands and urllib.request for fetching remote data:

import subprocess
import urllib.request
from pathlib import Path

Similarly, scripts/sync-codex-skills.py uses argparse for CLI parsing and os for environment variable access.

Installation Requirements

To run the AI Berkshire utilities, install only Playwright after setting up Python 3.8 or higher:

pip install playwright
playwright install chromium

No requirements.txt, pyproject.toml, or setup.py is present in the repository, confirming the intentional minimal dependency approach. All other functionality is available immediately after installing Python.

Summary

  • The AI Berkshire project requires only Python 3.8+ and Playwright to function completely
  • All data processing, financial calculations, and file operations use the Python standard library exclusively
  • No imports of pandas, numpy, or requests exist in the codebase at tools/xueqiu_scraper.py, tools/stock_screener.py, or tools/financial_rigor.py
  • Install Playwright via pip and download the Chromium browser binary before running the scraper
  • The project philosophy emphasizes dependency minimalism to ensure long-term maintainability and easy deployment

Frequently Asked Questions

Does AI Berkshire require pandas or numpy?

No. The codebase intentionally avoids pandas and numpy, utilizing instead the csv module for tabular data and decimal.Decimal for precise numeric calculations. This design choice reduces dependency overhead and eliminates potential version conflicts with scientific computing libraries.

How do I install Playwright for the AI Berkshire project?

Install Playwright using pip (pip install playwright) and then download the required browser binaries by running playwright install chromium. This is only necessary if you intend to use the Xueqiu scraper functionality in tools/xueqiu_scraper.py; all other tools function without this installation.

What Python version is required?

The code uses modern standard library features and async/await syntax, requiring Python 3.8 or higher. However, Python 3.10 or higher is recommended for optimal compatibility with recent Playwright versions and to ensure all standard library features used in tools/ashare_data.py are available.

Are there any optional dependencies or development requirements?

Currently, no optional dependencies are documented in the repository. All functionality is available with the standard library plus Playwright. There are no development dependencies, testing frameworks, or build tools required to use the scripts in tools/ or scripts/.

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 →