1 pointby kroneill5 hours ago1 comment
  • kroneill4 hours ago
    I quit my Big Fintech job recently and wanted to start things off right by shipping my first open-source project.

    Whenever I do Bogleheads-style investment rebalancing across multiple accounts (brokerage, IRA, 401K, HSA) I got tired of fiddling with a manual spreadsheets, so I built a tool to automate the task. There is maybe a paid product out there that does this but I couldn’t find a DIY solver that met all my needs.

    To keep it a “pure calculator” and protect privacy, it runs entirely in TypeScript on the client side, with no backend. Users can save or load JSON scenario files locally.

    The logic to compute trades was more complex than I expected. I wanted to enable the most generic scenarios (e.g. expressing limited fund options in 401Ks; supporting blended funds like VT or target date funds; allowing user-specified fund preferences within accounts) but a naive greedy algorithms can’t always find a possible solution. This isn't surprising since my old spreadsheet workflow sometimes led to dead ends where I’d have to backtrack try different fund placement choices before it all worked.

    To solve this, the engine models the rebalance scenario as a linear program and uses YALPS (https://github.com/IanManske/YALPS), a TypeScript LP solver. Specifically the rebalance is modeled as a transportation problem with lexicographic optimization of prioritized objectives. The solver code is pure TypeScript with a thin CLI wrapper, and the web UI defers all the “money logic” to the solver.

    I’ve had to resort to linear programming or min-cost flow a few times in my career when greedy algorithms didn’t work, in quite different settings (e.g. computing data layout in a distributed block storage system). It's great for computing a minimal “delta” to get to desired end state without having to code tricky backtracking logic yourself.

    This tool is free, open-source, and requires no signup or registration to use.

    GitHub: https://github.com/rebalancetool/rebalancetool

    I’d love to hear feedback on the UX, linear programming approach, or any edge-case bugs.