Task: Repair the equity routing
Table of Contents
This page documents a task in the Rework the equity instruments to the instrument table rule story. It captures the goal, current status, acceptance, and any notes or results.
1. Goal
A position nested in a total return swap reaches its own trade's key instead of being written as a central equity row, so the routing and the stored type no longer disagree. The 13 unrouted codes stay unrouted.
The 17 routed codes are not re-pointed here. The catalogue's instrument column names the table that holds a code, and under the atomised shape the central row is what holds an instrument; a part reaches its central row by the key and is never a routing target. The re-pointing therefore lands in unit 5 with the header it names.
2. Status
| Field | Value |
|---|---|
| State | DONE |
| Parent story | Rework the equity instruments to the instrument table rule |
| Now | Nothing. |
| Waiting on | Nothing. |
| Next | Nothing. |
| Last touched | 2026-10-17 |
3. Acceptance
- A position nested in a total return swap is keyed by the trade that owns it and writes no equity central row.
- The catalogue routes no equity code to a table that does not hold it.
- The 13 codes with no importer keep an empty
instrument.
4. Plan
(Implementation strategy. Written when work starts; key decisions
are distilled into the parent story's * Decisions at close, but the
plan itself stays — it is the historical record of what we did.)
5. Measurements
Every number this task claims about a tree, with the command that produced it
and the commit it was measured at. A number without both is not a measurement,
because a clean-up record describes a tree and trunk moves under a branch: a
consumer count, a gate's component count and a suite's size all change with no
code changing, and the reader of a bare number cannot tell which tree it came
from. Where the raw output matters, put it in an evidence/ file beside the
task and name that file in the Command column.
| What | Value | Command | Commit |
|---|---|---|---|
| Equity codes the catalogue routes to a product table | 17 | the instrument column of ores.trading.trade_type_catalogue.org |
06cee39705 |
Equity codes with an empty instrument |
13 | as above | 06cee39705 |
Codes routed to composite_instrument |
2, TotalReturnSwap and ContractForDifference |
as above | 06cee39705 |
| ORE core suite after the change | 483711 assertions in 719 cases, all pass | ores.ore.core.tests |
e82322bf99 |
6. Notes
7. Test Scenarios
Manual QA scenarios (scaffolded via compass add test_scenario)
that verify this task. Link
new ones here as they're created; the scenario doc itself links back
via its "Verifies task" field.
| Scenario | State | Notes |
|---|---|---|
8. PRs
9. Review
| Comment summary | File | Decision | Notes |
|---|---|---|---|
10. Result
A total return swap is now the composite the catalogue says it is. The
import mapper no longer diverts a swap whose underlying is an equity
position into the equity family, so no equity_position_instrument row is
written for a trade whose type is a swap, and the routing and the stored
type agree (E6).
The old path is removed rather than accommodated, per the operator: no
compatibility branch, no migration, and the database was recreated.
underlying_sub_trade_type, nested_sub_trade and the two fall-backs are
deleted, and both reverse mappers lost outer_trade_type and the wrapper
that rebuilt a swap around a position. Five files, 47 insertions and 112
deletions.
ores.ore.core.tests passes: 483711 assertions in 719 cases.
The corpus has no top-level position document, so the mapper test takes the sub-trade out of the swap fixture and maps it as the top-level trade it now is. That is a compromise worth naming: the position path is covered through a constructed top-level trade, not a documented one. A real top-level position fixture would be better and does not exist today.