Charitable-Giving Optimizer
Picks the appreciated lots to give so that a gift of stock avoids the most capital-gains tax.
Estimated tax saved by giving $250,000 of appreciated stock from a $1.46M sample portfolio.
Precomputed on the sample portfolio as of May 15, 2026.
See it on a sample portfolio
Pick a sample portfolio and a preset to see what the tool returns. Every number comes from the tool's own code, run offline ahead of time; nothing is calculated in your browser. Sort the table, or download it as a CSV file to check the figures yourself.
A long-held, diversified 15-name large-cap book worth about $1.46M, carrying roughly $916k of unrealised long-term gain and no lots at a loss. 15 lots · $1,455,101 portfolio value
- Gift amount
- $250,000
Not modelled in this demo yet: Tracking-error cap after the gift and AGI deduction limit. The tool accepts them, but they change no number below.
Giving $250,000 of stock from 2 lots keeps $216,166 of long-term gain from being taxed at 20%.
| Tax saved, as a bar | ||||||
|---|---|---|---|---|---|---|
| 1 | NVDA | 600 | $82,920 | $79,680 | $15,936 | |
| 2 | AAPL | 719.86 | $167,080 | $136,486 | $27,297 |
Order is the order the tool picked the lots: most gain per dollar first. Select a column heading to sort; each bar compares a lot's tax saved with the largest.
The same sample portfolio under each preset.
| Preset | Gift amount | Given | Lots | Tax saved | Gift amount reached |
|---|---|---|---|---|---|
| $100k gift | $100,000 | $100,000 | 2 | $18,726 | In full |
| $250k giftShown | $250,000 | $250,000 | 2 | $43,233 | In full |
| $1M gift | $1,000,000 | $1,000,000 | 9 | $145,991 | In full |
- The residual tracking-error cap is accepted but not enforced in this demo. Enforcing it needs a covariance matrix (how the stocks move together), which the sample portfolio does not carry.
Precomputed offline by the tool's Python code for these sample portfolios and presets. Nothing is calculated in your browser.
Giving appreciated stock instead of cash means the gain in those shares is never taxed. The more gain each dollar of stock carries, the more tax the gift avoids, so which lots you give matters.
maximize Σᵢ gainᵢ × xᵢ gain kept out of tax
subject to Σᵢ valueᵢ × xᵢ = G the gift amount (or every eligible lot, if less)
0 ≤ xᵢ ≤ 1 share of lot i given
lot i held more than a year, at a gain
solved exactly: rank lots by gain ÷ cost, give them in that order,
and split only the last one
tax saved = Σᵢ gainᵢ × xᵢ × 20%Ranking lots by gain as a share of cost puts first the lots that carry the most gain per dollar of value, so each dollar of the gift keeps as much gain out of tax as possible. The tool does not model the income-tax deduction for the gift itself, the yearly limit on that deduction, or how the gift moves the remaining portfolio away from its benchmark.
No solver is involved. The tool sorts the lots and works down the list. The tax each gift avoids is priced with LotWise's US tax engine at 20%, the top federal income-tax rate on long-term gains; only long-term lots are given. The demo leaves out the 3.8% net investment income tax, which also applies to investors in the top brackets, so every tax figure here is lower than it would be with that tax included. The tool runs offline, ahead of time, on the sample portfolios; this page shows the saved results.
- Lots with cost and purchase date
The tool considers only lots held more than a year and priced above their cost. Short-term lots can be given too, but their deduction is generally limited to cost basis, so the tool leaves them out.
- Gift amount
The dollar value of stock to give.
- Tracking-error cap after the gift
Accepted but not applied in this demo yet.
- AGI deduction limit
Accepted but not applied in this demo yet.
- Donation list
Stock, shares, value, gain avoided and tax saved for each lot, in the order the tool picked them.
- Tax saved
The gain kept out of tax, at the 20% long-term rate.
- Shortfall warning
When the eligible lots are worth less than the gift amount, the tool gives them all and says by how much it fell short.
- Why give stock, not cash
- Selling stock to give cash realizes the gain and the tax on it. Giving the shares directly to a qualified charity or a donor-advised fund skips the sale, so the gain is never taxed.
- Why the ranking works
- For a fixed gift, the tax avoided is largest when each dollar given carries as much gain as possible. Ranking by gain as a share of cost gives the same order as gain per dollar of value, and filling the gift in that order, splitting only the last lot, gives the largest total.
- What it does not model yet
- The deduction for the gift; the yearly limit on that deduction, a share of adjusted gross income with the excess carried forward up to five years; and the effect on tracking error. The last two have inputs on this page that are accepted but change nothing yet.
Gift amount
The dollar value of stock to give. The tool picks the lots that make up that amount.
Here vᵢ is the market value of lot i, xᵢ the share of it given and G this amount. The tool ranks long-term lots with a gain by gain as a share of cost and gives them in that order until the total reaches G, giving part of the last lot. If the eligible lots are worth less than G, it gives them all and warns.
A larger gift avoids more tax in total, but it reaches lots with less gain per dollar, so each extra dollar given avoids less tax.
A quarter-by-quarter selling schedule that trims an overweight portfolio inside a yearly budget for realized gains.
Finds every lot you can sell at a loss without realizing a gain, holding back a lot when other shares of the same stock were bought in the last 30 days.
The results on this page were computed ahead of time by the tool's Python code, on sample portfolios and a few preset inputs, and saved with the site. Output is illustrative and is not investment or tax advice.