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.3

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.3
File Size Uploaded
fpml_convert-0.6.3.tar.gz 11.5 kB Details

Built distribution (wheel)

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

Total release size: 23.6 kB

Release files / fpml_convert-0.6.3.tar.gz

Download URL fpml_convert-0.6.3.tar.gz
Size 11.5 kB
Tags Source
SHA-256 checksum
How to use checksums
865bb7c74877f996cb3c98cf282dbcc17be73395ef9126fb5fd97ca51bdeb2a2
BLAKE2b-256 checksum
How to use checksums
c6897f5828590750e8c18c5a695bb4bde6d0a7c390c4d2c4de8ad18b32ee8460
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.3-py3-none-any.whl

Download URL fpml_convert-0.6.3-py3-none-any.whl
Size 12.1 kB
Tags Python 3
SHA-256 checksum
How to use checksums
a43027fb20528d04a31d78d5d795084c3cd8ae1ec591383a23813fb1ea38b33b
BLAKE2b-256 checksum
How to use checksums
623c4c7f246edfaaf2dde6978d5129c0890a8dbfffd5ed936d9d98d74e54d1c2
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

This release

0.6.3 This release

2 release files

0.6.0

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