Skip to main content

Companion package for 'Learning Quantitative Finance with Python' (CRC Press): real historical episodes (qfwp.data) and the Trone synthetic market (qfwp.synth).

Project description

qfwp — companion package

Companion code for Learning Quantitative Finance with Python (CRC Press).

uv add qfwp      # or: uv sync, to build .venv from pyproject.toml + uv.lock
from qfwp import synth, data

mkt = synth.make_market(level=4)          # the full Trone market
mkt.prices.plot()                          # equities + TRN/USD
data.load("devaluation_1999")              # fetches BCB PTAX, caches locally

Two subpackages:

  • qfwp.data — the real historical episodes (1994 Real Plan, 1999 devaluation, 2008 GFC, 2011 EUR/SNB, 2014 elections) plus usdbrl(), the dollar–real rate adjusted to Real since 1985 (the §2.8 regime figure). Live: loaders fetch on demand from official open-data services (BCB SGS, FRED, ECB) and cache to $QFWP_CACHE (default ~/.cache/qfwp); set QFWP_OFFLINE=1 to pin a build to the cache. No data is redistributed — each series rides under its source's terms, not the package's MIT licence. SOURCES.md documents every endpoint, the series IDs, the ~10-year request cap, and how to call the BCB API yourself.

  • qfwp.synth — the Trone synthetic market with a four-level complexity dial matching the book's four parts, all four implemented:

    • 1 (Basics) — one asset, Trone calendar, seven injectable data pathologies;
    • 2 (Derivatives) — rates curve + meetings, FX pair, vol surface with skew, option chains on the meeting cycle;
    • 3 (Statistics) — six-asset fat-tailed panel, calm/stress regime, t-copula tail dependence (correlations rise in stress);
    • 4 (Risk) — credit names with wrong-way spreads and a jump-to-default, liquidity (widening spreads, no-quote days), and the central-bank floor that holds for years then breaks.

    Levels are strict supersets and the dial design is in SYNTH-DESIGN.md.

notebooks/discrete_hedging.ipynb reproduces the Derman–Kamal discrete-hedging result on the Trone market (see Chapter 8).

Everything is seeded and pinned (uv.lock), so the book's figures reproduce exactly — same seed, same numbers, same chart, on any machine.

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

qfwp-0.6.0.tar.gz (290.2 kB view details)

Uploaded Source

Built Distribution

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

qfwp-0.6.0-py3-none-any.whl (31.6 kB view details)

Uploaded Python 3

File details

Details for the file qfwp-0.6.0.tar.gz.

File metadata

  • Download URL: qfwp-0.6.0.tar.gz
  • Upload date:
  • Size: 290.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qfwp-0.6.0.tar.gz
Algorithm Hash digest
SHA256 42893c2ed89882a4b85176c98edc9941da7e332b6a1381a8bd5ea018ffffa38f
MD5 b7cd997fa3b0a3b94856386952e7d8f9
BLAKE2b-256 86b04adaeac77a449b3556dc5125b3836d2a21c9b45e73ca97fb2da79aab4915

See more details on using hashes here.

File details

Details for the file qfwp-0.6.0-py3-none-any.whl.

File metadata

  • Download URL: qfwp-0.6.0-py3-none-any.whl
  • Upload date:
  • Size: 31.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.28 {"installer":{"name":"uv","version":"0.11.28","subcommand":["publish"]},"python":null,"implementation":{"name":null,"version":null},"distro":{"name":"Ubuntu","version":"24.04","id":"noble","libc":null},"system":{"name":null,"release":null},"cpu":null,"openssl_version":null,"setuptools_version":null,"rustc_version":null,"ci":true}

File hashes

Hashes for qfwp-0.6.0-py3-none-any.whl
Algorithm Hash digest
SHA256 9e649ed6254bcdeaba36332753b1afbc3f96847f1b844c23f9927ef60ecbfcde
MD5 fd85c53754690f3389cc6c5f52825e45
BLAKE2b-256 1c9787939b59ae8925cc7012bd5b08bea6add1f6b47f2995908dcafb085fbfff

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