Skip to main content

AI Finance Analyzer

Turn raw expense data into actionable financial insights, not just reports.

Python 3.10+ License: MIT Tests


What This Is

AI Finance Analyzer is a developer-first AI financial decision engine. It takes raw expense data (WeChat Pay CSV, etc.) and produces structured analysis with actionable, quantified suggestions.

This is NOT another bookkeeping app, budgeting tool, or expense tracker.

This IS a programmable analysis engine that answers: "What should I do about my money?"

from analyzer import run_pipeline

report = run_pipeline("wechat_bill.csv")
print(f"Health Score: {report.analysis.health_score.total_score}/100")
# → Health Score: 72/100

for s in report.advice.suggestions:
    print(f"[{s.priority}] {s.action}")
# → [high] Reduce food spending by 20% — cut back on: 美团外卖, 饿了么
#   → Save approximately ¥300/month

How It's Different

Traditional Tools AI Finance Analyzer
Purpose Record what happened Decide what to do
Output Charts & tables Actionable suggestions with numbers
AI Role Bolt-on classifier Core decision engine
Target End users (app) Developers (SDK)
Data Flow Data → Category → Chart Data → Understanding → Behavior Analysis → Decision

Architecture

┌──────────────┐     ┌──────────────┐     ┌──────────────┐     ┌──────────────┐
│   Parser     │ ──→ │  Classifier  │ ──→ │   Analyzer   │ ──→ │   Advisor    │
│  (Input)     │     │(Understanding)│     │  (Insight)   │     │ (Decision)   │
├──────────────┤     ├──────────────┤     ├──────────────┤     ├──────────────┤
│ WeChat CSV   │     │ Rules Engine │     │ Structure    │     │ DeepSeek LLM │
│ Generic CSV  │     │ + LLM Backup │     │ Trends       │     │ Prompt Eng.  │
│ (Pluggable)  │     │              │     │ Health Score │     │ Mock Mode    │
│              │     │              │     │ Risk Alerts  │     │              │
│  ❌ No AI    │     │  ⚠️ AI Assist │     │  ❌ No AI    │     │  ✅ AI Core  │
└──────────────┘     └──────────────┘     └──────────────┘     └──────────────┘

AI is used precisely where it adds value (reasoning & language generation) and avoided where determinism matters (parsing & statistics).

Quick Start

1. Install

git clone https://github.com/yourusername/ai-finance-analyzer.git
cd ai-finance-analyzer
pip install -e ".[all]"

2. Run the Demo

python examples/quickstart.py

3. Use in Your Code

from analyzer import run_pipeline

# Full pipeline: parse → classify → analyze → advise
report = run_pipeline("your_wechat_bill.csv")

# Access structured analysis
print(report.analysis.health_score)      # HealthScore(72, grade='B')
print(report.analysis.savings_rate)       # 0.23
print(report.analysis.category_breakdown) # [CategoryBreakdown(...), ...]
print(report.analysis.risk_alerts)        # [RiskAlert(...), ...]

# Access AI-generated advice
print(report.advice.summary)
print(report.advice.suggestions)

4. Enable AI Advice (Optional)

export DEEPSEEK_API_KEY="your-key-here"

Without an API key, the system uses intelligent mock advice based on your actual data patterns.

Core Metrics

Financial Health Score (0-100)

A weighted composite score based on:

  • Savings Rate (30%) — Are you saving enough?
  • Essential Ratio (25%) — Is spending on necessities balanced?
  • Stability (20%) — How consistent are your spending patterns?
  • Diversity (15%) — Is spending spread across categories?
  • Trend (10%) — Is spending going up or down?

Spending Volatility Index

Measures spending consistency using the Coefficient of Variation across monthly totals. Lower = more stable habits.

Risk Alerts

Automatic detection of: category over-concentration (>35%), low savings rate (<10%), spending spikes, and trend acceleration.

API Reference

Function Description
run_pipeline(file) End-to-end: file → FullReport
analyze_transactions(txs) Analyze pre-parsed transactions
get_advice(report) Generate advice from analysis
parse_file(file) Parse bill file → transactions
classify(transactions) Classify → categorized transactions

Supported Formats

  • ✅ WeChat Pay (微信支付) CSV
  • ✅ Generic CSV (auto-detect columns)
  • 🔜 Alipay (支付宝) CSV
  • 🔜 Bank statement CSV
  • 🔜 Screenshot OCR

Project Structure

src/analyzer/
├── parser/          # Layer 1: Data parsing (pluggable)
├── classifier/      # Layer 2: Rules + LLM classification
├── engine/          # Layer 3: Statistical analysis
├── advisor/         # Layer 4: AI decision generation
├── models/          # Shared data schemas
├── core/            # Configuration
└── pipeline.py      # Orchestrator

Development

# Install dev dependencies
pip install -e ".[dev]"

# Run tests
pytest tests/ -v

# Run with coverage
pytest tests/ --cov=analyzer --cov-report=term-missing

# Lint
ruff check src/

Configuration

Environment variables:

Variable Default Description
DEEPSEEK_API_KEY (none) DeepSeek API key for AI features
LLM_BASE_URL https://api.deepseek.com LLM API endpoint
LLM_MODEL deepseek-chat Model name
DEBUG false Enable debug logging

Contributing

Contributions welcome! Key areas:

  • New parser plugins (Alipay, bank formats)
  • Improved classification rules
  • Additional analysis metrics
  • Documentation & examples

License

MIT — see LICENSE for details.

Metadata

Release files for ai-finance-analyzer 0.1.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for ai-finance-analyzer 0.1.0
File Size Uploaded Provenance
ai_finance_analyzer-0.1.0.tar.gz 32.1 kB Without provenance Details

Built distribution (wheel)

Table of built distributions (wheels) for ai-finance-analyzer 0.1.0
File Interpreter ABI Platform
ai_finance_analyzer-0.1.0-py3-none-any.whl Python 3 none any Details

Total release size: 68.6 kB

Release files / ai_finance_analyzer-0.1.0.tar.gz

Download URL ai_finance_analyzer-0.1.0.tar.gz
Size 32.1 kB
Tags Source
SHA-256 checksum
How to use checksums
beed46371c0bbdc41d623c9edf43bf40ddc371cf9004d8d9301ffb31bee2855d
BLAKE2b-256 checksum
How to use checksums
4a7c6362cbace1429559c0fc2f5f0a30e6e8994cff0170a01d8dd9575198b188
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Release files / ai_finance_analyzer-0.1.0-py3-none-any.whl

Download URL ai_finance_analyzer-0.1.0-py3-none-any.whl
Size 36.5 kB
Tags Python 3
SHA-256 checksum
How to use checksums
46e3329be84db48bd4a4a9a82dd0d59c0b1c52fce368029179fc36b1b1426c88
BLAKE2b-256 checksum
How to use checksums
78b6cab5188398d27cae34ebc350580e05671c882730df65b9796d3fa86c051c
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/6.2.0 CPython/3.13.5

Security for ai-finance-analyzer 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page