Trade set membership
Table of Contents
1. Summary
A context resolves membership in one of two ways. Derivation reads the trades' own attributes, so the set is a query and stores nothing. Recording writes a row per member, so the set has a key and holds still. Every set is read at a point in time, and that time is part of the definition rather than a filter applied after the fact.
2. Detail
2.1. Derived membership
A derived set is a predicate over trade attributes. The trades in a book are the trades whose book is that book. The predicate is the whole of the set's definition, and nothing is stored for the set itself.
Two consequences follow. The set is always current, because the next read evaluates the predicate again. And the set cannot be referred to on its own, because it has no key beyond the context's entity.
2.2. Recorded membership
A recorded set is a list. It holds one row per member, and it is the rows that make the set, not any attribute of the trades in it. A recorded set of trades that share nothing is a perfectly good set.
The list is what lets the set be read later. A batch that selected a thousand trades in the morning must value those thousand trades in the afternoon, even if a hundred of them were cancelled in between.
2.3. Why both exist
A derived set answers "what is in this book now". A recorded set answers "which trades did this run read". The first answer must move, or the book would be wrong. The second must not, or the run could not be described after the fact. A run that recomputed its input later would read a different set, and the difference would be invisible.
2.4. The point in time
A derived set read twice gives two answers, and neither is wrong. The time of the reading belongs to the reading, not to the set.
For that reason a set that a trade group records carries the moment it was read. A process that read a hundred trades and changed two has to be distinguishable from one that read two, and a repeat has to reconstruct the same input rather than take today's. Recording the membership is the mechanism, and the time point is the part of it that makes the record mean something.
2.5. Where membership lives
- A derived set is a key on the trade's booking. There is no membership table, and the nesting rule decides whether that key is part of the trade's identity.
- A recorded set is a membership table, keyed by the set and the trade.
2.6. How membership changes
A trade joins a book when someone books it there, and leaves when the book changes. That change is versioned with the rest of the booking, as Trade Versioning describes.
A trade leaves a derived set of live trades when it expires or is cancelled, and nobody writes to the set to make that happen. The set moved because its predicate moved.
A recorded set never changes. It is superseded by a new reading, or it goes away with the record that owns it. Editing the list would destroy the only evidence of what was read.
2.7. What follows for the model
- Derivation costs a query at read time and no storage.
- Recording costs storage and gives a stable, referable set.
- A recorded set that must be undone belongs to a record that can be undone, rather than to a delete.
3. Sources
The derived-versus-recorded split and the time-point rule are this page's synthesis, from the internal analysis notes on process runs and the requirement that a run be repeatable.
4. See also
- Trade sets and trade groups — the hub that orders this cluster.
- Trade set — the primitive this page resolves membership for.
- Nested trade sets — how a derived membership becomes part of a trade's identity.
- Trade group — the recorded set a run leaves behind.
- Trade Versioning — how a change of book is recorded on the trade.
- Data-Oriented Design in ORE Studio — why a stored relationship is a row and a derived one is a key.
- Trade — the structure note that orders this cluster, and where to read this page in it.