What cost basis is#
Cost basis is what you paid for an investment. If you bought 10 shares at $100, your basis is $1,000. It sounds trivial, but basis is the anchor for two numbers you care about: your gain, and your tax bill when you sell. Gains are measured against basis, and the IRS taxes realized gains, so tracking basis precisely is not optional bookkeeping. It is the ledger that decides what selling actually costs you.
Realized vs unrealized gain#
An unrealized gain exists only on paper. Your 10 shares at $100 now trade at $150, so you are up $500, but nothing has happened yet. No sale, no tax event. A realized gain locks in the moment you sell: sell all 10 at $150 and the $500 becomes real, reportable income.
Pyx shows both. The Overview carries an Unrealized G/L chip (market value minus cost basis across your holdings) and a Realized G/L chip (gains locked in by past sells).
What a tax lot is#
Every separate purchase creates a lot: a batch of shares with its own purchase date and its own basis. Buy the same ticker twice and you hold two lots at two prices. This matters the moment you sell part of a position, because the gain depends on which shares you are deemed to have sold.
Set up a concrete position. Two buys, then a partial sale:
| Date | Action | Shares | Price | Lot basis |
|---|---|---|---|---|
| March | Buy | 10 | $100 | $1,000 |
| August | Buy | 10 | $150 | $1,500 |
| November | Sell 5 | at $180 |
Before the sale you hold 20 shares with $2,500 of total basis. You sell 5 shares for $900. What is your gain? It depends entirely on which lot the 5 shares come from.
FIFO vs LIFO vs specific identification#
Three conventions answer "which shares did I sell."
FIFO (first in, first out) consumes the oldest lot first. The 5 shares come from the March lot at $100 each. Basis removed: $500. Realized gain: $900 - $500 = $400.
LIFO (last in, first out) consumes the newest lot first. The 5 shares come from the August lot at $150 each. Basis removed: $750. Realized gain: $900 - $750 = $150.
Specific identification lets you name the exact lot, or split across lots, at sale time. You could realize anywhere between $150 and $400 on this sale depending on the shares you designate.
| Method | Shares sold from | Realized gain | Basis remaining |
|---|---|---|---|
| FIFO | March lot | $400 | $2,000 |
| LIFO | August lot | $150 | $1,750 |
| Specific ID | Your choice | $150 to $400 | $1,750 to $2,000 |
Notice the conservation law. LIFO reports a smaller gain today but leaves less basis behind, so future sales carry a larger gain. No method creates or destroys gain. They only move it across time, which is exactly why the choice matters for tax planning.
Lots carry dates as well as prices, and the date sets the holding period. In the US, shares held longer than one year generally qualify for long-term capital gains treatment, while shorter holds are taxed as short-term. In the example, the March lot crosses the one-year line months before the August lot does, so the choice of lot can change not just the size of the gain but the rate applied to it.
How Pyx computes average cost#
The basis figure in the main Holdings table uses average-cost accounting, reconstructed from your full transaction history. Buys add their amount to basis. Sells reduce basis proportionally to the fraction of shares sold:
Sell 5 of 20 shares and basis drops by exactly one quarter, whatever prices the individual lots carried. Splits scale the share count and leave total basis unchanged, so per-share basis divides by the split ratio. Fees are excluded from basis. When Pyx's reconstruction from the ledger disagrees with what your broker reports, the broker-reported basis is displayed, since the broker's records are what your tax forms will reference.
How Pyx tracks lots#
Alongside the average, Pyx builds true per-lot detail: one lot per acquisition, consumed by sells according to the method you pick. Open the drill-down drawer on any holding on the Holdings page and the Lots table shows each open lot with its acquisition date, remaining shares, basis, and unrealized gain or loss at the current price. A toggle switches the lot math between FIFO, LIFO, and Spec-ID so you can see how each convention would carve up the same history.
Two edge behaviors worth knowing. Selling more shares than the ledger holds simply empties the open lots; Pyx does not model short positions. And reinvested dividends arrive as ordinary buys, so each reinvestment creates its own small lot, which is correct and also why decades-old dividend reinvestment plans produce dozens of lots.
What Pyx does not do#
Pyx shows you the lot math. It does not produce tax reports, generate a Form 8949, or tell your broker which lots to sell. The method your broker applies at sale time, recorded on your 1099-B, is what the IRS sees. Use the drawer to understand your position and plan, then confirm the actual disposal method with your broker before selling, and confirm tax treatment with a professional.