Capital Gains and Loss Harvesting Basics with AI

Tax-loss harvesting sounds like an advanced investor move, but the underlying idea is simple: if an investment is down, selling it can generate a loss you're allowed to use against gains elsewhere, lowering what you owe. AI is a useful tool for scanning a portfolio and surfacing candidates—it is not a substitute for investment judgment, and this article is general education, not a recommendation to buy or sell anything.
The basic mechanics, explained simply
- A capital gain happens when you sell an investment for more than you paid.
- A capital loss happens when you sell for less than you paid.
- Losses can offset gains dollar for dollar in the same tax year, and a limited amount of any leftover loss can typically offset ordinary income, with additional losses carried forward to future years.
- Harvesting means intentionally realizing a loss (or sometimes a gain, in different strategic situations) before year-end to manage your tax outcome, rather than waiting for it to happen by accident.
How AI can help scan a portfolio
- Export your holdings from your brokerage, including purchase price (cost basis) and current value for each position.
- Upload the export to AI and ask it to calculate the unrealized gain or loss on each holding.
- Ask for a sorted list, largest loss to largest gain, so you can see at a glance which positions are currently showing a paper loss worth considering.
- Ask AI to total your realized gains so far this year from any sales you've already made, so you know how much loss you'd actually need to offset them.
Checking for wash-sale risk before you act
If you're considering harvesting a loss but want to stay invested in a similar asset, ask AI directly: "If I sell this position and buy [similar investment] within 30 days, would that likely trigger a wash sale?" It can walk through the general rule and flag an obvious conflict, but treat any close call as a reason to check with your brokerage's own tools or a professional rather than proceeding on an AI guess alone.
A simple year-end review prompt sequence
- "Here are my current holdings with cost basis and current value—which show an unrealized loss, and how large is each?"
- "I've realized $X in capital gains so far this year from other sales—how much loss would I need to harvest to fully offset that?"
- "If I sell [position], is there a similar investment I should avoid repurchasing immediately to steer clear of a wash sale?"
- "Roughly how much of any leftover loss could apply against ordinary income this year, and how much would carry forward?"
A worked example
Imagine a portfolio export showing one position down $2,400 from its purchase price and another up $3,100. Earlier in the year, you sold a different holding and realized a $1,800 gain. Ask AI to lay this out: the $2,400 loss, if harvested, would fully offset the $1,800 realized gain with $600 left over, a portion of which could typically apply against ordinary income up to an annual limit, with any remainder carried forward to future years. Seeing the numbers lined up this way—gain, available loss, offset, leftover—turns an abstract strategy into a concrete decision you can evaluate, even though whether to actually execute it remains yours to make.
Long-term versus short-term treatment matters
Ask AI to separate your holdings by how long you've owned each position, since investments held longer than a set period are typically taxed differently than ones held for a shorter window, and losses and gains of each type generally offset within their own category first. A large short-term gain paired with a long-term loss doesn't necessarily net cleanly—ask AI to walk through the ordering rules in plain language for your specific mix of holding periods, then verify the specifics against your brokerage's own reporting or a tax professional, since the interaction between the two categories can get genuinely intricate.
Year-end timing considerations
Harvesting is typically a before-December-31 decision for the current tax year, which means the review is worth doing earlier than the last week of the year, in case a wash-sale window would otherwise get cut short by the calendar. Ask AI to flag, for any position you're considering harvesting, whether a 30-day wash-sale window on either side would still cleanly fit before or after year-end given today's date—this kind of date arithmetic is simple for AI and easy to miscount by hand when you're juggling several positions at once.
Where this stops being a simple calculation
Harvesting decisions interact with your overall investment strategy—selling a long-term holding to capture a short-term tax benefit can undo years of a buy-and-hold approach, trigger different long-term versus short-term tax treatment, or shift your portfolio's risk profile in ways AI can't evaluate for you. Use AI to identify and quantify candidates; use your own judgment, or a financial advisor's, to decide whether acting on any of them fits your actual goals. For related tax-planning pieces, see our taxes hub and our guide on maximizing retirement contributions with AI.
Bottom line
AI is well suited to the arithmetic side of gains and loss harvesting—scanning a portfolio, sorting by unrealized gain or loss, and flagging wash-sale risk—but the decision to actually sell something is an investment decision, not just a tax calculation. This is general information, not personalized investment or tax advice; confirm any harvesting move with a licensed financial or tax professional and current IRS rules before acting. More in topics.
FAQ
What is tax-loss harvesting, in plain terms?
It's selling an investment that's currently worth less than you paid for it, realizing that loss on paper, and using it to offset capital gains (or a limited amount of ordinary income) on your tax return. The core idea is turning a paper loss into a real tax benefit without necessarily changing your overall investment strategy, since you can typically reinvest the proceeds elsewhere.
Can AI tell me which specific investments to sell for tax purposes?
AI can scan a portfolio export and flag which positions currently show a loss or gain and roughly by how much, which is useful information. It should not be treated as personalized investment advice about which specific trade to make—that decision depends on your broader strategy, goals, and risk tolerance, which is outside what a general AI tool can safely judge.
What is the wash-sale rule and can AI help me avoid it?
The wash-sale rule generally disallows a tax loss if you buy a substantially identical investment within a set window before or after the sale. AI can help you check whether a planned repurchase falls inside that window and flag the risk, but the specifics of what counts as 'substantially identical' can be nuanced enough to warrant a professional check on anything borderline.