Skip to main content

FinCraftr - A bilingual quantitative finance toolkit

Project description

FinCraftr

FinCraftr is a bilingual (Python + C++20) toolkit for quantitative finance. Its goal is to provide clean, composable building blocks for pricing, risk, portfolio analytics, and market data modelling, implemented with parallel APIs across both languages.

Disclaimer: This software is for research and engineering purposes only and does not constitute investment advice.


Purpose & Scope

  • Production-minded primitives. Small, orthogonal functions and components that can be assembled into full valuation and risk workflows: discounting/curves, cash-flow schedules, instrument pricing, time-series/econometrics, portfolio construction, and diagnostics.
  • Bilingual parity. Each major concept appears in Python (for exploration and pipelines) and C++20 (for performance and embedding). Namespaces and semantics mirror each other to minimise cognitive switching.
  • Transparency of assumptions. Modules make units, conventions, and modelling choices explicit (e.g., compounding basis, day-count, interpolation). Where trade-offs exist, they’re documented at the module boundary.
  • Deterministic & testable. Functions are pure (no hidden globals), accept explicit inputs, and are covered by language-specific unit tests for reproducibility and cross-language consistency.
  • Interoperability. Designed to plug into existing research stacks (NumPy/Pandas, CMake-based C++ projects) without bespoke infrastructure.

What this repository aims to cover

  • Core rates/curves utilities (discount factors, compounding conventions, bootstrapping & interpolation).
  • Instrument pricing surfaces (fixed-income, equity/vanilla options, swaps) that depend on the core utilities.
  • Time-series & econometrics helpers (returns, diagnostics, forecasting) used by risk and strategy modules.
  • Portfolio & risk primitives (covariance handling, optimisation interfaces, sensitivities/Greeks, P&L explain).
  • Validation tools (reference datasets, sanity checks, numerical diagnostics).

What is explicitly out of scope

  • Live brokerage/exchange connectivity and order routing.
  • Proprietary vendor data access layers.
  • High-frequency trading engines or latency-sensitive infra.
  • A drop-in replacement for QuantLib—FinCraftr is intentionally lighter-weight and modular.

Design Principles

  1. Separation of concerns: low-level rate/curve mechanics are isolated from instrument pricing; pricing is isolated from portfolio/risk layers.
  2. Explicit conventions: compounding basis, day-count, calendars, and interpolation must be provided or selected; no silent defaults that change results across environments.
  3. Numerical robustness: prefer stable formulations; document error bounds and known edge cases.
  4. Small surface area: fewer, clearer functions over large, opinionated classes.
  5. Symmetry: Python and C++ exports follow the same naming and signatures where practical.

Quick Examples

import fincraftr as fc

# Calculate stock returns
return_val = fc.return_simple(105, 100)  # 0.05 (5%)

# Option payoffs
call_payoff = fc.options.payoff_call(105, 100)  # 5.0

# Interest rate calculations  
compound_value = fc.rates.compound_discrete(1000, 0.05, 12, 1)

# Forward pricing
forward_price = fc.forwards.forward_price_no_div(100, 0.05, 1)

📚 For comprehensive examples with detailed explanations, see EXAMPLES.md

Installation

Python (PyPI)

Install the latest release from PyPI:

pip install fincraftr

Then use in Python:

import fincraftr as fc

# Calculate simple return
return_val = fc.return_simple(105, 100)  # 0.05

# Access by module
option_payoff = fc.options.payoff_call(105, 100)  # 5.0
compound_value = fc.rates.compound_discrete(1000, 0.05, 12, 1)
forward_price = fc.forwards.forward_price_no_div(100, 0.05, 1)

C++ (vcpkg)

Option 1: Direct Installation

vcpkg install fincraftr

Option 2: Manifest Mode - Add FinCraftr to your vcpkg.json:

{
  "dependencies": ["fincraftr"]
}

Then in your CMakeLists.txt:

find_package(fincraftr CONFIG REQUIRED)
target_link_libraries(myapp PRIVATE fincraftr::fincraftr)

