Should I sell stocks to buy a house in cash or get a mortgage?

Trying to decide between two paths and the tax side is tripping me up. I have a decent brokerage account — mix of long-term positions and a few shorter ones — and I'm under contract on a house. I could liquidate enough to buy it outright, but that would trigger a big capital gains bill this year. The alternative is to get a mortgage and leave the portfolio alone, but rates aren't exactly friendly right now. I already ran the basic math on after-tax proceeds from selling but I'm not sure I'm doing it right. Some of my lots have held over a year, some under. Does the sell-to-buy-cash route actually make sense once you factor in the capital gains hit, or is there a smarter middle path? Has anyone actually worked through this decision?

40 comments

The tax piece is the first thing to get right before anything else. When you sell, your gain is calculated per lot — each one has its own cost basis and its own holding period. Lots you've held more than one year get long-term treatment; lots held one year or less are short-term. Long-term and short-term gains are taxed at different rates, so the mix of lots you choose to sell matters a lot. You can usually specify which lots to sell through your broker, so it's worth running the numbers lot by lot before you decide anything.

Raj F.

Author

This is what I was missing — I was thinking of the portfolio as one lump. So if I cherry-pick only my long-term lots, the tax hit could be meaningfully lower than if I just liquidate everything proportionally?

Exactly. And if any of your long-term lots are sitting at a loss, selling those at the same time can offset some of the gains. That's the standard approach — harvest the losses to reduce net gain on Schedule D.

There's also the question of what happens to the capital gains on your Schedule D in the year you sell. Net short-term gains go on Schedule D and flow to Form 1040 as ordinary income. Net long-term gains get their own rate computation. Stacking a big gain on top of your salary can push you into a different bracket for the ordinary income portion. Worth modeling the full picture before closing.

Went through this last year. Ended up doing a split — sold enough long-term lots to cover the down payment for a conventional mortgage instead of the full purchase price. Smaller gain, still got a low loan-to-value rate. Not a perfect solution but the tax bill was way more manageable than if I'd liquidated everything.

Raj F.

Author

This split approach is actually what I keep coming back to. Did you have to do anything special for the lots you chose, like get written confirmation from your broker of which shares were sold?

Yeah, I specified the lots through the broker's website before placing the sell order. Got a confirmation email. Keep that because your 1099-B at year end should match, but it's good to have your own record if the cost basis looks off.

Before I made a similar call last year I ran my actual brokerage statements through Taxr at taxr.ai — it read each lot, calculated the gain or loss per lot, and sorted out which ones were long-term versus short-term. Saved me from accidentally triggering a wash sale by repurchasing something too soon after selling at a loss. The wash sale window is 30 days before and after a sale, and if you're doing any reinvesting while you liquidate, that can quietly disallow a loss. The disallowed amount gets added to the cost of the new shares instead of being deductible this year.

Raj F.

Author

The wash sale angle hadn't even crossed my mind. I do have automatic dividend reinvestment turned on for a couple of positions. That could easily land inside that 30-day window.

Turn off DRIP before you sell those positions. Even a small reinvested dividend in the same security within 30 days can trigger a wash sale on the loss portion. Brokers sometimes catch it, sometimes don't — especially if the repurchase is in a different account.

One more layer: if your capital gains push your AGI high enough, you may also owe the net investment income tax on top of the regular capital gains rate. It applies to investment income when income is above certain thresholds — check the Form 8960 instructions for the current figures. That's a line item people miss when they're just looking at the Schedule D rate.

Good point. That one doesn't show up on Schedule D at all, it's a separate form. Easy to forget when you're modeling the sale.

The mortgage side has its own math too. Mortgage interest is potentially deductible on Schedule A if you itemize, but with the current standard deduction a lot of people don't get to actually deduct it. So the "deductible interest" argument for carrying a mortgage isn't as strong as it used to be for everyone — depends entirely on your other itemized deductions.

Raj F.

Author

Yeah I already checked and I don't think I'd clear the standard deduction threshold even with the mortgage interest added. So that point kind of goes away for me.

Then for your situation the mortgage-interest deduction isn't a real offset. The comparison really comes down to after-tax cost of the gain versus the total interest you'd pay over the life of the loan — a pure financial planning question more than a tax one at that point.

Are any of your stock positions in an employer plan or are they all in a regular taxable brokerage? RSUs or ISOs held in a brokerage after vesting are still just stock at that point, but the cost basis can be weird if the company reported it oddly on your W-2. Worth double-checking your 1099-B cost basis against what actually vested.

Raj F.

Author

All taxable brokerage, nothing from an employer plan. These are just regular purchases over the years so the basis should be straightforward — whatever I paid when I bought them.

Had a similar pile of lots to sort through last spring. I uploaded my 1099-B to Taxr and it walked through each row — flagged two entries where the broker had marked the basis as not reported to the IRS, which meant I needed box B on Form 8949 instead of box A. I would not have caught that on my own. For those rows you enter the correct basis in column (e) and put -0- in column (g), not an adjustment figure.

