One rebalancing engine powers three markets: how Balance app avoids code sprawl
A solo developer building Balance, a portfolio rebalancing app, has detailed how a single engine handles Brazilian (B3), US, and crypto markets without duplicating core logic. The app originally launched for Brazil only, later expanding to US stocks and cryptocurrency, each differing in price sources, currency symbols, tax rules, and quantity precision. Rather than building separate systems, the developer centralised all market-specific branching into a single 'market' field on the Portfolio model, keeping the rebalancing mathematics, category targets, and contribution flows identical across all three. Price fetching, asset forms, and display formatting adapt per market, but the pipeline itself remains unaware of the source. A key lesson highlighted was storing all quantities and prices at eight decimal places to safely handle crypto fractions, while display logic formats output narrowly based on asset type.
This is an AI-generated summary. ShortSingh links to the original source for the complete article.
Discussion (0)
Log in to join the discussion and vote.
Log in