Rebalancing your portfolio requires buying and selling shares. In most countries that will attract capital gains taxes, often affected by when you bought those shares.
If you care about tax efficiency -- which can severely deplete your on-paper returns -- then it's not really ~5 lines of code at all.
If you're looking for dumb-and-good-enough, delegating the fiddly rebalancing problem to someone with economies of scale isn't really so bad.