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). 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. See SOURCES.md.

  • 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.4.2.tar.gz (93.9 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.4.2-py3-none-any.whl (18.0 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qfwp-0.4.2.tar.gz
  • Upload date:
  • Size: 93.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.4.2.tar.gz
Algorithm Hash digest
SHA256 5864f4e9758e15c7d947d0a7aa4adf88e3288942f0c8368e5ef6a425b40e08f5
MD5 e318ccd2bb1bd7ba9a69b3591087d170
BLAKE2b-256 eeeaaad9f58cd54489c4360c61fbb9c637f44d623bf63abf75ab0eebfe006bda

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qfwp-0.4.2-py3-none-any.whl
  • Upload date:
  • Size: 18.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: uv/0.11.21 {"installer":{"name":"uv","version":"0.11.21","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.4.2-py3-none-any.whl
Algorithm Hash digest
SHA256 f9e9df507211f26f69c0e4449f45bc95ee41659247a3b1aaebce1212f36be2b9
MD5 bbb59f876ae82646a88c17e69671143f
BLAKE2b-256 40020081a4834eb8c69a65bfd081cfebe69c4013bf49f4ab3b613711080c2a2a

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