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.0.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.0-py3-none-any.whl (19.2 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: qfwp-0.5.0.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.0.tar.gz
Algorithm Hash digest
SHA256 110a1f787b8c492d4adcadc28be99db73a1281a241db321473f0664410540750
MD5 a052efd9a146d20c2e0ee750e96b2ae3
BLAKE2b-256 24dd73b94ef48cc3a10764238b010c8463c26529fd7d0c800e454f0a42d03ffc

See more details on using hashes here.

File details

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

File metadata

  • Download URL: qfwp-0.5.0-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.0-py3-none-any.whl
Algorithm Hash digest
SHA256 b8ad2a6771c6945b0188ae8f36a798d1f65ceb59d4678c914aa79418ae5d4d41
MD5 a72b9c401bdc2582b37ed25506d94e8b
BLAKE2b-256 3a4fd6f57c701df2235e25b1de19719a84f9b125775596d0a29be67f2c991cf0

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