Box A vs box B is something that bites people. If the basis IS reported to the IRS and it's wrong, you still enter what the 1099-B says in column (e) and then correct it with an adjustment in column (g). The rule flips depending on which box is checked.

Right, that's the distinction. The box determines the method, not just where you put the number. Getting it backwards means column (g) is off and your gain or loss is wrong.

If you're selling long-term lots at a gain and you have any short-term lots at a loss, netting them on Schedule D can reduce what you owe this year. Long-term gains and short-term losses do offset each other — just not at the same rate. The Schedule D instructions walk through the netting order if you want to see exactly how it flows.

Raj F.

Author

I do have a couple of short-term positions that are underwater. So selling those at the same time would actually reduce the net gain from the long-term sales?

Net short-term loss first reduces short-term gains; if there's still a net short-term loss after that, it then offsets long-term gains. Run it through Schedule D and you'll see the order. If total losses still exceed total gains, you can deduct up to the annual cap against other income and carry the rest forward.

Something I keep seeing people overlook: state taxes. If you're in a state that taxes capital gains as ordinary income — which most do — the federal Schedule D picture is only part of the total bill. Some states have their own form for this, some just piggyback on federal AGI. Worth checking your state's treatment before you finalize the decision.

Raj F.

Author

I'm in a state with a flat income tax so this would add a straight percentage on top. Good reminder — I hadn't built that into my estimate.

The carryover angle is worth keeping in mind too. If after all the netting you still have more losses than gains, only a limited amount offsets other income each year — check Topic 409 on irs.gov for the current cap and the carryover rules. The rest carries forward indefinitely. So if you're not in a rush to buy, timing the sale across two tax years might let you spread the gain.

Spreading across two years only works if you can delay closing. Tight contract timelines usually don't allow that. But if someone has flexibility it's genuinely worth modeling.

One scenario nobody's mentioned: a margin loan or pledged-asset line against the brokerage account. Some brokers let you borrow against the portfolio to fund a purchase without selling. No sale means no capital gains event. The risk is a margin call if the portfolio drops, and the interest isn't deductible the same way a qualified mortgage is. Interest follows how the loan proceeds are used, so money borrowed to buy your house is generally nondeductible personal interest, not investment interest on Form 4952. But it's another option if you want to avoid liquidating at all.

This is a real option but the margin call risk on a house purchase is not trivial. If the market drops right after you buy, you could be forced to sell at exactly the wrong time. Worth understanding fully before committing.

Raj F.

Author

I hadn't thought about pledged-asset lines. The margin call risk during what would already be a stressful time makes me nervous but I'll look into how the thresholds work at my broker.

When I was mapping out which lots to keep and which to sell, I loaded my cost basis spreadsheet into Taxr and had it draft a lot-by-lot comparison showing estimated gain, holding period, and which Form 8949 box each lot would use. Made it a lot easier to see the total tax picture before I called my broker. Still had a CPA review the final numbers before I pulled the trigger — something this size warrants it.

CPA check on a large liquidation is the right call. The lot selection, the wash sale tracking, and the state tax interaction are all places where a small mistake has a large dollar consequence.

Raj F.

Author

The lot-by-lot breakdown is exactly what I need. I think that's my next step — build that out and then bring it to a CPA before I make any moves.

To correct something earlier in the thread: someone implied losses above the annual offset cap just disappear. They don't. They carry forward to future years and are applied against gains in those years first, then up to the same annual cap against ordinary income again. The Capital Loss Carryover Worksheet in the Schedule D instructions or Publication 550 is how you calculate the exact amount that carries. Nothing is lost.

Carrying forward — yes. I should have said that more clearly. The cap is per year, not a lifetime limit.

Practically speaking: if you decide to sell, get the settlement dates right. For securities traded on an established market, the holding period ends on the trade date, not the settlement date. So if you're right on the edge of the one-year mark, the trade date is what determines long-term versus short-term — not when the cash actually arrives.

Raj F.

Author

This is the kind of detail that would have tripped me up. So if I need a sale to count as long-term I should check the trade date, not plan around when settlement hits.

Trade date is what goes on Form 8949 column (c) for the date sold. That's the date that determines the holding period. Settlement is irrelevant for that calculation.

Where this thread landed for me: the tax math alone probably doesn't tell you to sell or not sell — it tells you HOW to sell if you decide to. Lot selection, timing, loss harvesting, and state taxes all move the number. The mortgage-vs-cash question then becomes: does the after-tax cost of liquidating beat the total cost of borrowing? That's a financial planning question that sits on top of the tax one.

Raj F.

Author

This framing actually helps a lot. Getting the tax picture right first, then making the buy decision on top of that, is the right order. I'll build out the lot analysis and loop in a CPA before I do anything.