Cost basis and holding period for a sale, by FIFO, specific identification or average cost
One command in the Portfolio pack, available in the CLI, as an MCP tool and as a JavaScript import: portfolio cost-basis.
What it needs, and why
Every input is checked before anything is calculated. lots and sale are required; the rest refine the answer.
| Input | Required | The question it asks | Why it matters |
|---|---|---|---|
lots | yes | Which lots are held: quantity, price paid and purchase date for each? | Basis and holding period come from the lots actually sold. |
sale | yes | How many shares are being sold, on what date, and at what price? | The sale date sets each lot’s holding period. |
method | optional | Which method applies: FIFO, specific identification, or average cost? | It changes both the basis and the short/long-term split. |
Requests it answers
- “what is the basis on this sale”
- “which lots should we sell”
- “is this gain short or long term”
An agent with this pack loaded picks the command from phrasing like that, asks for whatever input is missing, and reports the figures with the method that produced them.
Limits it inherits from wealth-portfolio
- Tax-loss harvesting checks only purchases in the 30 days *before* the sale, across the lots supplied. Confirm separately that nothing substantially identical is bought in the 30 days after, including in IRA and spouse accounts. Replacement candidates track a different index, but whether a fund is "substantially identical" is a judgment for the advisor or tax professional. No replacement is suggested for total-bond funds.
- Backtests use approximate embedded annual returns and capture drawdowns at year-end only.
- Forward-simulation regime assumptions are illustrative, not forecasts; pass your firm's capital market assumptions for client work.
- VaR is parametric normal and only as good as the volatility you supply.
The full pack, its other 10 commands and what it deliberately leaves alone are on the Portfolio page.