The core math
For each holding the calculator computes target value = total portfolio value x target percentage, then subtracts the current value. A positive result is a buy order, a negative result a sell order, and a zero means the holding is already on target. Because the total is fixed, the sum of all buy amounts equals the sum of all sell amounts.