The structure view
Table of Contents
| Item | Where |
|---|---|
| Prototype | the prototype |
| Gemini review | none |
| Signed off | the owner, 2026-10-29 |
| Group | Trades prototypes |
1. Summary
A structure is an entity: an immutable identity and legs that are trades. A package is not a second entity. The composition ladder in Trade Structures and Deal Composition ends in the untyped structure, which the note calls a package, and the model holds it as a structure of kind Package: the same table, the same anchor, the same members. So the prototype has one screen, and its words follow the kind. A package page says package, and a strategy page says structure. It also draws the workflow Group trades into a structure.
2. Detail
2.1. A structure is a tree
The root is the deal the customer sees. Inside it are strategies, packages and plain trades, and the leaves are trades. This is the deal topology of Trade Structures and Deal Composition. The page draws it as a tree in its own panel beside the page, one row for the root, one for each inner structure with its kind tag and how it confirms, and one for each trade with its product tag, its role and its notional. The panel shows the whole tree of the root whichever node is open. A click on a structure opens its page. A click on a trade selects it, and the page shows that trade's card in the tree, with a link to the trade.
The model nests one level at most. parent_structure_id points to a root, and an inner structure holds only trades. The note draws a deeper tree, and the insert trigger refuses it. The page says so under the tree.
2.2. States
The page opens on a structure. The list it opens from is the blotter, which draws the trees and the trades together; this page is what a structure row opens.
| Query | What it shows |
|---|---|
?deal=STR-0010 |
A dynamic structure that is the root of a tree: a strategy, a package and a hedge trade inside it |
?deal=STR-0007 |
The strategy inside it, a risk reversal, with its template roles checked |
?deal=PKG-0021 |
The package inside it: a bond repo and a bond, each confirming on its own |
?deal=STR-0009 |
A typed structure on its own: a callable swap, with legs of different families |
?deal=PKG-0004 |
A package on its own: a swap and a cap |
?mode=group&trades=ACME-100202,ACME-100209 |
The grouping workflow, with the kind to choose |
?mode=group&trades=ACME-100201,ACME-100202 |
The refusal: the trades have different counterparties |
?state=loading, ?state=error, ?state=empty, ?state=stale, ?state=refused&tab=history |
The states of the list and the page |
?as=reader |
The grouping screen names the right it needs and links to a request for each role that gives it |
2.3. Open question
A package inside a structure that confirms as one document: does each of its trades still confirm on its own, or inside the one document? The notes do not say. The tree shows each node's own kind, the page warns that this is undecided, and the amend dialog says so for a trade inside such a package. It is filed as a capture.
2.4. Structure and package
They are different rungs of the composition ladder, one entity with a kind, and the page treats the kinds differently. The test is how the customer holds the trades. See Trade Structures and Deal Composition.
| Strategy, typed, dynamic | Package | |
|---|---|---|
| The customer holds | One deal | Each trade under its own terms |
| Confirmation | One document for the deal | Each leg confirms on its own |
| Pricing | As a whole | Leg by leg: the price is the sum of the parts |
| External version | Of the deal | Of each trade |
| Template and roles | A template fixes them (strategy, typed). Dynamic reads them from data | None. Any role is allowed |
| Product family | A strategy has one. Typed and dynamic may mix | Any mix |
| Unlinking a leg | Changes the deal. A partial close-out is a lifecycle event | The other legs are unaffected |
PKG-0004 is a package of a swap and a cap. STR-0007 is a risk reversal, a strategy. The page shows the chips, the card "How it confirms and prices", and the members table differently for each. The Members tab of a package shows each leg's external version, because the customer quotes the one for the trade they hold. The trade page says which kind a trade's structure is, and the amend dialog says whose confirmation a change reaches.
A composite trade is neither. It is one trade with its own legs, and it is not in a structure in these prototypes.
2.5. What the prototype argues
- The version is read from the legs and is never stored beside them. A change to a leg moves that trade's version and not the structure's.
- The kind is chosen at grouping, with its consequences stated beside each choice, because it decides what the customer receives. Package is one of the four kinds, so there is one workflow, Group trades.
- The client states the rules the database enforces: every leg shares the party and the counterparty, a structure nests one level at most, and a strategy has one product family. The person sees the check before the server refuses it.
- A trade moves from one structure to another without being rewritten.
- Pricing is the Price tab. It reads a market snapshot, says when it was read, and does not tick. A newer snapshot turns Refresh gold, and Refresh reads it. The price is indicative, and the shifts that were applied are named.
- A leg is booked on Book a trade. Book a leg is in the Workflows menu and on the Members tab, and it carries the structure and the open role in the address. It is not shown when the template has no role left.
- The Members tab states what the template asks of the legs, as checks that pass or fail: one product family for a strategy, a call and a put at one strike for a straddle, and the other templates by their descriptions. A risk reversal's legs differ in option type and strike in the mock data, so the checks have something to find.
- A change to the members is recorded in the history of the structure with its reason and commentary, and it stays when the page is loaded again.
- A tab, a click in the tree and a click on a trade open in place and put their address in the history. Link a trade is the Add of the Trades card and is not in the menu. Link and Unlink ask for a reason and commentary, and the card keeps its old rows until Refresh, which then adds an entry to History.
2.6. What is fake
The structures. Grouping stores the new structure in the browser.
2.7. Where the code lives
doc/prototypes/trades/structure-page/.