Rebalance a Model Portfolio Using Whole-Share Trades
Last updated: November 29, 2026
Quick Overview
Given current share holdings, cash, prices and target weights, compute the whole-share buy and sell quantities that bring the portfolio as close to target as possible without spending more cash than the portfolio has.
BlackRock
November 29, 20260
0
0 solved
Given current share holdings, cash, prices and target weights, compute the whole-share buy and sell quantities that bring the portfolio as close to target as possible without spending more cash than the portfolio has.
Model-based rebalancing is core to Aladdin Wealth and to the model portfolios BlackRock offers advisors. The interviewer wants to see the candidate reason about rounding to whole shares, a cash constraint, and a sensible greedy rule for leftover cash.
What the Interviewer Expects
- Computes NAV including cash and current holdings
- Floors target shares first so cash is never overspent
- Distributes leftover cash greedily to the most underweight names
- Handles tickers held but absent from the model (sell to zero)
- Explains why greedy is a heuristic and not always optimal
Key Topics to Cover
How to Approach This
- Clarify input constraints and edge cases before writing code.
- Walk through your approach verbally and confirm with the interviewer before coding.
- Start with a brute force solution, then optimize. Mention time and space complexity.
- Test your solution with examples, including edge cases like empty input or duplicates.
- Consider common patterns: sliding window, two pointers, hash map, BFS/DFS, dynamic programming.
Possible Follow-up Questions
- How would you add a minimum trade size so you skip tiny trades?
- How would taxes on realized gains change the objective?
- What if fractional shares are allowed for some accounts?
- How would you rebalance 2 million advisor accounts overnight?
Sharpen Your Skills on Codemia
Practice similar problems with our interactive workspace, get AI feedback, and track your progress.
Practice DSA ProblemsSample Answer
Requirements
Inputs: nav_cash, holdings (ticker to shares), prices, targets (weights summing to at most 1). Output: share deltas, positive to buy and negative to sell, only for tickers that change. Whole s...
High-Level Design
- NAV is cash plus the value of all holdings.
- Ideal shares for each name are
target * NAV / price; floor them, which guarantees we do not overspend. - Leftover cash is spent one share at a time...