Rebalance stock holdings with new cash contributions
New cash can help a stock portfolio approach its target without selling an overweight holding, but a small contribution may leave substantial drift. Compare a contribution-only buying policy with a full funded rebalance over the same cash-arrival schedule. Preserve the reduced selling and the remaining overweight together rather than calling one route automatically better.
This guide builds two synthetic account paths with equal deposits, prices and costs. It is an external research method, not verified cash-flow support or order routing in CoTrading. Use one market and currency. The example measures cash, quantities and profit amounts; it does not repeat time-weighted or money-weighted return calculations.
Freeze what arrives and when
Record each contribution’s currency, amount and effective availability time. Money promised for a later date cannot finance an earlier order. Separate pending transfers from usable cash and external capital from dividends, stock sales or internal account movements.
Both policies begin with eight A shares and two B shares at 100, cash zero and portfolio value 1000. The target is half in each stock. A deposit of 100 becomes available at each of two modeled boundaries, before that boundary’s allocation decision. Both therefore receive exactly 200 of new external capital.
The Investor.gov rebalancing guide discusses directing contributions toward underweighted assets. Our stock-level allocation and numbers are original examples, not a recommendation that new-cash buying can always restore a target or eliminate transaction costs.
Define the two policies precisely
The new-cash policy spends available cash on positive target-value gaps only, allocating across those gaps proportionally and reserving its purchase fee. It never sells existing shares in this fixture. If no eligible gap exists, cash remains cash instead of being assigned to an overweight asset merely to make the account appear fully invested.
The full policy can sell overweight shares and buy underweights, subject to the same available capital. It solves for an equal-weight post-fee portfolio using both purchases and sales. Any minimum holding, lot or restricted-sale rule would need an explicit addition; this example allows fractional shares and has no tax model.
Keep a target, requested allocation, actual quantity and residual cash record for both routes. Avoid silently renormalizing the securities after trades, because that would conceal cash and imply the target was reached when it was not.
Reserve costs before spending contributions
Charge an invented 0.001 of executed value. The new-cash route can invest cash/1.001, since purchasing the full cash amount would leave nothing to pay its fee. For a full rebalance, fees depend on changes from old security values, so the program solves invested wealth and fees together.
gap[s] = max(0, funded_nav * target_weight[s] - current_value[s])
investable = available_cash / (1 + fee_rate)
buy_value[s] = investable * gap[s] / sum(gap.values())
That sketch applies only when positive gaps exist. The complete script handles the zero-gap branch and asserts nonnegative cash and the equity-minus-fee identity at each boundary. It does not assume every real market allows fractional or immediate fills at the displayed price.
Costs in this example are a proportional research assumption, not a complete broker schedule. Actual minimum commissions, taxes, spreads and blocked orders can alter both allocation and feasibility. A real implementation must execute them in the state path rather than subtract an estimated amount after all quantities are chosen.
Work through the first contribution
Before the first deposit, A is worth 800 and B 200. Adding 100 makes funded value 1100, so pre-fee targets are 550 each. A remains overweight; B has a positive gap of 350. The new-cash policy uses its 100 to buy approximately 99.900100 of B after reserving its fee.
A still has eight shares and value 800, while B is worth approximately 299.900100. The resulting A weight is approximately 0.727339. New capital helped, but did not reach equal weight. The uncorrected overweight must remain visible in the comparison.
The full route sells 250.3 of A and buys 349.7 of B. Two-sided traded value is 600 and fee 0.6, leaving assets 1099.4, or 549.7 in each stock. This funded operation achieves the declared half-and-half target under the fixture’s assumptions.
Apply the second deposit to each actual account
At the next boundary A’s price is 120 and B remains 100. Mark each route’s own quantities before receiving the second 100. The new-cash route still owns eight A shares, so its A price gain is 160. The full route owns 5.497 A shares after its first rebalance, so its gain is 109.94.
Only then add the new deposit and form the next allocation. Do not use the original account’s holdings for both routes, since their first actions deliberately changed exposure. Also do not count the 100 deposit as a market gain simply because ending equity increases.
| Result after both contributions | New-cash buying | Full rebalance |
|---|---|---|
| External capital added | 200 | 200 |
| Ending value | 1359.800200 | 1309.230060 |
| Profit excluding contributions | 159.800200 | 109.230060 |
| Total transaction cost | 0.199800 | 0.709940 |
| Sold value | 0 | 255.324970 |
| Final A weight | 0.705986 | 0.500000 |
The higher ending value on the new-cash path mainly reflects retained A exposure during an invented price increase, not merely lower fees. It is a different risk path. Do not attribute the entire profit gap to a cheaper implementation of an identical target portfolio.
Reconcile amounts without disguising flows as returns
For each route, opening 1000 plus contributions 200 plus market gains minus fees must equal ending value. The script asserts this bridge independently of the target calculation. It also checks the precise ending and cost anchors within an absolute tolerance of 1e-6.
No investor-return percentage is reported here. The amount bridge answers whether capital and performance were accounted for consistently. If percentage performance is required, use a separately declared cash-flow-adjusted method with actual timing rather than dividing profit by whichever balance produces a preferred result.
Report still-unresolved deviations and cash alongside selling reductions. A policy that avoids sales may be useful operationally while failing a strict concentration limit. That is a constraint decision, not a detail that can be omitted because net profit happened to be higher.
Handle contributions that cannot solve the imbalance
The counterexample is the small cash amount itself: both contributions are fully available, yet the buy-only route ends with A above seventy percent. Repeatedly buying underweights does not guarantee convergence within a short horizon when prices keep moving or contributions are small relative to the existing account.
An unreceived, negative or nonfinite contribution must not enter the usable-cash calculation. This guide models positive new cash only; withdrawals require a separate funding policy. Keep a failed allocation or blocked purchase as its actual state, preserving cash rather than inventing a fill.
If the target changes between deposits, version that target and explain the intervention. If a real share unit prevents using all available cash, carry the remainder and show achieved weights. Neither situation is handled by silently scaling the stock weights back to one.
Execute and accept the comparison
Download the complete example. Use Python 3.12 or later and run python R630.py. Standard-library assertions verify equal deposits, funded fees, amount bridges, precise ending values, zero sales for new-cash buying and persistent overweight versus equal weight under full rebalancing.
Archive arrival records, both initial states, targets, allocations, quantities, fees, sales and residual cash. A reviewer should reconstruct each boundary using only information and money available then. Preserve every unfilled event if the method is extended to an execution engine.
Keep the pre-deposit valuation timestamp beside each arrival record.
Recompute when contribution timing, amount, target, price, fees or trading restrictions change. The example validates synthetic cash-flow-assisted allocation, not a real account result, a tax recommendation or an already implemented product deposit/backtest workflow.
FAQ
Does directing deposits to underweights guarantee the target?
No. The available amount may be too small, and continuing price changes can preserve the overweight.
Is the extra 200 part of investment profit?
No. It is external capital and is kept separate in the amount reconciliation.