# How to Integrate AI Berkshire with Other Financial Tools: A Complete Integration Guide

> Seamlessly integrate AI Berkshire with financial tools. This guide shows how to connect AI Berkshire's Python modules to databases, APIs, and BI platforms using DataFrame operations.

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

---

**AI Berkshire exposes its core financial analysis engines as importable Python modules in the `tools/` directory, enabling seamless data pipeline integration with databases, REST APIs, and business intelligence platforms via standard DataFrame operations.**

AI Berkshire is a modular research framework hosted at `xbtlin/ai-berkshire` that bundles reusable financial analysis utilities. Because the core logic is decoupled from the AI interface layer, you can **integrate AI Berkshire with other financial tools** by importing its Python functions directly into existing data pipelines, trading systems, or portfolio management dashboards.

## Understanding the AI Berkshire Architecture

The repository organizes functionality into three distinct layers that facilitate external integration.

### Core Data-Processing Utilities (tools/)

Located in [`tools/financial_rigor.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/financial_rigor.py), [`tools/stock_screener.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/stock_screener.py), and [`tools/morningstar_fair_value.py`](https://github.com/xbtlin/ai-berkshire/blob/main/tools/morningstar_fair_value.py), these modules expose pure Python functions like `run_financial_rigor()` and `screen_stocks()` that accept standard Pandas DataFrames and return analyzable objects.

### Skill Packages (skills/)

The `skills/` directory contains Markdown-described workflows such as [`skills/financial-data.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/financial-data.md) and [`skills/portfolio-review.md`](https://github.com/xbtlin/ai-berkshire/blob/main/skills/portfolio-review.md). These define reusable prompts for Claude Code, but underlying each skill is a direct call to the corresponding utility function in `tools/`.

### Integration Glue (scripts/)

Files like [`scripts/sync-codex-skills.py`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py) and [`scripts/install-codex-skills.sh`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/install-codex-skills.sh) generate slash-command wrappers for AI coding assistants. The architecture diagram in `assets/architecture.mmd` visualizes how data flows from raw inputs through these utilities to final outputs.

## Installing and Importing AI Berkshire Modules

You do not need to deploy the entire AI interface to use the financial logic. Install only the core package requirements and import specific utilities.

```bash
git clone https://github.com/xbtlin/ai-berkshire.git
cd ai-berkshire
python -m venv .venv && source .venv/bin/activate
pip install -r requirements.txt

```

Import the analysis engines directly into your script:

```python
from tools.financial_rigor import run_financial_rigor
from tools.stock_screener import screen_stocks

```

## Feeding Market Data into AI Berkshire Utilities

The utilities accept flexible input formats. While the repository includes sample data in [`data/fundamentals.json`](https://github.com/xbtlin/ai-berkshire/blob/main/data/fundamentals.json), production workflows typically substitute proprietary or third-party feeds.

Pass a DataFrame directly to bypass the default JSON loader:

```python
import pandas as pd

# Load your own CSV of raw fundamentals

df = pd.read_csv("my_fundamentals.csv")
rigor_report = run_financial_rigor(df)

```

## Exporting Analysis Results to External Systems

Because AI Berkshire returns plain Python objects—DataFrames, dictionaries, or markdown strings—you can serialize outputs to any downstream system.

**Database Integration (PostgreSQL/MySQL)**

Push DataFrame results directly to SQL tables using SQLAlchemy:

```python
rigor_report.to_sql("financial_rigor", engine, if_exists="replace")

```

**REST API Endpoints**

Serve results via FastAPI or Flask by converting outputs to JSON:

```python
from fastapi.responses import JSONResponse

return JSONResponse(content=rigor_report.to_dict())

```

**Business Intelligence Dashboards**

Render markdown reports in Streamlit or Panel applications:

```python
import streamlit as st
st.markdown(md_report)

```

**Data Lake Storage**

Write parquet files for S3-based data lakes:

```python
rigor_report.to_parquet("s3://my-bucket/rigor.parquet")

```

## End-to-End Integration Example

The following example demonstrates a complete workflow: fetching daily prices from a third-party API, running the stock screener, and pushing screened tickers to a portfolio management system via HTTP.

```python
import requests
import pandas as pd
from tools.stock_screener import screen_stocks

# Fetch raw price data from external API

resp = requests.get("https://api.example.com/daily-prices")
prices = pd.DataFrame(resp.json())

# Apply AI Berkshire screening logic

screened = screen_stocks(prices, min_market_cap=1e9, sector="Technology")

# Push to external portfolio service

payload = {"tickers": screened["symbol"].tolist()}
requests.post("https://portfolio.example.com/api/add", json=payload)

```

## Synchronizing Skills with AI Assistants

If you modify analysis logic or add new screening criteria, regenerate the skill wrappers to keep Claude Code and Codex integrations current:

```bash
python scripts/sync-codex-skills.py

```

## Summary

- **AI Berkshire** exposes financial analysis logic as standard Python modules in `tools/`, making it compatible with any Python-based financial stack.
- Import functions like `run_financial_rigor()` and `screen_stocks()` directly to bypass the AI interface and embed logic into existing pipelines.
- The utilities accept **Pandas DataFrames** and return structured objects suitable for SQL databases, REST APIs, Parquet files, or BI dashboards.
- Use the [`scripts/sync-codex-skills.py`](https://github.com/xbtlin/ai-berkshire/blob/main/scripts/sync-codex-skills.py) utility to maintain alignment between your Python code changes and AI assistant skill definitions.

## Frequently Asked Questions

### Can I use AI Berkshire without installing the Claude Code or Codex interface?

Yes. The core financial logic resides in [`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) as pure Python functions. You can import these modules into any Jupyter notebook, ETL script, or web application without deploying the AI assistant layers.

### What data formats does AI Berkshire support for input?

The utilities primarily accept **Pandas DataFrames** and file paths pointing to JSON or CSV files. The sample data in [`data/fundamentals.json`](https://github.com/xbtlin/ai-berkshire/blob/main/data/fundamentals.json) demonstrates the expected schema, but you can map any column-compatible dataset to the function parameters.

### How do I update the AI skills after modifying the underlying Python code?

Run `python scripts/sync-codex-skills.py` from the repository root. This script regenerates the slash-command wrappers and metadata used by Claude Code and Codex, ensuring that your AI assistants reflect the latest changes in `tools/` and `skills/`.

### Is AI Berkshire suitable for real-time trading pipelines?

While the `tools/` modules provide rigorous financial analysis, they are designed for research and batch processing. For real-time trading, you should wrap these utilities in an asynchronous execution layer and benchmark latency, as the underlying functions perform comprehensive calculations best suited for end-of-day or periodic analysis.