Use in C++:

#include <fincraftr/equity/returns.hpp>
#include <fincraftr/options/payoff.hpp>

double return_val = fc::equity::return_simple(105.0, 100.0);  // 0.05
double call_payoff = fc::options::payoff_call(105.0, 100.0);  // 5.0

Manual Build from Source

C++ Library

# Header-only (default)
cmake -B build -DFINCRAFTR_HEADER_ONLY=ON
cmake --build build
cmake --install build --prefix /usr/local

# Or with compiled libraries
cmake -B build -DFINCRAFTR_HEADER_ONLY=OFF -DFINCRAFTR_BUILD_SHARED=ON
cmake --build build
cmake --install build --prefix /usr/local

Python Package

# Install build dependencies
pip install pybind11 cmake ninja

# Build and install
pip install .

# Or build wheel
python -m build
pip install dist/*.whl

Repository Layout

cpp/include/fincraftr/     # C++20 headers (header-only implementations)
├─ equity/                 # equity analysis (returns, valuation, indices)
├─ options/                # options pricing and analysis
├─ forwards/               # forward contract pricing
└─ rates/                  # interest rates and discounting

python/
├─ fincraftr/              # Python package with fallback implementations
└─ bindings/               # pybind11 C++ bindings

CMakeLists.txt             # C++ build configuration
vcpkg.json                 # vcpkg package manifest
pyproject.toml             # Python package configuration
.github/workflows/         # CI/CD pipelines

API Documentation

All functions include comprehensive docstrings accessible via help() in Python or doxygen-style comments in C++.

Equity Module

  • return_simple(Pt, Pt_prev) - Simple return calculation
  • market_cap(shares, price) - Market capitalization
  • ddm_gordon_growth(D1, r, g) - Gordon growth dividend discount model
  • Index functions: index_price_weighted, index_cap_weighted, etc.

Options Module

  • payoff_call(ST, K), payoff_put(ST, K) - Option payoffs
  • price_binomial_one_period(...) - Binomial option pricing
  • check_put_call_parity(...) - Put-call parity validation

Rates Module

  • compound_discrete(p0, r, m, years) - Discrete compounding
  • compound_continuous(p0, r, t) - Continuous compounding
  • nominal_to_continuous(R, m) - Rate conversions

Forwards Module

  • forward_price_no_div(S, r, tau) - Forward pricing without dividends
  • forward_price_with_div(S, D, r, tau) - With discrete dividends
  • forward_price_cont_yield(S, r, q, tau) - With continuous yield

Language & Tooling

  • Python: 3.8+ with NumPy support
  • C++: C++20 headers (header-only by default, compiled libraries optional)
  • Build: CMake 3.20+, vcpkg support, PyPI distribution
  • CI: GitHub Actions for Windows, Linux, macOS

Contributing

  • Keep modules small and orthogonal; document inputs, conventions, and failure modes in a short module README (see module templates in docs/).
  • Add matching unit tests in both languages where it makes sense.
  • Include tiny, attribution-safe test fixtures in data/ if needed.

License

MIT. See LICENSE 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

fincraftr-1.0.0.tar.gz (25.7 kB view details)

Uploaded Source

Built Distributions

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

fincraftr-1.0.0-cp312-cp312-win_amd64.whl (91.2 kB view details)

Uploaded CPython 3.12Windows x86-64

fincraftr-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (118.9 kB view details)

Uploaded CPython 3.12manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fincraftr-1.0.0-cp312-cp312-macosx_11_0_arm64.whl (98.9 kB view details)

Uploaded CPython 3.12macOS 11.0+ ARM64

fincraftr-1.0.0-cp311-cp311-win_amd64.whl (90.0 kB view details)

Uploaded CPython 3.11Windows x86-64

fincraftr-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (117.4 kB view details)

Uploaded CPython 3.11manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fincraftr-1.0.0-cp311-cp311-macosx_11_0_arm64.whl (97.3 kB view details)

Uploaded CPython 3.11macOS 11.0+ ARM64

fincraftr-1.0.0-cp310-cp310-win_amd64.whl (89.4 kB view details)

Uploaded CPython 3.10Windows x86-64

fincraftr-1.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (116.1 kB view details)

Uploaded CPython 3.10manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fincraftr-1.0.0-cp310-cp310-macosx_11_0_arm64.whl (95.7 kB view details)

Uploaded CPython 3.10macOS 11.0+ ARM64

fincraftr-1.0.0-cp39-cp39-win_amd64.whl (92.6 kB view details)

Uploaded CPython 3.9Windows x86-64

fincraftr-1.0.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl (116.2 kB view details)

Uploaded CPython 3.9manylinux: glibc 2.24+ x86-64manylinux: glibc 2.28+ x86-64

fincraftr-1.0.0-cp39-cp39-macosx_11_0_arm64.whl (95.8 kB view details)

Uploaded CPython 3.9macOS 11.0+ ARM64

File details

Details for the file fincraftr-1.0.0.tar.gz.

File metadata

  • Download URL: fincraftr-1.0.0.tar.gz
  • Upload date:
  • Size: 25.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fincraftr-1.0.0.tar.gz
Algorithm Hash digest
SHA256 2a8632cc8951f1a08464e2b0c552de98bbf6e82e1bf472baf231f279d43038b6
MD5 3618215f2193fb0334ccea39fd216b4b
BLAKE2b-256 0c7d31df55acb1252dc724f76e0a9deb6c6237e20445ca4ec04f25d99a971d08

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0.tar.gz:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp312-cp312-win_amd64.whl.

File metadata

  • Download URL: fincraftr-1.0.0-cp312-cp312-win_amd64.whl
  • Upload date:
  • Size: 91.2 kB
  • Tags: CPython 3.12, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fincraftr-1.0.0-cp312-cp312-win_amd64.whl
Algorithm Hash digest
SHA256 1df1418196d0ed74004b4df0eef188569f985be928d46e76f4cc964fa46b2b30
MD5 b5f52b1204fbe4ef0fb5c016fe40661e
BLAKE2b-256 5b42eda2e5f5e0bc4115f7d3a07f31bc51523dbe2a169a48ec3e78ee6e4e2e62

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp312-cp312-win_amd64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 8d9540e348ed8a2b381a2612e9d6bef5ddb9b7db25c7da5fba3d2920afe3bb96
MD5 8b834f211f66f50f703a087728f6ad04
BLAKE2b-256 d8ddcb7c6c25ac75a2386091134f3647c38b4e07588afff44d5ac89b0bbdaac1

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp312-cp312-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp312-cp312-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp312-cp312-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 af8dd0b4d8c6a28cd2f5690bcaa230cccb4e0d45675307569c8df9a9ce0428bd
MD5 b5c267ad9b7f85b46c13fb375390786c
BLAKE2b-256 83fcfac3b93c0599bbbcfba459637a9be55b49fa205ba2ba083ae0ff9c863c74

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp312-cp312-macosx_11_0_arm64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp311-cp311-win_amd64.whl.

File metadata

  • Download URL: fincraftr-1.0.0-cp311-cp311-win_amd64.whl
  • Upload date:
  • Size: 90.0 kB
  • Tags: CPython 3.11, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fincraftr-1.0.0-cp311-cp311-win_amd64.whl
Algorithm Hash digest
SHA256 16929efc673a8d5fe785b4a8706f01413db04819bd026dd2c70580aa0946bff9
MD5 4af9042f5f8d2375be84b8eed9d13965
BLAKE2b-256 d183de2af95158fbf331689d7c8beea07ac825ab544d8e9daace02720ed24153

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp311-cp311-win_amd64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9a52c37a632e70694ac13c7f16b60de4723e075212d1f7f75adac469be654255
MD5 766f0290811d3d566a4603709050d159
BLAKE2b-256 33aa9d55a063058014afe4fbeb2962c5126e8678ce679a4810ed79cd84e7b1a5

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp311-cp311-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp311-cp311-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp311-cp311-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 8252c37b7fba035819d4b65a4f9ad5f467a52787c31ac8c0acb1e08d153091cb
MD5 e6c6f68422579fab1ff1977dae6659ff
BLAKE2b-256 e03c2fe9a584e61bc3f15394d5bcd1d5c98804fed05b7da51eb9117393698792

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp311-cp311-macosx_11_0_arm64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp310-cp310-win_amd64.whl.

File metadata

  • Download URL: fincraftr-1.0.0-cp310-cp310-win_amd64.whl
  • Upload date:
  • Size: 89.4 kB
  • Tags: CPython 3.10, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fincraftr-1.0.0-cp310-cp310-win_amd64.whl
Algorithm Hash digest
SHA256 0c10e5ca3c95f62a0eff8c6929f53bce2ead82c100b4d0bd00ad98363ff71fe4
MD5 9c2eb2f753b18dae9b5e579415cc009c
BLAKE2b-256 871804ee95f395b220fb1f759e308d551b5b304acd9f13ac25901c3c030fabef

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp310-cp310-win_amd64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 9888422be5ef0673ed11df9a0cf9ec9211941a209133432e819375b91ea14d14
MD5 ceefaf9c6b8c2817237008da576f3f1a
BLAKE2b-256 cfab2971a53acac67c5a088b04d8f81e09376a3a28d374ebab5fe5612f9f93f2

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp310-cp310-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp310-cp310-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp310-cp310-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 c03c38eca4416c21d6390bd48eec01d6d6c32ac5911408dd9af9051d41c623c5
MD5 a90f125c2bce5f3d964c5eff1e66b748
BLAKE2b-256 f38cb86b386c903080fd28867a572bbcb423db1795868196d62c0a3e701828ee

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp310-cp310-macosx_11_0_arm64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp39-cp39-win_amd64.whl.

File metadata

  • Download URL: fincraftr-1.0.0-cp39-cp39-win_amd64.whl
  • Upload date:
  • Size: 92.6 kB
  • Tags: CPython 3.9, Windows x86-64
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.12.9

File hashes

Hashes for fincraftr-1.0.0-cp39-cp39-win_amd64.whl
Algorithm Hash digest
SHA256 6adb789e8c40791aa927aed545b9508fa5689e254d4525229888dc1a9565b725
MD5 bc10503f36f3b2a47d0317745fba11c6
BLAKE2b-256 f2fd36eb6e9b76a5938f8044c43ec25f8ac88a4986591cef39f124368b4ab2f3

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp39-cp39-win_amd64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl
Algorithm Hash digest
SHA256 ba7ac8782dbe460d542bf7fc4a2a1de9928175cc1004856b651a9e22bcac737a
MD5 25b0b6e7f0b8d5c65af42b614fb80248
BLAKE2b-256 46fa95a78c309b4220b8b01c1661a130f6a306228a6f55e29f002521e1aa1948

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp39-cp39-manylinux_2_24_x86_64.manylinux_2_28_x86_64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file fincraftr-1.0.0-cp39-cp39-macosx_11_0_arm64.whl.

File metadata

File hashes

Hashes for fincraftr-1.0.0-cp39-cp39-macosx_11_0_arm64.whl
Algorithm Hash digest
SHA256 ed8d1a24ba69ad7da30e29a6e22d2d3ba5f2c3065a5a0465e6958d158de0548e
MD5 2f0dec8e8d5097136c77c7a7827002e2
BLAKE2b-256 0a0dec4ddafc4e4896ff7a87e32e26e83f1f90d4d75f362ca35dc9ba4d7e9182

See more details on using hashes here.

Provenance

The following attestation bundles were made for fincraftr-1.0.0-cp39-cp39-macosx_11_0_arm64.whl:

Publisher: release.yml on danielyekini/FinCraftr

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

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