jmelo11/derivative_structuring

AI-based derivative structuring platform, with QuantSupport as backend.

0

stars

1

commits

Rust

primary language

Sep 14, 2026

updated

README

Structura — AI derivative structuring with QuantSupport

Structura is a self-contained demo desk: describe a derivative in chat, let an OpenAI model express the payoff in QuantSupport's scripting language, then run the script in a Rust service to produce valuation, market-quote sensitivities, deal terms, and risk observations. The UI renders typed results as native widgets rather than scraping numbers from model prose.

Structura AI structuring desk

Run with Docker

docker compose up --build

Open http://localhost:3000, open Model settings, and enter an OpenAI API key. The key is kept in sessionStorage for the current browser tab and is sent to the Rust service only with chat requests. It is not written to disk or logged. For a trusted single-user setup you can instead set OPENAI_API_KEY in a local .env file.

The backend is also available at http://localhost:8080 for direct testing. The default model is gpt-5.6-terra; the settings dialog also offers the lower-latency gpt-5.6-luna and higher-capability gpt-6-astra profiles.

Local development

Requirements: Node 20+, Rust 1.89+, and access to GitHub for the pinned QuantSupport dependency. The adjacent QuantSupport checkout should include the ordinary if/else parser fix in src/scripting/parsing/parser.rs. Docker applies the same small compatibility patch to its pinned checkout automatically.

# terminal 1
cd backend
MARKET_DATA_DIR=../market-data cargo run

# terminal 2
cd frontend
npm install
npm run dev

Vite proxies /api to the Rust service on port 8080.

API surface

  • GET /api/health — service and market-data health
  • GET /api/market-data — model-visible market-data catalogue
  • POST /api/chat — OpenAI Responses API orchestration plus QS execution
  • POST /api/price — execute a typed QS request without an LLM

Direct pricing example:

curl http://localhost:8080/api/price \
  -H 'content-type: application/json' \
  -d @examples/fixed-coupon.json

examples/conditional-coupon.json is a fuller path-dependent example with seven quarterly Term SOFR observations and a conditional redemption. Its source uses ordinary if blocks; QuantSupport evaluates continuous conditions with scale-aware call-spread/butterfly smoothing inside the interpreter, following the fuzzy-evaluator approach from Andreasen and Savine. Payoff authors never need to emit the internal fif primitive.

Market data and risk

market-data/manifest.json is loaded on every price request, so market files can be edited without rebuilding the container. It references the instrument quotes and historical fixings stored alongside it. A script requesting an index, payment currency, equity, or FX payoff that is not configured returns an explicit unsupported_market_data result; the service never silently proxies or substitutes a risk factor.

The demo configures USD SOFR and Term SOFR 3M curves plus a small equity set. Curves are bootstrapped from their market instruments at pricing time, and AAD sensitivities are mapped back to the originating quotes. The UI separates Rates, Equity, and Volatility into tabs; long ladders initially show the eight largest exposures and expand in place.

Linear scripts use one exact discounted-cashflow path. Optional scripts use Owen-scrambled Sobol points with antithetic pairing, pathwise LGM numeraires, and bond/forward martingale control variates. The controls reduce noise inside the full optional-script simulation; they do not change how a trade is routed. The optional-product budget is 2,048 paths. Linear swaps and other non-optional cashflows bypass simulation and use exact pricing.

Broad objectives such as “income with downside protection” use a dedicated comparison workflow. The model authors and submits a complete QS script for each candidate, the Rust service prices every candidate, and the UI presents the alternatives in a carousel with a recommendation, key economics, a standard-bump risk mix, and source code collapsed per card.

Every product, including vanilla swaps and fixed-coupon notes, is structured by the model as a complete dated QS script. The Rust service does not contain product templates: it compiles and executes the supplied events, and can solve explicit numeric script variables against a target PV. Fair, par, ATM and break-even levels for a specified trade always use this full-schedule solve; nearby market pillars are inputs to the curves, not substitutes for the calculated trade level.

Safety and scope

The model cannot execute Rust or shell code. It can only call strict tools whose event strings are parsed by QuantSupport's DSL. Payload sizes and event counts are bounded by the API. Results are indicative demo analytics, not trading advice or production valuations.

Contributors

jmelo11

1 commits

jmelo11/derivative_structuring

