Your portfolio started 2025 at 60/40 stocks to bonds. By December, market gains pushed it to 72/28. You're taking more risk than you intended, and you're not alone — this drift happens to every portfolio over time.
Most investors wait for quarterly statements to discover this. By then, they're looking at stale data and making decisions based on yesterday's numbers. This post builds a continuous portfolio analysis system that tracks allocation drift as it happens, stress-tests rebalancing strategies, and calculates the tax implications before you make a move.
The year-end portfolio challenge
December is portfolio decision season:
- Tax considerations: Realizing gains or losses before year-end.
- Rebalancing needs: Asset allocation has drifted over the year.
- Risk assessment: Is your portfolio positioned correctly for your goals?
- Performance review: Which investments drove returns? Which dragged?
- Strategy evaluation: Should you adjust your approach for next year?
Traditional tools make this painful — exporting data, manual calculations, static spreadsheets. Let's do better.
Setting up the portfolio data
Your broker's quarterly statement shows you where you ended up. But to understand how you got there — which decisions drove performance, when drift accelerated, where risks emerged — you need the full journey. Let's reconstruct your entire year.
In practice, this data would stream from your broker's API. Here we'll simulate realistic market movements to demonstrate the analysis. The key insight: we're not building a static spreadsheet. We're creating a live system where every calculation updates as new data arrives. Your portfolio's story unfolds in real time.
Deephaven's time_table creates a continuously updating dataset where each row represents a point in time. Watch how update_by with cum_prod transforms daily price movements into year-long performance — the same calculation your broker runs, but happening live as markets move:
Year-end portfolio snapshot
December 31st: Time to see where you stand. This is the moment most investors pull up their quarterly statement and start manually calculating percentages in a spreadsheet.
We'll do it differently. last_by grabs your current position in every holding, then natural_join seamlessly combines your holdings with portfolio totals to calculate allocation percentages — no spreadsheet formulas, no manual key matching, no worrying about indexes. When prices change tomorrow, these numbers update automatically:
Now you know where you are. But how did you get here? Your statement shows final numbers. It doesn't show that your equity positions surged in Q1, pulled back in Q3, then rallied again in December. It doesn't reveal that your bond allocation underperformed consistently, or that commodities provided crucial diversification during the August volatility spike.
Let's trace the path.
Performance attribution for 2025
You made money this year. Great. But which positions drove those returns? Which ones you thought would perform actually delivered? Which diversifiers justified their allocation by cushioning volatility when equity markets wobbled?
These aren't academic questions. They determine what you keep, what you trim, and where you redeploy capital in 2026. Time-aware operations become critical here: ema_tick calculates day-over-day price changes to track P&L, then agg_by groups by asset class to show which categories powered your returns and which dragged. Let's trace every position's contribution:
Risk assessment
Your tech stocks are up 35% this year. Feels great, right? But here's what your quarterly statement won't tell you: that position swung 4% daily during volatile periods, keeping you up at night checking prices. Meanwhile, your boring bond allocation barely moved — and that stability let you sleep through market turmoil.
Returns matter. But so does volatility. Let's measure what you actually experienced, position by position. We're measuring what actually happened to your money over the last twelve months:
Those volatility numbers tell a story. Your QQQ position — up big this year — also swung the hardest. That 28% annualized volatility means daily moves that made your portfolio feel like a roller coaster. Compare that to your AGG bond position at 6% volatility: steady, predictable, boring. Both have their place. The question is: do you have the right balance?
Target allocation and rebalancing needs
You set your target allocation a year ago: 50% US equity, 30% fixed income, 10% international, 5% real estate, 5% commodities. A balanced, diversified approach.
Then markets happened. Equities rallied, bonds lagged, and suddenly you're 62% equities. You're taking more risk than you planned. Time to bring it back to target.
Let's calculate exactly what needs to move. The analysis joins your current position against your target allocation and shows the gap — not in percentage points, but in actual dollars you need to trade:
Now let's visualize where rebalancing is needed:
Current vs target allocation:

This grouped bar chart reveals exactly where your portfolio has drifted: US Equity is overweight (need to sell), Fixed Income is underweight (need to buy), while Real Estate and Commodities are close to target. The visual gap between current and target bars immediately identifies rebalancing priorities.
Backtesting rebalancing strategies
Here's the uncomfortable truth: you could have rebalanced monthly, quarterly, or just once a year. Each approach would have produced different results. Monthly rebalancing would have locked in gains earlier but racked up transaction costs. Annual rebalancing would have let your winners run but exposed you to larger drift.
Which strategy was actually best for 2025? Let's replay the entire year and find out.
We'll simulate three approaches: monthly rebalancing (disciplined but costly), threshold-based rebalancing when drift exceeds 5% (event-driven), and annual rebalancing (minimal trading). Same portfolio, same year, different rules. Watch how they diverge:
Let's visualize how allocation drifted throughout the year:
Allocation drift throughout 2025:

