Skip to main content

fpml-convert (Python)

Standard-library-only conversion between FpML interest-rate-swap XML and plain JSON, in both directions. No lxml, no third-party JSON — just xml.etree.ElementTree and json.

One projection mapping, also implemented as a JavaScript interpreter (for the Structile viewer) and a pure-STL C++17 converter; the three agree byte-for-byte on a shared test corpus. Downloads, the full version archive, and the mapping's precise rules: https://danieltuzes.github.io/fpml-convert/.

Install

pip install fpml-convert

No runtime dependencies. Python 3.8+.

Use

from fpml_convert import fpml_to_json, json_to_fpml

value = fpml_to_json(xml_text)      # -> dict
xml_text2 = json_to_fpml(value)     # -> schema-ordered FpML, round-trips at the value level
# CLI (direction inferred from the input, or forced with --to)
python -m fpml_convert swap.xml  -o swap.json
python -m fpml_convert swap.json -o swap.xml
cat swap.xml | python -m fpml_convert - > swap.json

The mapping

  • Element local name → object key; a tag repeated under one parent → an array in document order.
  • Namespace prefixes and ElementTree Clark notation ({uri}local) are both reduced to the local name, so the result is identical across a browser DOMParser and a server-side parser.
  • Attributes → @-prefixed keys, before any child keys, ordered @id, @xsi:type, @href, then the rest. xsi:type is kept verbatim.
  • A pure reference element (href, no children) → the scalar «id»; Structile renders that as a link to the element whose @id matches.
  • Typed lexical forms are preserved as strings, never coerced (1000000.00 stays exactly that).
  • Every element the projection descends into is checked against a supported-subset allowlist — an unknown element raises FpmlUnsupportedError rather than projecting partially.
  • Serialization re-emits children in schema (xs:sequence) order.

Scope

FpML 5.10 confirmation view, interest-rate swap dataDocument only. A non-IR-swap document raises ValueError. FRA and other products widen the allowlist in later releases. An FpML-AWG interchange-shape mode is planned.

License

Apache-2.0. The FpML example files used for testing are redistributed under the FpML Public License.

Metadata

Release files for fpml-convert 0.6.0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for fpml-convert 0.6.0
File Size Uploaded
fpml_convert-0.6.0.tar.gz 11.5 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for fpml-convert 0.6.0
File Interpreter ABI Platform
fpml_convert-0.6.0-py3-none-any.whl Python 3 none any Details

Total release size: 23.6 kB

Release files / fpml_convert-0.6.0.tar.gz

Download URL fpml_convert-0.6.0.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
7de4e27df17bdd650a5e41d913c23d862a411f119590544230cb43141c0bf17d
BLAKE2b-256 checksum
How to use checksums
75cea6502973e3014db0b27928b4b0cd9a9c10fd3a29fad8965cb76237f61cd4
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release files / fpml_convert-0.6.0-py3-none-any.whl

Download URL fpml_convert-0.6.0-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
034e4785e118bece2e4b07c8748acc1cf9ae3a337162ba0a6ad4d1874899a6f5
BLAKE2b-256 checksum
How to use checksums
f63616b30ed6aa990120c04a155b58b7089c7d3c6f2e385201b9eb21e9c7e75e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/7.0.0 CPython/3.12.13

Release history Release notifications | RSS feed

0.6.3

2 release files

This release

0.6.0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page