AI-based derivative structuring platform, with QuantSupport as backend.

0

stars

1

commits

Rust

primary language

Sep 14, 2026

updated

README

Structura — AI derivative structuring with QuantSupport

Structura is a self-contained demo desk: describe a derivative in chat, let an OpenAI model express the payoff in QuantSupport's scripting language, then run the script in a Rust service to produce valuation, market-quote sensitivities, deal terms, and risk observations. The UI renders typed results as native widgets rather than scraping numbers from model prose.

Structura AI structuring desk

Run with Docker

docker compose up --build

Open http://localhost:3000, open Model settings, and enter an OpenAI API key. The key is kept in sessionStorage for the current browser tab and is sent to the Rust service only with chat requests. It is not written to disk or logged. For a trusted single-user setup you can instead set OPENAI_API_KEY in a local .env file.

The backend is also available at http://localhost:8080 for direct testing. The default model is gpt-5.6-terra; the settings dialog also offers the lower-latency gpt-5.6-luna and higher-capability gpt-6-astra profiles.

Local development

Requirements: Node 20+, Rust 1.89+, and access to GitHub for the pinned QuantSupport dependency. The adjacent QuantSupport checkout should include the ordinary if/else parser fix in src/scripting/parsing/parser.rs. Docker applies the same small compatibility patch to its pinned checkout automatically.

# terminal 1
cd backend
MARKET_DATA_DIR=../market-data cargo run

# terminal 2
cd frontend
npm install
npm run dev

Vite proxies /api to the Rust service on port 8080.

API surface

  • GET /api/health — service and market-data health
  • GET /api/market-data — model-visible market-data catalogue
  • POST /api/chat — OpenAI Responses API orchestration plus QS execution
  • POST /api/price — execute a typed QS request without an LLM

Direct pricing example:

curl http://localhost:8080/api/price \
  -H 'content-type: application/json' \
  -d @examples/fixed-coupon.json

examples/conditional-coupon.json is a fuller path-dependent example with seven quarterly Term SOFR observations and a conditional redemption. Its source uses ordinary if blocks; QuantSupport evaluates continuous conditions with scale-aware call-spread/butterfly smoothing inside the interpreter, following the fuzzy-evaluator approach from Andreasen and Savine. Payoff authors never need to emit the internal fif primitive.

Market data and risk

market-data/manifest.json is loaded on every price request, so market files can be edited without rebuilding the container. It references the instrument quotes and historical fixings stored alongside it. A script requesting an index, payment currency, equity, or FX payoff that is not configured returns an explicit unsupported_market_data result; the service never silently proxies or substitutes a risk factor.

The demo configures USD SOFR and Term SOFR 3M curves plus a small equity set. Curves are bootstrapped from their market instruments at pricing time, and AAD sensitivities are mapped back to the originating quotes. The UI separates Rates, Equity, and Volatility into tabs; long ladders initially show the eight largest exposures and expand in place.

Linear scripts use one exact discounted-cashflow path. Optional scripts use Owen-scrambled Sobol points with antithetic pairing, pathwise LGM numeraires, and bond/forward martingale control variates. The controls reduce noise inside the full optional-script simulation; they do not change how a trade is routed. The optional-product budget is 2,048 paths. Linear swaps and other non-optional cashflows bypass simulation and use exact pricing.

Broad objectives such as “income with downside protection” use a dedicated comparison workflow. The model authors and submits a complete QS script for each candidate, the Rust service prices every candidate, and the UI presents the alternatives in a carousel with a recommendation, key economics, a standard-bump risk mix, and source code collapsed per card.

Every product, including vanilla swaps and fixed-coupon notes, is structured by the model as a complete dated QS script. The Rust service does not contain product templates: it compiles and executes the supplied events, and can solve explicit numeric script variables against a target PV. Fair, par, ATM and break-even levels for a specified trade always use this full-schedule solve; nearby market pillars are inputs to the curves, not substitutes for the calculated trade level.

Safety and scope

The model cannot execute Rust or shell code. It can only call strict tools whose event strings are parsed by QuantSupport's DSL. Payload sizes and event counts are bounded by the API. Results are indicative demo analytics, not trading advice or production valuations.

Contributors

jmelo11

1 commits

Languages

Rust

57.4%

TypeScript

22.0%

CSS

19.9%