💸 Deposited Capital, Total PnL and Cash Pools
💡 Concept Overview
Capital Baseline = cumulative economic capital contributed since inception:
Total PnL = all value generated above external contributions:
InKindCapital covers the securities that enter or leave the scope without cash:
- incoming ADJUSTMENT rows carrying a cost basis (
cost_basis_override, not linked to a split), at cost: the cost they add to the position; an outgoing row never counts: it has no value (Outgoing Adjustments); - TRANSFER legs whose other leg is not in the scope — it sits at a broker outside the view, is missing, or was never linked — at market value on their own date: \(+\) for securities received, \(-\) for securities sent. A received leg with a cost basis, for a security with no quote and no other operation on or before its date, gives the security its price: its own cost, as an estimate, so on its date its market value is that cost and the leg is neutral. A security with no price at all on that date — no quote, no BUY or SELL and no such estimate on or before it — counts at cost instead: the cost the leg moves in its position, the cost a received leg adds or the average cost a sent leg removes. An unknown cost counts as zero, as in the position's own cost. While the position's cost is complete, the NAV values the holding at that same cost and the leg is neutral; with part of the cost unknown, the holding has no value in the NAV, yet the leg still moves its known cost, so nothing is left in the capital once the units are gone. Nothing counts if the security cannot be valued that day: it has a price, but the exchange rate is missing.
These rows move value without cash: they are capital, not profit or loss. An outgoing ADJUSTMENT is not capital: it realizes the average cost its position gives up as a loss.
🎯 What Counts
| Transaction | Effect on capital baseline |
|---|---|
| DEPOSIT / WITHDRAWAL (unlinked) | ✅ Yes |
| CASH_TRANSFER / FX_CONVERSION whose other leg is outside the view, missing, or never linked (orphan) | ✅ Yes, at its amount, like a deposit or a withdrawal |
| CASH_TRANSFER / FX_CONVERSION / TRANSFER with both legs in the view (internal pair) | ❌ No. Per broker, a pair across two brokers moves capital from the sender to the receiver on the arrival day, summing to zero (Internal Transfers) |
| TRANSFER of securities whose other leg is outside the view, missing, or never linked (orphan) | ✅ Yes, in-kind capital at market value on its date, or at cost for a security with no price at all |
Incoming ADJUSTMENT with cost_basis_override, not split-linked |
✅ Yes, in-kind capital at cost |
| Outgoing ADJUSTMENT | ❌ No: it has no value, and realizes the cost of its units as a loss (below) |
| SPLIT-linked ADJUSTMENT | ❌ No, quantity rescale only |
| BUY, SELL, DIVIDEND, INTEREST, FEE, TAX | ❌ No |
| Exchange-rate move on cash held in another currency (no transaction) | ❌ No: a result, part of TotalPnL; the capital flows (deposits, withdrawals, orphan cash legs) entered the baseline at the rate of their own dates |
📤 Outgoing Adjustments
An ADJUSTMENT that removes \(|q|\) units of asset \(a\) from broker \(b\) on date \(d\) — units given away, sent to an account LibreFolio does not track, or removed by a correction — has no value, whatever cost basis the row holds: it only lowers the quantity. The position gives up the historical cost of those units, at its average cost before the adjustment, each purchase at the rate of its own date, and nothing comes back:
\(s_b\) is the broker's ownership share.
- Capital. Nothing leaves the capital baseline, nor the capital of broker \(b\)'s line. No cash moves, so the cash pools do not change.
- Realized. \(-C\) counts in the period's realized gain or loss and in the position's contribution (Period P&L), and is left out, as a sale is, when the position's cost is incomplete. The average cost of the units that remain does not change.
- Returns. TWRR and MWRR take their flows from the changes of the capital baseline, so the adjustment is no flow: the value of the units leaves the NAV, and the day's return reads it as a loss.
A split-linked ADJUSTMENT is the exception (table above): it only rescales the quantity. Units that leave for money are a SELL.
Two shares given away
Report currency EUR, share 100%. A deposit of €500 buys 10 shares at €50; the price rises to €80. An ADJUSTMENT of −2 shares gives two away, the price unchanged that day: \(C = 2 \times 50 = 100\).
| Moment | NAV | CapitalBaseline | TotalPnL | Realized |
|---|---|---|---|---|
| Before the adjustment | 800 | 500 | +300 | 0 |
| After the adjustment | 640 | 500 | +140 | −100 |
The 8 shares left keep an average cost of €50, so their unrealized gain is \(8 \times (80 - 50) = 240\), and \(-100 + 240 = +140\). The day's flow is 0, so the TWRR reads \(640 / 800 - 1 = -20\%\) that day.
🔀 Internal Transfers in the Broker Lines
With two or more brokers in scope, the P&L chart draws one line per broker. Each broker \(b \in S\) has its own NAV, capital and PnL:
\(\mathrm{InTransit}_b\) is the value in transit that left \(b\), and \(\mathrm{Internal}_b\) is \(b\)'s side of the internal transfers described below. Since \(\sum_b \mathrm{NAV}_b = \mathrm{NAV}\) and the internal flows cancel out every day, the lines add up to the scope figures:
A broker's line is therefore the PnL earned while the value was at that broker, or travelling from it. It is not the unrealized gain of the positions the broker holds.
📐 The Internal Flow
An internal pair is a linked CASH_TRANSFER, FX_CONVERSION or TRANSFER whose two legs are both in \(S\), on two different brokers: the sender \(A\) (the leg going out) and the receiver \(B\) (the leg coming in). It produces one flow, on the arrival day \(t_{arr}\), the date of the later leg:
\(s_A\) is the sender's ownership share and \(V(t_{arr})\) the full value the arrival brings to \(B\) that day, valued exactly as the NAV values it:
| Pair | \(V(t_{arr})\) |
|---|---|
| CASH_TRANSFER | The amount received, converted at \(\mathrm{fx}(c, C^*, t_{arr})\) |
| FX_CONVERSION across brokers | The received leg, converted the same way: \(-1{,}000\) USD at \(A\) → \(+900\) EUR at \(B\) gives \(V = 900\) EUR, and the conversion cost stays in \(A\)'s line |
| TRANSFER of securities | \(\mathrm{MV}\) of the quantity received at the valuation price of \(t_{arr}\), the last known price carried forward if there is none that day. With no price at all on or before \(t_{arr}\), the cost basis the units add to \(B\)'s position — the cost recorded on \(B\)'s leg, converted at that leg's date —, since the NAV values a holding with no price at its cost (§3) |
With equal shares, \(X\) is exactly what the arrival adds to \(\mathrm{NAV}_B\), so neither line jumps. The scope's \(\mathrm{CapitalBaseline}\) is untouched, because an internal move is not external capital: NAV, CapitalBaseline, TotalPnL and its candles, ROI, TWRR, MWRR and cash are the same as without the flow. Only the split of the baseline among the brokers changes.
✈️ Value in Transit
When the legs fall on different days, the value travels from the departure day \(t_{dep}\) to the day before \(t_{arr}\). Meanwhile it is part of \(\mathrm{InTransit}_A\), at the sender's share \(s_A\), valued every day: cash at that day's exchange rate, securities at that day's valuation price (at the cost recorded on the transfer if the security has no price at all). No flow happens while the value travels, so its price and exchange-rate moves stay in \(A\)'s line, the arrival day's own move included; \(B\)'s line starts from the value received.
For example, \(A\) receives a deposit of 1,000 USD on day 0 at 0.90 EUR per USD (\(C_A = 900\)) and sends the dollars on day 1; \(B\) receives them on day 4. With the rate at 0.90, 0.91, 0.92, 0.93 on days 1–4, \(A\)'s line reads 0, +10, +20, +30 and \(B\)'s stays at 0. On day 4, \(X = 930\) and \(C_A = 900 - 930 = -30\). Once arrived, the dollars are \(B\)'s cash, revalued every day, so from day 5 \(B\)'s line moves with the rate: at 0.94, it reads +10.
🧩 Special Cases
- Different ownership shares. \(X\) uses \(s_A\), like the value in transit, while the arrival adds \(s_B \cdot V(t_{arr})\) to \(\mathrm{NAV}_B\). \(B\)'s line keeps a residual step of \((s_B - s_A)\,V(t_{arr})\) on the arrival day, and TotalPnL shows the same step, with or without the flow.
- Value unknown on the arrival day. If \(V(t_{arr})\) cannot be computed — an exchange rate is missing, or the security has no observation on or before \(t_{arr}\) (\(\operatorname{mark} = \varnothing\)) and the cost on \(B\)'s leg is unknown (no cost basis, or one with no exchange rate), so that the arrival adds nothing to \(B\)'s position cost — then \(X = 0\). Nothing is guessed: the jump stays, and the security's value appears in the line of the broker holding it from its first price.
- No price at all. A security with no observation on or before \(t_{arr}\) moves at the cost its arrival adds to \(B\)'s position — the cost recorded on \(B\)'s leg, the sender's average cost when the transfer is saved with an automatic cost basis — whether or not \(B\)'s cost is complete. With \(B\)'s cost complete, that is the value \(\mathrm{NAV}_B\) takes the units at, so with equal shares \(B\)'s line does not jump. The cost need not equal the value the units had at \(A\) before leaving, \(A\)'s own cost basis or nothing when that cost was incomplete; the difference ends up in \(A\)'s line, and TotalPnL shows it too. With \(B\)'s cost incomplete — \(B\) already held units of unknown cost — \(B\)'s holding has no value in the NAV, which is incomplete: \(B\)'s line takes the gap, its own unknown cost, and \(A\)'s line is the same as with a complete cost at \(B\).
- Fees. They are not part of \(X\). A FEE row of 5 recorded at the sender, or the same 5 as a gap between the legs (\(-1{,}000\) sent, \(+995\) received, so \(X = 995\)), stays in \(A\)'s line as a loss of 5.
- Same-broker pairs. Two legs on the same broker, such as a currency conversion inside one account, need no flow: the value never leaves the line.
- ADJUSTMENT pairs. They are not internal pairs: each leg follows its own rule (see the table above). The receiver's capital rises by the cost its leg adds; the sender's leg has no value, so its capital does not move and it realizes its average cost as a loss (Outgoing Adjustments). With the setup of the example below and both legs on day 2, the receiving leg at a cost of 10: \(A\)'s line drops to \(-100\) and \(B\)'s reads \(+20\), so TotalPnL falls from \(+20\) to \(-80\). To move units between two brokers without that loss, link the two adjustments as a TRANSFER pair.
🔍 Filtered Views
In a view with only some brokers, a TRANSFER leg whose other leg is outside \(S\) — or missing, or never linked — cannot form an internal pair. It is in-kind capital at market value on its own date: \(+\mathrm{MV}\) for securities received, \(-\mathrm{MV}\) for securities sent, at that broker's share — at cost for a security with no price at all, as above — and nothing if the security cannot be valued that day. Unlike an internal flow, it moves the view's CapitalBaseline, so the view's TotalPnL, ROI, TWRR and MWRR treat it as capital, like an in-kind ADJUSTMENT. A CASH_TRANSFER or FX_CONVERSION leg in the same position is external cash at its amount, like a deposit or a withdrawal, and it moves the cash pools as that deposit or withdrawal would: the split of the view's cash between contributed capital and generated returns, and the funding of its later purchases, follow it.
When the broker holding the other leg is deleted, the remaining leg becomes what a split of the pair leaves, and the legs older versions left are converted the same way at startup: securities become an ADJUSTMENT — a received leg in-kind capital at cost when it carries a cost basis (table above), no longer at market value; a sent leg an outgoing ADJUSTMENT without a value, which realizes the cost of its units as a loss (Outgoing Adjustments) — and cash a DEPOSIT or a WITHDRAWAL. The converted rows follow the same rules in every view, the full one included.
Comparing a broker's own view with the combined view:
- The receiver alone matches its combined line. In \(B\)'s own view the received securities are capital at their market value on \(t_{arr}\), which is the \(X\) of the combined view. This holds with equal shares and a price that both views can see: a price that comes only from trades at \(A\) is not visible in \(B\)'s own view.
- The sender alone loses the moves in transit. In \(A\)'s own view its capital drops on the departure day by \(s_A \cdot V(t_{dep})\), while in the combined view the value stays with \(A\) until it arrives.
Writing \(\mathrm{PnL}_A^{(S)}\) for \(A\)'s line in the view of scope \(S\), from the departure day on:
📦 Example — Securities in Transit
All amounts in EUR, shares 100%. \(A\) receives a deposit of 100 and buys 10 units at 10 on day 0. The price is 10, 11, 12, 13, 14, 15 on days 0–5. \(A\) sends the 10 units on day 1, and \(B\) receives them on day 3.
Combined view (both brokers in \(S\)):
| Day | Price | \(\mathrm{NAV}_A\) | \(C_A\) | \(\mathrm{PnL}_A\) | \(\mathrm{NAV}_B\) | \(C_B\) | \(\mathrm{PnL}_B\) | TotalPnL |
|---|---|---|---|---|---|---|---|---|
| 0 | 10 | 100 | 100 | 0 | 0 | 0 | 0 | 0 |
| 1 | 11 | 110 (in transit) | 100 | +10 | 0 | 0 | 0 | +10 |
| 2 | 12 | 120 (in transit) | 100 | +20 | 0 | 0 | 0 | +20 |
| 3 | 13 | 0 | −30 | +30 | 130 | 130 | 0 | +30 |
| 4 | 14 | 0 | −30 | +30 | 140 | 130 | +10 | +40 |
| 5 | 15 | 0 | −30 | +30 | 150 | 130 | +20 | +50 |
On day 3 the flow \(X = 10 \times 13 = 130\) moves capital from \(A\) to \(B\). \(A\) keeps the +30 earned while the units were at \(A\) or travelling (10 → 13), and \(B\) earns from 13 on. \(C_A\) turns negative because \(A\) passed on more value (130) than the capital it took in (100): the difference is its gain. TotalPnL is the same with or without the flow; without it, on day 3 \(A\)'s line would drop to \(0 - 100 = -100\) and \(B\)'s would jump to \(130 - 0 = +130\).
Single-broker views:
| Day | \(B\) alone: \(C_B\) | \(B\) alone: \(\mathrm{PnL}_B\) | \(A\) alone: \(C_A\) | \(A\) alone: \(\mathrm{PnL}_A\) |
|---|---|---|---|---|
| 0 | — | — | 100 | 0 |
| 1 | — | — | −10 | +10 |
| 2 | — | — | −10 | +10 |
| 3 | 130 | 0 | −10 | +10 |
| 4 | 130 | +10 | −10 | +10 |
| 5 | 130 | +20 | −10 | +10 |
\(B\)'s own view starts at its first transaction and matches \(B\) in the combined view. In \(A\)'s own view the units leave on day 1 at \(10 \times 11 = 110\), so \(C_A = 100 - 110 = -10\) and the line stays at +10: the move from 11 to 13 while travelling is not in it, and \(+30 - (130 - 110) = +10\). Counted as a gain or a loss instead of capital, the same transfer would put \(A\) alone at −100 from day 1 and \(B\) alone at +130 on day 3.
💶 Example — Cash Between Two Brokers
\(A\) receives a deposit of 5,000. Later, \(A\) sends 1,000 to \(B\), both legs on the same day.
| Case | \(\mathrm{NAV}_A\) | \(C_A\) | \(\mathrm{PnL}_A\) | \(\mathrm{NAV}_B\) | \(C_B\) | \(\mathrm{PnL}_B\) | TotalPnL |
|---|---|---|---|---|---|---|---|
| After the deposit | 5,000 | 5,000 | 0 | 0 | 0 | 0 | 0 |
| After the transfer | 4,000 | 4,000 | 0 | 1,000 | 1,000 | 0 | 0 |
| \(B\) receives 995 (fee 5) | 4,000 | 4,005 | −5 | 995 | 995 | 0 | −5 |
| \(B\) owned at 50% | 4,000 | 4,000 | 0 | 500 | 1,000 | −500 | −500 |
| Without the flow | 4,000 | 5,000 | −1,000 | 1,000 | 0 | +1,000 | 0 |
The last row is the same transfer read without the internal flow: the move looks like a loss for \(A\) and a gain for \(B\). With \(B\) owned at 50%, the step of −500 is the residual \((s_B - s_A)\,V = (0.5 - 1) \times 1{,}000\), and TotalPnL shows it too.
📊 Three-Pool Cash Model
The Growth Chart decomposes current cash into two visible aggregates plus a hidden global tracker:
| Pool | Scope | Meaning |
|---|---|---|
| \(K_b\) | Per-broker | External capital still at broker \(b\) |
| \(R_b\) | Per-broker | Generated returns still at broker \(b\) |
| \(W\) | Global | Returns that left the system (restorable on re-deposit) |
Key properties
- \(\mathrm{CapitalBaseline}\) = historical sum of cash and in-kind capital flows. \(\sum K_b\) = how much current cash is external capital. They diverge after BUY/SELL.
- A BUY on broker \(b_1\) only consumes \(R_{b_1}\), never \(R_{b_2}\).
- Cash transfers between brokers and currency conversions with both legs in the scope move \(R\) and \(K\) from source to destination without touching \(W\): the departure leaves returns first, and the arrival brings back what it took from capital and returns; any gap between the two legs — another currency, another day's rate, another ownership share — is a result.
- A cash transfer or conversion leg whose other leg is outside the scope, or that has lost its pair, moves the pools as a DEPOSIT or a WITHDRAWAL of its amount: arriving, it first restores withdrawn returns from \(W\) into \(R_b\) and the rest is \(K_b\); leaving, it takes \(K_b\) first, then \(R_b\), which goes to \(W\) (example E).
- An exchange result on cash a broker holds in another currency goes to \(R_b\); a loss larger than \(R_b\) comes out of \(K_b\), as a FEE does. \(\mathrm{CapitalBaseline}\) does not move (Portfolio Engine — §6).
🔗 Full per-broker update rules: Portfolio Engine — §6 Three-Pool Model
📝 Worked Examples
🧾 A — Deposit → Buy → Sell in Gain
| Step | Tx | \(K\) | \(R\) | Cash |
|---|---|---|---|---|
| 1 | DEPOSIT €1,000 | 1,000 | 0 | 1,000 |
| 2 | BUY €1,000 | 0 | 0 | 0 |
| 3 | SELL P=€1,200, C=€1,000 | 1,000 | 200 | 1,200 |
TotalPnL = 1,200 − 1,000 = +€200 ✓
💸 B — Dividend then Withdrawal
| Step | Tx | \(K\) | \(R\) | \(W\) | Cash |
|---|---|---|---|---|---|
| 1 | DEPOSIT €1,000 | 1,000 | 0 | 0 | 1,000 |
| 2 | DIVIDEND €50 | 1,000 | 50 | 0 | 1,050 |
| 3 | WITHDRAWAL €100 (K first) | 900 | 50 | 0 | 950 |
| 4 | WITHDRAWAL €950 (K=900→0, R=50→0, W+=50) | 0 | 0 | 50 | 0 |
| 5 | RE-DEPOSIT €30 (restore min(30,W=50)=30) | 0 | 30 | 20 | 30 |
After step 5: Cash=30, K=0, R=30 ✓ (returns restored from W)
🧪 C — Full Sell Regression
| Step | Tx | \(K\) | \(R\) | Cash |
|---|---|---|---|---|
| 1 | DEPOSIT €1,000, BUY 1@€1,000 | 0 | 0 | 0 |
| 2 | SELL 1@€1,005 (C=1000, G=5) | 1,000 | 5 | 1,005 |
Capital correctly returns to \(K\); only €5 gain to \(R\). Not all €1,005 to \(R\).
💱 D — Dollars Held While the Rate Moves
One broker, report currency EUR, rates in EUR per USD; \(\varepsilon\) is the exchange result on cash.
| Step | Event | \(\varepsilon\) | \(K\) | \(R\) | Cash | TotalPnL |
|---|---|---|---|---|---|---|
| 1 | DEPOSIT 1,000 USD at 0.90 | — | 900 | 0 | 900 | 0 |
| 2 | Rate rises to 0.95 | +50 | 900 | 50 | 950 | +50 |
| 3 | Rate falls to 0.85 (\(R\) = 50 − 100, \(K\) absorbs −50) | −100 | 850 | 0 | 850 | −50 |
| 4 | BUY for 1,000 USD at 0.85 (€850) | — | 0 | 0 | 0 | MV − 900 |
The CapitalBaseline stays €900 throughout: the exchange results are profit and loss, not capital. After step 4, TotalPnL is the security's market value MV less the €900 deposited — −50 on the purchase day if MV equals the €850 paid.
🔀 E — Cash From Outside the View
The view of broker \(B\) alone; broker \(A\) is outside it, so each cash transfer between them is an external flow of the view, as in Filtered Views above.
| Step | Tx at \(B\) | \(K\) | \(R\) | \(W\) | Cash |
|---|---|---|---|---|---|
| 1 | DEPOSIT €100, INTEREST €100 | 100 | 100 | 0 | 200 |
| 2 | CASH_TRANSFER €150 to \(A\), as a WITHDRAWAL (K=100→0, R=100→50, W+=50) | 0 | 50 | 50 | 50 |
| 3 | CASH_TRANSFER €100 from \(A\), as a DEPOSIT (restore min(100,W=50)=50, the other 50 to K) | 50 | 100 | 0 | 150 |
| 4 | BUY €100 (R first) | 50 | 0 | 0 | 50 |
The purchase of step 4 is all reinvested returns, none of it new capital. The same holds for a transfer leg that has lost its pair, in every view. In the view of \(A\) and \(B\) together, both transfers are internal pairs instead and move the pools from one broker to the other, without touching \(W\).
⚙️ Implementation
The 3-pool model runs in a single per-transaction loop (event-driven, not daily-delta):
- Take the transaction's step of its position's average-cost pool, computed before the replay — for a SELL, the cost it removes (\(C\) = pre-sale WAC × quantity sold, at historical rates)
- Update K/R/W per transaction type rules, with that \(C\) for a SELL
On each day the exchange rate of a foreign currency held as cash changes, each broker's exchange result on that cash is also booked into its pools, after the day's cash movements and before the day's transactions (§6).
The ROI/TWRR/MWRR input series is derived from day-over-day changes in cumulative_external_cash_flow, the capital baseline. It is not derived from the cash-only external_cash_flow field.
🔗 See Portfolio Engine — §6 for all formal rules.
🔗 Related
- 💼 NAV — the other term in Total PnL
- 📊 Period PnL — windowed version
- ⚙️ Portfolio Engine — full mathematical model
- 📈 Performance Metrics Overview — all performance metrics at a glance