Inside a transaction-driven portfolio
Yesterday changes.
Today recalculates.
A portfolio looks like a set of current numbers. Underneath, it is a sequence of decisions. Edit one old event and the rest of the story has to make sense again.
A balance is a conclusion.
Holdings, cash and gains are easy to present as current facts. Their meaning comes from the events behind them: purchases, sales, fees, income, adjustments and corporate actions. The same final quantity can have very different histories.
The hard cases arrive when someone changes the past. An imported purchase may belong before an existing sale. A correction may change the lots available later. A cost-basis method may explain the remaining position differently. Updating a total cannot answer all of those questions.
I helped shape a transaction-driven approach in which the record of events remains durable and the current view can be rebuilt from it. That creates a path back from a number to the decisions that produced it. It also introduces computational work that the interface must acknowledge.
Change the record. Follow the ripple.
No fees or other events. Cost is not market value. The sale price does not change weighted-average unit cost in this example.
The illustration uses a deliberately small weighted-average example. Two purchases create a shared average cost; a later sale reduces the holding. Correct the first purchase price and the quantity stays the same while the cost of the remaining holding changes.
Real histories carry many more events and rules. Cash, lots, holdings, allocation and income need distinct responsibilities so a result can be explained. Replay must apply those rules in a defined order, with behavior that can be tested again after a change.
Repair should be a journey, too.
Historical data is rarely perfect. A strict rule that rejects an import protects consistency, but it leaves the person with a second problem: understanding what to fix. A useful preview makes the affected records and downstream consequences visible before a change becomes durable.
Heavy validation and rebuilding belong in observable asynchronous workflows when they cannot complete comfortably inside an interactive request. The interface needs to distinguish accepted work, work in progress and a completed result. A spinner alone cannot communicate those differences.
Recovery also needs an identity. A failed job should be something an operator can find, inspect and reason about. Otherwise, the person sees a delay while the team sees an unrelated log line. Both sides need to be talking about the same piece of work.
Explainability has a running cost.
Replay is powerful because it makes a history inspectable. It can also become expensive as that history grows. Compression reduces detail; cached projections need invalidation; incremental computation has to preserve the same result as a full rebuild. Each shortcut needs a clear boundary.
Weighted average, FIFO and compressed FIFO are not interchangeable labels. They describe different ways to account for cost. Supporting them means making the behavior explicit, including where performance choices change the granularity available for later explanations.
A useful way to judge an optimization is to start with a small history that can be calculated by hand. Change an early purchase, insert an event between two existing records, then compare the rebuilt result with the optimized path. The exercise is intentionally ordinary: performance work should preserve an understandable answer before it is trusted with a larger history.
The interface has a related obligation. A preview and a completed rebuild should not describe different assumptions without explanation. The person correcting the record needs to know which state they are reviewing and when a new result has replaced the old one.
The question I carry forward is how to make repair faster while keeping it auditable. A quick answer is welcome. An answer that can survive a correction years later is the deeper requirement.
Related work & references
Selected public entry points and related portfolio pages. A company website or profile is context, not a claim that private source code is available.
Scope, context & further questions
These figures describe migration scope, import limits, and cost-basis design. They are scope notes, not measured performance improvements.
- Migration scope: 10k+. Historical portfolios required a safe path from legacy state into replayable records.
- Cost-basis strategies: 3 methods. Weighted average, FIFO, and compressed FIFO required explicit, testable behavior.
- Import boundary: 5,000. Large transaction files demanded asynchronous validation, progress, and failure reporting.
Questions I am still working through
How can replay become incremental without weakening determinism?
Checkpoint derived state at safe boundaries, identify the earliest affected event, and replay only the dependent suffix while preserving one canonical ordering and calculation path. Incremental work must remain equivalent to a full replay.
The hard part is proving equivalence across corporate actions, edits, lot compression, and long transaction histories.
Which historical explanations matter most during correction?
People need to know what changed, which later records are affected, why a later action may become invalid, and what the resulting holdings or cash will be before committing the correction.
The next step is validating which explanation format is clearest for non-technical investors under real support conditions.