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.5.1.tar.gz (96.1 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.5.1-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qfwp-0.5.1.tar.gz
  • Upload date:
  • Size: 96.1 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.5.1.tar.gz
Algorithm Hash digest
SHA256 78a7d0b8ca3c9b3d077789429f0d074e85bef38fb31e953cc049fdd7a11edee5
MD5 d0d3814686543c0269691b1fdd37261c
BLAKE2b-256 55d65ad3169a065c7d4ce17d4b4a616756b8ac713de43c2964747cef14adc3e2

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qfwp-0.5.1-py3-none-any.whl
  • Upload date:
  • Size: 19.2 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.5.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ce421f272afa173062c9bd558ccadc72f365e20e9a9d34c488d6a05f4359bb99
MD5 dcb5221ce78a58935d5b6389dc4485c2
BLAKE2b-256 722a302dadf814dba25e2d33d05810210b1f8c324b02e27c1179b34f3f39ad93

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