Donating cash to a qualified charity gives the donor a deduction equal to the cash amount. Donating long-term appreciated stock gives the donor a deduction equal to the stock's fair market value, and avoids the capital-gains tax on the embedded appreciation. The arithmetic almost always favours the stock — but only if the donor picks the right lots. The charitable-giving optimizer does that selection: which lots leave the portfolio without realising the gain, subject to a cap on how off-track the residual portfolio drifts.
Maximise embedded-gain donated, subject to TE preservation
max Σ_i embedded_gain_i · donate_i
donate
s.t. Σ_i fmv_i · donate_i = G (gift target met)
0 ≤ donate_i ≤ shares_i (per-lot ceiling)
TE(w_after) ≤ TE_max (TE preservation)
AGI cap on FMV deduction (optional, deferred)The arithmetic, in one box
The charity is indifferent between cash and stock — either way they liquidate. The donor is not. The "give stock" path delivers the same deduction as a $250k cash gift while keeping the $43,860 of would-be capital-gains tax in the donor's pocket. The optimizer's job is to maximise that delta — equivalent to maximising the embedded gain in the donated lot list.
Donating appreciated stock is the rare structure where the donor's tax-saving and the charity's economics align with the same trade.
Concentrated donations skew the residual portfolio
The lots with the largest embedded gain are usually the names that compounded the most — which means they're often the biggest positions in the residual portfolio. Donating them away without replacement leaves the residual book under-weighted in those names relative to the benchmark, which widens TE. The TE-preservation constraint limits that drift. If TE_max is loose, donations cluster in the deepest-appreciated names; tight, and they spread across the portfolio.
$10M direct-indexing account, $250k gift, 50 bp TE cap
| Lots flagged for donation | 9 (out of 612) |
| Total gift FMV | $251,200 |
| Embedded gain in those lots | $184,300 |
| Capital-gains tax avoided · @ 23.8% | $43,860 |
| Tax avoided per dollar gifted | ≈ 17 ¢ |
| Post-gift TE vs benchmark | 31 bp |
When the deduction phases in over years
Long-term appreciated stock donated to a public charity is deductible at FMV up to 30% of the donor's AGI. Excess deduction carries forward five years. For donors with high net worth and modest income, the AGI cap binds — and the optimizer can be told to size the gift to the cap rather than to a dollar target. Pass {agi_cap: 0.30, agi: $X} and the constraint becomes Σ FMV · donate ≤ 0.30 × AGI.
The vehicle question
The tool returns a list of lots and shares. It doesn't pick the receiving vehicle — direct charity transfer, donor-advised fund (DAF), private foundation. Each has different tax consequences (DAFs preserve the donor's flexibility on which charity ultimately receives; private foundations have stricter AGI limits on appreciated-stock donations). That's a conversation for the donor's adviser, downstream of the optimizer's output.
What's not in scope
- Short-term lots are excluded by default. Short-term appreciated stock is deductible only at basis, not FMV. The optimizer filters them out unless the holder explicitly opts them in (rare).
- Bunching strategies. Donors who alternate "give heavily one year, take the standard deduction the next" benefit from a multi-year version of this optimizer; that's a planning conversation, not a one-shot output.
- State deduction asymmetries. Some states cap or disallow charitable deductions; the federal-equivalent number the optimizer surfaces overstates the after-state benefit in those states.
For the related concentrated-position tool, see the options overlay deep-dive. For the year-end harvest tool, see year-end loss harvest maximiser.
- IRC §170 — Charitable contribution deduction. The 30% AGI cap on long-term appreciated stock to public charities is in §170(b)(1)(C).
- Stein (1998). Diversification of Concentrated Holdings. JWM 1(2). The charitable channel is one of the canonical 'release without realisation' techniques.
Educational illustration · numbers illustrative. Not investment, tax, or legal advice.