This time-series view shows exactly when rebalancing would have triggered. Notice how US Equity drift gradually increased from January through December (that's the year's strong market at work), crossing the 5% threshold in August. Fixed Income drifted negative as bonds underperformed. The horizontal lines at ±5% mark the threshold-based rebalancing trigger points.
Monthly rebalancing would have triggered twelve times. Threshold-based? Just four. Annual? Once, right now. The question becomes: did those extra trades justify their costs?
Transaction cost analysis
Every trade costs money. Commissions, bid-ask spreads, market impact. Even low-cost index ETFs carry friction. That monthly rebalancing strategy that looked disciplined? It might have cost you thousands in fees.
Let's quantify it:
The numbers are clear: monthly rebalancing cost $300 in fees for $150 of drift control. Threshold-based cost $160 for better drift management. Annual rebalancing costs just $75 but let drift reach 12%.
There's no free lunch. You trade off control against costs.
Tax-efficient rebalancing
You're ready to rebalance. But wait — this is a taxable account. That equity position you're about to trim? It's up 30%, which means selling triggers capital gains tax. At 20%, that's real money.
Meanwhile, your international equity position is down 8%. You could sell it, harvest the loss to offset other gains, then immediately buy a similar (but not identical) fund to maintain your allocation. Same exposure, lower tax bill.
This is where integrated analysis pays off. We already calculated year-to-date performance for every position. Now we layer in tax implications — identifying loss-harvesting opportunities, estimating taxes on gains, and showing you the most tax-efficient path to rebalance:
Now you see the full picture: which positions to sell, where to harvest losses, what to buy, and how to minimize your tax bill while rebalancing. Your accountant will thank you.
2026 positioning strategy
You've analyzed performance, measured risk, calculated drift, modeled strategies, estimated costs, and optimized for taxes. Time to decide: what actually happens on January 2nd?
Here's your personalized action plan — filtered for meaningful drift (>2%), prioritized by severity, and flagged for high-risk positions:
Additional visualizations
To complete the analysis, here are two more useful charts:


Key insights and recommendations
This analysis reveals several actionable insights:
Portfolio health check:
- Review year-end allocation vs targets.
- Identify positions that have drifted significantly.
- Assess overall portfolio risk profile.
Rebalancing strategy:
- Compare costs and benefits of different rebalancing frequencies.
- Monthly rebalancing captures drift early but incurs higher transaction costs.
- Threshold-based rebalancing (5% drift) balances cost and control.
- Annual rebalancing minimizes costs but allows larger drift.
Tax optimization:
- Harvest losses before year-end to offset gains.
- Prioritize rebalancing in tax-advantaged accounts when possible.
- Consider wash sale rules when harvesting losses.
Risk management:
- High-volatility positions may need reduction.
- Ensure diversification across asset classes.
- Monitor correlation during market stress.
2026 positioning:
- Execute prioritized rebalancing trades.
- Set up alerts for future drift beyond thresholds.
- Schedule quarterly reviews to stay on track.
Real-world applications
This year-end analysis framework extends beyond personal portfolios:
Wealth management: Automate client portfolio reviews at scale, generating personalized reports for hundreds of accounts simultaneously.
Institutional investing: Monitor multiple strategies across different mandates, ensuring compliance with investment policy statements.
Robo-advisors: Provide continuous rebalancing with real-time tax optimization, executing trades as opportunities arise.
Family offices: Coordinate rebalancing across multiple family members' accounts, optimizing for household-level tax efficiency.
Pension funds: Track allocation drift across asset classes, generating rebalancing recommendations that consider liquidity constraints.
The Deephaven advantage
Traditional portfolio management tools require:
- Manual data extraction and cleaning.
- Separate systems for performance, risk, and rebalancing analysis.
- Static calculations that become outdated.
- Batch processing that can't respond to market moves.
With Deephaven:
- Live updates: Portfolio metrics refresh as prices change.
- Integrated analysis: Performance, risk, and rebalancing in one system.
- Historical context: Analyze full year of data to inform decisions.
- Scenario testing: Model different strategies and see results instantly.
- Scalability: Analyze one account or thousands with the same code.
Looking ahead to 2026
The new year is the perfect time to reset your portfolio for success. Start by executing your year-end rebalancing with the prioritized plan we built, keeping tax efficiency top of mind. Set up alerts to notify you when drift exceeds your thresholds — no more waiting until next December to discover your allocation wandered off course. Schedule quarterly reviews to stay aligned with your goals, using the same analysis framework to track progress. And as 2026 unfolds, use this year's data to refine your rebalancing approach: did threshold-based rebalancing work better than monthly? Did transaction costs eat into returns? Let the data guide your strategy.
With Deephaven, you have the tools to analyze, optimize, and execute with confidence. Join our Community on Slack to ask questions, share your experience, and connect with other Deephaven users.
Happy New Year, and happy investing!
