Skip to main content
QWED-Finance uses Neurosymbolic AI - combining neural (LLM) outputs with symbolic (math/logic) verification.

1. Compliance guard (Z3)

Purpose: Verify KYC/AML regulatory decisions using formal boolean logic.

Methods

How Z3 works


2. Calendar guard (SymPy)

Purpose: Deterministic day count conventions for interest calculations.

Supported conventions


3. Derivatives guard (Black-Scholes)

Purpose: Options pricing and margin verification using pure calculus.

Methods

Arbitrary-precision arithmetic

Since the Decimal/mpmath migration: DerivativesGuard uses mpmath (30 decimal places) for all transcendental functions — log, exp, sqrt, and erf — replacing IEEE-754 math.* calls. The standard normal CDF and PDF (_norm_cdf, _norm_pdf) are now exact to 30 dp, and verify_margin_call and verify_put_call_parity compare values in Decimal space.
Breaking change — Greeks are now str, not float. Each Greek is Decimal.quantize()’d and returned as a string to preserve precision across serialization boundaries. Cast explicitly if you need a numeric type:
mpmath is now a runtime dependency. It was already pulled in transitively by sympy, so no extra install step is required.

4. Message guard (XML schema)

Purpose: Validate ISO 20022 and SWIFT messages before transmission.

Supported formats

SWIFT MT validation


5. ISOGuard (JSON schema)

Purpose: Enforce ISO 20022 compliance for JSON-based Agentic Banking.

Why JSON vs. XML?

While MessageGuard handles traditional XML SWIFT messages, ISOGuard enables Modern Banking Agents to speak the same standard using lightweight JSON.

6. Query guard (SQLGlot)

Purpose: Prevent SQL injection and unauthorized data access.

Methods

Why AST, not regex?


7. Cross-guard (multi-layer)

Purpose: Combine multiple guards to verify every component.

8. Bond guard (yield analytics)

Purpose: Verify fixed income calculations like Yield to Maturity (YTM) and duration using Newton-Raphson.

Rate format rules

Since v2.1.0: _parse_rate() no longer silently guesses whether an input is a percentage or decimal. The old heuristic (val < 1 → decimal, else percentage) has been removed.
This same parsing logic is used consistently across BondGuard._parse_rate() and FinanceVerifier.verify_irr(), eliminating cross-guard inconsistencies.

Exact arithmetic with Decimal

Since the Decimal/mpmath migration: BondGuard runs Newton-Raphson YTM solving and all duration, convexity, and accrued-interest math in Decimal with 50-digit precision (getcontext().prec = 50). Inputs are converted to Decimal at the boundary, eliminating IEEE-754 cancellation in long-dated bond cashflow sums.tolerance_pct is now stored as Decimal. Pass a float or int — the guard converts it via Decimal(str(value)) to avoid float contamination:
verify_ytm, verify_duration, and verify_convexity return their details fields as quantized strings (e.g. "5.6601%") instead of raw floats.

9. FX guard (currency arbitration)

Purpose: Validate cross-currency conversions and detect arbitrage opportunities.

10. Risk guard (portfolio metrics)

Purpose: Ensure risk metrics like Sharpe Ratio and VaR (Value at Risk) are mathematically consistent.

Exact arithmetic with Decimal

Since the Decimal/mpmath migration: every RiskGuard method computes in Decimal. verify_var and verify_sortino_ratio use Decimal.sqrt() instead of math.sqrt(), and verify_beta accumulates covariance and variance in Decimal to prevent catastrophic cancellation on large return histories.The Z_SCORES lookup table is Decimal-typed:

:::tip PyPI Package All 10 guards are available via pip install qwed-finance :::