Trace a process run over a set of trades

Table of Contents

This page is a capture in the inbox bucket of the product backlog — a pre-sprint idea, not yet pulled into a sprint as a story.

1. What

A process that acts on a set of trades — a compression, a merge, an allocation, a funding roll, a sweep run, a cleardown, an import, a bulk book move — must be traceable so it can be undone or repeated. Three pieces are missing:

  1. An enumeration of the processes, so a run names which process ran.
  2. A table recording each run of a process, with an id generated for that run. The run is expected to need a state machine over its evolution, in the way the other long-running records in the tree do.
  3. The run id as the foreign key the trade groups carry, for the inputs and for the outputs, so the set of trades a run read and the set it wrote are both reachable from the run.

This is roughly the shape and not yet a design. It needs proper analysis before it is built.

2. Why

A process that read a hundred trades and changed none of them leaves no trace today, and a process that read a hundred and changed two cannot be told from one that read two. Undo and repeat both need to know what the inputs were and at which time point the process read them, because a repeat has to reconstruct the same input set rather than today's.

Trade sets and trade groups states what a trade group is: a trade set created for a run of a process, with the run supplying the identity, the provenance, the roles and the undo. What is missing is the run itself.

3. Approach

Pilot one process end to end before adding the rest, and pick it from the processes already in the tree rather than inventing one:

  • Funding roll (Tom/Next) and sweep run (Spot Sweep) are candidates, because both have a book in the tree that describes them and both run over a population rather than over a pair.
  • Add the remaining processes only once the pilot has settled the run table, the state machine and the input/output keys.

4. The stamp is not the run

A trade amendment carries a trade activity stamp that classifies what the amendment was about, so risk buckets by amendment type. It stands alone and needs no other trade. Where an amendment was generated by a process, the process stamps its own activity, so the stamp matches the run in some cases — and that match is incidental. Nothing requires a stamp to point at a run, and a stamp exists for many amendments no process produced.

For that reason the stamp stays as it is, and this work adds the run beside it rather than behind it.

5. References

6. See also

Emacs 29.3 (Org mode 9.6.15)