Skip to main content

A Python library for quantitative finance, offering tools for risk management, portfolio optimization, and financial modeling

Project description

qfinbox

PyPI version Python 3.8+ License: MIT Documentation Status

qfinbox is a comprehensive Python library for quantitative finance, offering professional-grade tools for risk management, portfolio optimization, and financial modeling. It enables easy simulation of market scenarios and investment strategy optimization, enhancing financial analysis and decision-making.

✨ Features

🧮 Time Value of Money (TVM)

  • Basic TVM: Future/present value calculations with various compounding methods
  • Annuities: Ordinary and due annuities (PV/FV calculations)
  • Bond Valuation: Pricing, yield-to-maturity, duration, and convexity
  • Loan Analysis: Payment calculations, amortization schedules, and balance tracking
  • Cash Flow Analysis: NPV, IRR, payback periods, and profitability index

🛡️ Core Utilities

  • Input Validation: Robust parameter validation for financial calculations
  • Exception Handling: Custom exception hierarchy for clear error reporting
  • Data Conversion: Seamless integration with NumPy arrays and Pandas DataFrames
  • Type Safety: Full type hints throughout the codebase

🚀 Installation

pip install qfinbox

For development dependencies:

pip install qfinbox[dev]

For advanced features:

pip install qfinbox[advanced]

📋 Requirements

  • Python 3.8+
  • NumPy >= 1.21.0
  • Pandas >= 1.3.0
  • SciPy >= 1.7.0

🎯 Quick Start

import qfinbox as qf

# Basic TVM calculations
fv = qf.tvm.future_value(1000, 0.05, 10)  # $1,628.89
pv = qf.tvm.present_value(fv, 0.05, 10)   # $1,000.00

# Annuity calculations
annuity_pv = qf.tvm.ordinary_annuity_pv(1000, 0.05, 10)  # $7,721.73
annuity_fv = qf.tvm.ordinary_annuity_fv(1000, 0.05, 10)  # $12,577.89

# Bond valuation
bond_price = qf.tvm.bond_price(1000, 0.06, 10, 0.08)  # $864.10
duration = qf.tvm.bond_duration(1000, 0.06, 10, 0.08)  # 7.45 years

# Loan calculations
monthly_payment = qf.tvm.loan_payment(300000, 0.05, 30, 12)  # $1,610.46
schedule = qf.tvm.amortization_schedule(100000, 0.06, 15, 12)

# Cash flow analysis
cash_flows = [-100000, 30000, 40000, 50000]
npv = qf.tvm.net_present_value(cash_flows, 0.10)  # $-2,103.68
payback = qf.tvm.payback_period(cash_flows)        # 3.6 years

# Input validation and error handling
try:
    weights = qf.validate_weights([0.4, 0.3, 0.3])  # ✓ Valid
    invalid = qf.validate_weights([0.5, 0.3, 0.3])  # ✗ Raises ValidationError
except qf.ValidationError as e:
    print(f"Error: {e}")

📖 Documentation

Full documentation is available at https://qfinbox.readthedocs.io

🤝 Contributing

Contributions are welcome! Please feel free to submit a Pull Request. For major changes, please open an issue first to discuss what you would like to change.

📄 License

This project is licensed under the MIT License - see the LICENSE file for details.

🏦 Use Cases

  • Investment Analysis: Calculate returns, risk metrics, and portfolio optimization
  • Loan Analysis: Mortgage calculations, amortization schedules, and payment planning
  • Bond Valuation: Price bonds, calculate yields, duration, and convexity
  • Project Finance: NPV analysis, IRR calculations, and investment decision-making
  • Risk Management: Portfolio risk assessment and scenario analysis
  • Financial Planning: Retirement planning, education funding, and goal-based investing

🔗 Links

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

qfinbox-0.1.0.tar.gz (25.1 kB view details)

Uploaded Source

Built Distribution

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

qfinbox-0.1.0-py3-none-any.whl (14.8 kB view details)

Uploaded Python 3

File details

Details for the file qfinbox-0.1.0.tar.gz.

File metadata

  • Download URL: qfinbox-0.1.0.tar.gz
  • Upload date:
  • Size: 25.1 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for qfinbox-0.1.0.tar.gz
Algorithm Hash digest
SHA256 145383d8cce3620b13e3db415890c69b800e97fc6d4833765cb88ec9731b693a
MD5 e08c85ad968df3662204bfaf29229799
BLAKE2b-256 e5085d28876d2157e58abc537ab0c986bea164ea5a68d810f81120671988875f

See more details on using hashes here.

File details

Details for the file qfinbox-0.1.0-py3-none-any.whl.

File metadata

  • Download URL: qfinbox-0.1.0-py3-none-any.whl
  • Upload date:
  • Size: 14.8 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.12.6

File hashes

Hashes for qfinbox-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 09e7a8b90ca9b28ab8afc13eb5114a26545cc860863b165cf7d8b3b68e44ba91
MD5 0b3c35cf197dd6a59c9d3b38874127e7
BLAKE2b-256 4ef25969c1bbc19db5e07d30faf6a08ee9b42a2383f11353a6b455eeeef16050

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