Double-click to edit cells. Right-click a row to add or remove assets. Pie charts and target checks are based on groups. Chosen Weight for Buy splits each group's trades across its assets.
Only assets receiving a non-zero allocation are shown. Sorted by purchase size.
A Shiny app that calculates how to allocate new investment funds across a portfolio to bring allocations as close as possible to target weights — without selling any assets .
Based on: J. Bartroff, "Rebalance your portfolio without selling", arXiv:2305.12274. This repository implements the algorithms from that paper; the implementation is original code.
Read the paper for theory and proofs- Input Data Tab: Edit assets, tickers, current values, and target percentages directly in the table. Upload a CSV file with your portfolio data.
- Buy Orders Tab: Review the calculated buy orders with a bar chart and detailed breakdown table.
- CSV Format: Columns: Asset, Ticker, Group (optional), Current_Value, Target_Percent, Chosen Weight for Buy (optional). Target percentages must sum to 100%.
- Groups: Assign assets to groups for aggregated analysis. Within each group, you can specify how new buys are split.
- New Funds: Enter the total amount of new money to invest. The app shows the minimum amount needed to avoid selling.
- Rebalancing Methods: Choose between ℓ₁ (proportional), ℓ₂ (threshold), or full rebalance (with selling) for comparison.
- Analysis Tab: View current and rebalanced allocations with pie charts and detailed tables.
You have a portfolio with current values and target proportions. You want to invest additional funds y to get as close as possible to targets without selling.
The
naive adjustments
that would achieve exact targets (if selling were allowed) are:
δᵢ = pᵢ(x + y) − xᵢ
where
x
is the current total value.
Since some δᵢ may be negative, we use optimal solutions:
- ℓ₂ Solution (Theorem 1): Minimizes sum of squared deviations. Funds go to the top k* underweight assets. Best for closing biggest gaps first.
- ℓ₁ Solution (Theorem 2): Minimizes sum of absolute deviations. Funds spread proportionally to all underweight assets.
These closed-form solutions are mathematically proven optimal, fast, and deterministic — unlike heuristic optimizers.