Skip to main content

A Python package for financial modeling and reporting

Project description

Pyproforma

A Python package for financial modeling and reporting that provides a flexible framework for building financial models with line items, formulas, constraints, and rich output formatting.

Installation

Install from PyPI:

pip install pyproforma

For local development:

pip install -e .

Quick Start

from pyproforma import Model, LineItem, Category

# Create line items
revenue = LineItem(
    name="revenue",
    category="income",
    label="Total Revenue",
    values={2024: 100000, 2025: 120000, 2026: 150000}
)

expenses = LineItem(
    name="expenses", 
    category="income",
    label="Total Expenses",
    formula="revenue * 0.6"  # 60% of revenue
)

# Create a model
model = Model(
    line_items=[revenue, expenses],
    years=[2024, 2025, 2026]
)

# Calculate results
results = model.calculate()
print(results.to_dataframe())

Key Features

📊 Financial Modeling

  • Create line items with explicit values or formulas
  • Organize items into categories with automatic totals
  • Support for complex financial calculations using numexpr

📈 Interactive Charts

  • Built-in Plotly integration for data visualization
  • Line charts, bar charts, and mixed chart types
  • Cumulative change and percent change charts

📋 Flexible Tables

  • Generate formatted tables for financial statements
  • Export to Excel with styling and formatting
  • Configurable row types and table structures

🔧 Advanced Features

  • Constraint validation for model integrity
  • YAML/JSON serialization for model persistence
  • Debt and financing generators
  • Rich HTML output for Jupyter notebooks

Usage Examples

Working with Formulas

# Line items can reference other line items in formulas
profit = LineItem(
    name="profit",
    category="income", 
    formula="revenue - expenses"
)

# Support for complex expressions
margin = LineItem(
    name="margin",
    category="ratios",
    formula="profit / revenue",
    value_format="percent"
)

Creating Categories

from pyproforma import Category

# Categories automatically calculate totals
revenue_category = Category(
    name="revenue",
    label="Revenue Sources",
    include_total=True
)

model.add.category(revenue_category)

Generating Reports

# Create formatted tables
table = model.tables.generate_table([
    {"type": "category", "name": "income"},
    {"type": "line_item", "name": "revenue"},
    {"type": "line_item", "name": "expenses"},
    {"type": "total", "category": "income"}
])

# Export to Excel
table.to_excel("financial_report.xlsx")

# Create interactive charts
chart = model.charts.line_item("revenue", chart_type="line")
chart.show()

Model Persistence

# Save model to YAML
model.save_yaml("model.yaml")

# Load model from YAML
model = Model.load_yaml("model.yaml")

Development

Install in development mode with testing dependencies:

pip install -e .[dev]

Run tests:

pytest

Run tests with coverage:

pytest --cov=pyproforma

Requirements

  • Python 3.9+
  • pandas >= 1.3.0
  • openpyxl >= 3.0.0
  • numexpr >= 2.7.0
  • jinja2 >= 3.0.0
  • plotly >= 5.0.0
  • PyYAML >= 6.0.0

License

MIT License - see LICENSE file for details.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyproforma-0.1.8.tar.gz (65.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

pyproforma-0.1.8-py3-none-any.whl (77.2 kB view details)

Uploaded Python 3

File details

Details for the file pyproforma-0.1.8.tar.gz.

File metadata

  • Download URL: pyproforma-0.1.8.tar.gz
  • Upload date:
  • Size: 65.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for pyproforma-0.1.8.tar.gz
Algorithm Hash digest
SHA256 628d7c5570149c89fae75ff3521f8aec3f10321d47d11d0ff3290295946dec54
MD5 698285eec118336af082e947d2ce0419
BLAKE2b-256 16562e35efcdd6b3453334d5be3bb39cfbf05063b93d9922176abd2319868013

See more details on using hashes here.

File details

Details for the file pyproforma-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: pyproforma-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 77.2 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.12.6

File hashes

Hashes for pyproforma-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 ec3f8c94abea013c3dee6333c00d652b4eea1a5234cdf41aea7ec06dbb104176
MD5 aa660906294d59f3d5b2c6dc2eed065a
BLAKE2b-256 0eccd71654151ac890b132fc5b6801372c5ba4ab1474ba3bf1957ef2a7fa5320

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page