How Many Ways Can You Harvest Taxes From 10 Holdings?
Let's start with simple math.
You own 10 stocks. Some have gains, some have losses.
You could harvest by selling:
- No stocks
- Stock 1 only
- Stock 2 only
- Stock 1 + Stock 2
- Stock 1 + Stock 2 + Stock 3
- ... (all other combinations)
How many different combinations are there?
Answer: 2^10 = 1,024 combinations.
Now scale up:
- 15 holdings = 2^15 = 32,768 combinations
- 20 holdings = 2^20 = 1,048,576 combinations (over 1 million)
- 30 holdings = 2^30 = 1 billion combinations
- 40 holdings = 2^40 = 1 trillion combinations
If you had a spreadsheet that evaluated 1,000 combinations per second (which is unrealistically fast), evaluating 1 trillion combinations would take you:
1,000,000,000,000 ÷ 1,000 ÷ 60 ÷ 60 ÷ 24 ÷ 365 = 31,688 years
That's not a metaphor. It's literally impossible for a human to manually evaluate all combinations for a 40-stock portfolio.
What You Actually Do (The Heuristic Approach)
So what do real DIY investors do with 20+ holdings?
They use a heuristic (a shortcut). Something like:
- 'I'll look at my top 10 biggest losses'
- 'I'll pick the biggest 3 losses'
- 'I'll harvest those and call it done'
This is fast. You can do it in 30 minutes with a spreadsheet.
But it's not optimal. In fact, your best three biggest losses might not be the best three to harvest.
Here's why:
Example: You have 25 holdings. Your 3 biggest losses are in Stock A (-₹50k), Stock B (-₹40k), and Stock C (-₹35k).
You harvest all three. Total loss: ₹125,000.
But what if the optimal combination was actually Stock A (-₹50k) + Stock D (-₹22k) + Stock E (-₹18k) + Stock F (-₹15k) + Stock G (-₹12k)?
Total loss: ₹117,000 (less overall loss, but better tax outcome due to holding periods and interaction with gains)
You'll never find this combination manually. It's not in your 'top 3 losses.' But an optimizer would evaluate it and might find it's better than your 'obvious' choice.
The Cost of the Heuristic
When you use a heuristic (pick the biggest losses), you're probably finding 60-75% of the optimal tax harvesting opportunity.
That means you're missing 25-40% of the available tax savings.
For a portfolio with ₹50,000 in annual harvesting opportunity, missing 30% means leaving ₹15,000 on the table.
For a portfolio with ₹100,000 in annual opportunity, you're missing ₹30,000-₹40,000.
Over 20 years of investing, this compounds to ₹300,000+ in lost tax-optimized returns.
Now, you might say: 'But I'm in the top 5% of DIY investors. I probably catch 85% of opportunities.'
Maybe. But you're still leaving 15% on the table. That's still ₹7,500-₹15,000 per year for most portfolios.
Why Algorithms Don't Have This Problem
An algorithm doesn't suffer from combinatorial complexity. It's designed to handle it.
A good tax harvesting optimizer uses techniques like:
- Dynamic programming to avoid evaluating all combinations
- Branch and bound to prune impossible combinations early
- Greedy selection with lookahead to find high-value combinations fast
- Heuristic ranking to prioritize promising combinations
The result: evaluate millions of combinations in seconds. Find the true optimum (or very close to it) without needing 31,688 years.
The optimizer sees your 40-stock portfolio and says: 'I can analyze this completely in 2 seconds.'
You look at the same portfolio and say: 'I'll pick the 5 biggest losses and call it done.'
The optimizer finds ₹50,000 in tax savings. You find ₹32,000. Difference: ₹18,000 that the algorithm sees and you don't.
This Scales With Portfolio Size
The bigger your portfolio, the worse this problem gets.
- 10 holdings: Combinatorial complexity is manageable manually. You catch 80-90% of opportunities.
- 20 holdings: Manual approaches start to strain. You catch 70-80%.
- 30 holdings: Nearly impossible manually. You catch 50-65%.
- 40+ holdings: Completely intractable. You catch 40-60%.
If you're a serious investor with a large portfolio, your missing optimization is not 5% or 10%. It's 30-50%.
That's serious money.
See How Complex Your Portfolio Actually Is
Upload your tradebook to TaxHarvestLab. The optimizer will evaluate all combinations for your specific portfolio and show you:
- Total tax harvesting opportunity for your holdings
- Recommended harvest plan (which stocks to sell for maximum savings)
- Tax savings breakdown (how much you save overall)
- How many combinations were evaluated (to show the complexity it solved)
You'll see exactly how much complexity your portfolio has and why manual optimization was missing it.
See your portfolio analysis: taxharvestlab.com/optimize
See how this applies to your portfolio
Upload your Zerodha or Groww reports and get personalized recommendations in under 2 minutes.
Analyze My Portfolio FreeFrequently Asked Questions
How many combinations exist for a 40-stock portfolio?
2^40 = 1,099,511,627,776 combinations (over 1 trillion). This represents every possible subset of stocks you could sell. Manually evaluating even a small fraction of these is impossible. An algorithm evaluates millions of combinations in seconds.
Why is 'biggest loss first' not always the best strategy?
Because optimal tax harvesting depends on how each loss interacts with your realized gains, holding periods, and exemptions. A combination of medium losses might result in higher total tax savings than harvesting the single biggest loss. This requires evaluating multiple combinations, which is why algorithms outperform manual methods.
How much money do I typically miss with manual tax harvesting?
For a 20-30 stock portfolio, you're likely missing 20-40% of available tax savings. For a 40+ stock portfolio, you might miss 40-50%. This translates to ₹10,000-₹50,000 per year depending on portfolio size, and compounds to hundreds of thousands over a decade.
Do I really need an algorithm for a small 10-15 stock portfolio?
For small portfolios, manual methods work reasonably well—you'll likely catch 70-85% of opportunities. However, as your portfolio grows beyond 15-20 stocks, the combinatorial explosion makes manual optimization increasingly unreliable and time-consuming.
What algorithm techniques allow optimization of large portfolios?
Effective tax optimization algorithms use dynamic programming (to avoid redundant calculations), branch-and-bound (to eliminate impossible combinations early), and heuristic ranking (to prioritize high-value combinations). These techniques reduce the problem from evaluating trillions of combinations to millions.