- Jh123x: Blog, Code, Fun and everything in between./
- My Blog Posts and Stories/
- Making the HYSA Calculator suggest the next step/
Making the HYSA Calculator suggest the next step
Table of Contents
I built the SG HYSA Calculator in 2024 to answer 1 question: given my current habits and conditions, which high-yield savings account (HYSA) should I use instead? It compares 17 accounts, with a rate history going back years.
For a long time I used it as a lookup: open it, read the name at the top of the table, close the tab. It tells me who wins today, not what would make tomorrow better.
Then I showed it to a friend during reservist, and he asked: what should he change about his current account to earn more, and what would that change cost him?
The HYSA at that time was unable to point him in the correct direction. This is what led to the discussion of this feature.
The Optimize page #

The page starts from your profile, finds the best account for it, then lists 1 candidate per account: the next requirement that account cares about, the change needed to reach it, and what that change does to your effective interest rate (EIR) and your yearly interest.
- Every row shows the change in plain words, the annual cost, and a net figure.
- If the net is negative the row says so: “costs more than it earns”.
- Explore applies the change and recomputes from there. There is also an option to return to the previous step.
3 different people, 3 different questions #
A table of rates only means something against a profile, so here are 3 fictional ones with different questions. Every number below comes from the live site on 2026-12-01.
John, 25: “What should I aim for next?” #
John has $25,000 saved, earns $3,500 a month, has 3 GIRO arrangements and puts nothing on cards. The page puts his current best at Chocolate Finance: 2.14%, $535 a year. The rows that promise more all want something first:
| Bank | EIR | What it takes | Net per year |
|---|---|---|---|
| BOC SmartSaver | 3.70% | $12,000 a year in insurance premiums | −$11,610 |
| Citi Wealth First | 2.51% | $225,000 more savings, +$1,500/mo salary, +$750/mo spending | −$3,260 |
| Trust Bank Flex | 2.40% | $20,000 invested, referred customer | +$65 |
The highest rate on the page loses him $11,610 a year, and the honest next step is worth $65. That is the answer to his question: not the biggest number, the first one that pays. His profile is reproducible: open John’s Optimize page.
Priya, 32: “Which lever is cheapest?” #
Priya has $100,000 saved, earns $5,000 a month and spends $500 on cards. Her current best is Chocolate Finance at 1.96%, $1,960 a year.
| Bank | EIR | What it takes | Net per year |
|---|---|---|---|
| OCBC 360 | 2.75% | $500/mo more kept in the account | +$790 |
| Citi Wealth First | 2.51% | $150,000 moved in, +$250/mo spending | +$1,315 |
| DBS Multiplier | 2.20% | 1 eligible transaction, here a $9,500/mo loan instalment | +$240 |
OCBC 360 asks for $500 of movement a month and pays $790 a year; Citi pays more but wants $150,000 moved. Same table, very different decisions. The DBS row is the grouped one: 1 requirement she could meet with salary, a loan, spending, insurance or investment, and the numbers recalculate per option. Her profile is reproducible: open Priya’s Optimize page.
Marcus, 40: “Is changing anything worth it?” #
Marcus has $55,000, earns $4,500 a month, puts nothing on cards, and is already on the best account for his profile: 2.01%, $1,105 a year.
| Bank | EIR | What it takes | Net per year |
|---|---|---|---|
| BOC SmartSaver | 3.70% | $12,000 a year in insurance premiums | −$11,070 |
| Citi Wealth First | 2.51% | $195,000 moved in, +$500/mo salary, +$750/mo spending | −$3,830 |
| Trust Bank Flex | 2.40% | $20,000 invested, referred customer | +$215 |
For Marcus the most useful rows are the negative ones: the accounts with the highest rates lose him money once the premiums and spending they require are counted. His only positive row is worth $215, which is the page telling him to change nothing big. His profile is reproducible: open Marcus’s Optimize page.
Graph or table #
The first version of the page was a React Flow graph. Profiles were nodes, edges were the changes required to transition from 1 profile to another.
While it did make the website look very nice, it was very hard for the user to use especially for cases where there are many possible transition points. Every node also had to compute its own candidates, so the cost of the page grew with depth.
After several iterations, we eventually decided to go with the table form, which is what you see on the website today.
The graph went, and the @xyflow/react dependency went with it.
Probing the code instead of copying it #
The obvious way to build this is a table of per-bank thresholds. “UOB One needs $500 of card spend.” “OCBC 360 needs a $500 average daily balance increase.” 17 accounts, each with a handful of conditions, written out by hand.
That table would be a 2nd copy of rules that already exist in src/logic/ocbc360.ts, src/logic/uob.ts and the rest.
2 copies of the same rule drift the moment a bank changes its terms, and the one nobody recalculates is always the stale one.
The calculator already had a rate history and 1 interest function per account, so the optimizer should ask those functions instead.
The probe grid is not handwritten either: a geometric sweep of plausible values, plus every non-negative integer literal found by scanning src/logic/*.ts.
A threshold in the logic but not in the grid would be a missed step, and every threshold here is a numeric literal.
A test regenerates the tables in memory from the current code and asserts the committed JSON matches, byte for byte. When a new rate snapshot lands, the test fails until the tables are regenerated.
Pruning the search space #
While tackling this issue, the initial idea was to brute force all the possible combinations to find the best one.
For each profile that the user keys in, we can keep the ones that improve the rate and sort the results by the interest rates gained.
14 fields can be moved by an action (except age), and the probe lattice has 545 values per field, so the space is 546¹⁴, about 2.1 × 10³⁸ profiles. Even 1 change at a time is 7,630 profiles, and each one needs 17 interest function calls to find the best account: 129,710 calls for a scan nobody would wait for.
| Scope | Profiles to score |
|---|---|
| 1 change at a time | 7,630 |
| 2 changes | 27,029,275 |
| 3 changes | 5.9 × 10¹⁰ |
| Any combination of the 14 fields | 2.1 × 10³⁸ |
The version that shipped walks each account’s own breakpoints instead: it takes the first value that raises the rate, keeps the best 1, so the page shows 1 move per account, and lets Explore walk the path 1 step at a time instead of materializing the tree. On the demo profile that turns 7,630 profiles into 53 candidate profiles, and dedupe plus the “the bank that produced it must still be the best” filter leaves 3 rows.
The rest of the runtime work is 6 shortcuts, each one a trade between time and certainty.
Precomputed breakpoints #
Naive. Probe the interest function on demand: 545 lattice values across 14 fields is 7,630 calls per account, 129,710 across the 17 accounts, on every render.
This. Probe once, offline, over 14 fields and 56 snapshots, commit the breakpoints as a 14KB JSON file, and look them up at runtime.
Estimated effect. 129,710 interest function calls per render become 0 probes.
Only forwards, and stop at the first hit #
Naive. Evaluate every lattice value for every field, and keep every value that improves the rate.
This. Only breakpoints above the current value are candidates, which averages 5 per snapshot and peaks at 16 (DBS Multiplier), and the scan stops at the first value that raises the account’s rate.
Estimated effect. 7,630 evaluations per account become 5 on average, 16 at most.
Memoised scoring #
Naive. Score every candidate against all 17 accounts on every render: 53 candidates x 17 accounts is 901 interest function calls, paid again when you press Back.
This. bestBank() and the candidate list are memoised on a canonical profile key, so a profile you have already seen is free the second time.
Estimated effect. 901 calls per repeated render become 0.
Bisection for the savings minimum #
Naive. Walk the savings bracket $1 at a time until the rate moves: 15,000 evaluations for the demo profile’s 60,000 to 75,000 bracket, and 1,200,000 for the widest bracket in the app (Trust Bank Zen, 0 to 1,200,000).
This. Bisect instead of walking. Test the middle of the range, keep the half that can still contain the answer, and repeat: every test halves what is left, so 15,000 possible balances take about 14 tests instead of 15,000. For the demo bracket, the first test is 67,500. If the rate already qualifies there, the answer is somewhere in the lower half (60,000 to 67,500); if it does not, the answer is in the upper half (67,500 to 75,000). The next test is 63,750 if it qualified, or 71,250 if it did not, and each further test halves what is left until the range is 1 dollar wide.
It is safe here because the question has exactly 1 boundary. Inside a single savings bracket the EIR only goes up as the balance goes up, so “does this balance qualify?” is false below the threshold and true above it, and each test says which half the threshold is in.
Estimated effect. 14 tests for the demo bracket, 21 for the widest one, against 15,000 and 1,200,000 evaluations for the walk.
Compounds as a fallback #
Naive. Try every non-empty combination of fields up front: 2¹⁴ − 1 = 16,383 profiles per account.
This. Singles first; only when none qualifies does it combine fields that have a breakpoint, smallest combinations first, and stop at the first size that produces a qualifying action.
Estimated effect. For DBS Multiplier that is 15 pairs before any triple, instead of 16,383 combinations.
Dedupe before sort #
Naive. Rank every candidate, then collapse the duplicates, or show them.
This. Candidates are keyed by their canonical profile, so duplicates collapse before anything is ranked and the sort only sees unique profiles.
Estimated effect. 53 candidate profiles on the demo profile pass through the pipeline and come out as 3 ranked rows.
Where the shortcuts cost accuracy #
Every one of those shortcuts trades a guarantee for time, and 4 of them can return an answer that is not the global best:
- Only forwards. A field is never reduced on its own, so “spend less and still clear the tier” only appears when the decrease is folded into another action. A pure reduction is never a row.
- First hit wins. For a non-savings field the scan stops at the first breakpoint that raises the rate. A later breakpoint might raise it further; that one is not evaluated.
- 1 row per account. The row is the best action for that account by your priority order, not the best pair of actions across 2 accounts.
- The $1,000 block is a rounding choice. It gives a number you would actually move, not the mathematically smallest qualifying one.
The guard in the next section stops these shortcuts from producing advice that lowers your interest, but it cannot make them exhaustive.
A change only counts if both numbers go up #
A candidate has to pass 1 check before it is shown:
best.eir > eir0 && best.yearly >= yearly0
Both numbers, not either. EIR is the fair way to compare accounts with different tier structures, but dollars are what you receive. A change that lifts the percentage while lowering the dollars is not an improvement: move a large balance into a high rate, low cap account, and the headline improves while the interest does not.
That is also why the table shows both columns.
Cost is not one number #
Treating every dollar the same is wrong in both directions: spending $500 more a month can look like a win while the extra interest is a rounding error next to the spending, and a change that lowers a cost while raising a rate is a real improvement.
The model separates 4 kinds of commitment:
| Kind | Example | Counts as annual cost |
|---|---|---|
| Spend | $500 more card spend per month | Yes, times 12 |
| Premium | An insurance premium | Yes |
| Capital | An investment or a one-time loan | No, it is committed, not spent |
| Transfer | Moving savings into the account | No |
Net is yearly interest gained minus the annual running cost. Eligibility toggles, like NTUC membership, have fees the model cannot see, so they are labelled and left out of the arithmetic.
On the demo profile, BOC SmartSaver shows a 4.30% EIR and $1,110 a year more interest, which looks like the best row on the page. Its conditions say otherwise: getting there needs $12,000 a year in premiums, so the net is minus $10,290. That is the row I want people to read twice.
Cases of Saving $1 more. #
A Savings candidate moves 1 field to the next breakpoint, and the smallest integer that crosses a threshold is usually $1. So the first useful answer the optimizer gave was: add $1 and your EIR goes up.
This is mainly caused by banks which have a tiered system.
For example
Bank A:
1st 20k at 1.9% EIR
next 20k at 2.2% EIR
After 20k of savings, every $1 increase in savings will increase EIR by a small amount. In this case, the optimizer will recommend increasing savings by $1 until the next 20k is up.
Technically correct, completely useless. No one switches accounts for $1, and a table of $1 steps reads like a rounding error.
Candidates that only move savings are now promoted to a $1,000 block, capped, so it never jumps over the next savings bracket, and only kept if the same bank stays the best one and its rate does not drop.
It took 2 commits: the first rounded the step to a block, the second fixed the rows that still reported the $1 change after the rounding.The other things that broke #
The $1 step was the first sign that a mathematically correct answer can still be a bad answer. 2 more are worth calling out:
A $1 premium placeholder. The row that just says “Buy insurance” prices the premium at $1, because the model has no idea what a policy costs. The net on that row is meaningless until you put a real number in, which is why the row carries a caveat instead of a confident figure.
Most improvements never appear. Of the 53 candidate profiles the demo profile produces, only 3 survive the “the bank that produced it must still be the best” filter. The other 50 are real improvements to accounts that do not end up on top, and they are dropped rather than shown as a second tier.
Limitations #
The page shows 1 step and 1 candidate per account: there is no 2-step plan, so finding the best pair means pressing Explore and reading the next table.
The numbers are only as current as the rate history. If a bank changes its terms without a new snapshot, the optimizer is confidently wrong.
Future work #
The 3 things I would build next:
- Carry the per-account priorities in the shared profile link. They live in
localStoragetoday, and “the levers I am willing to pull” belongs in the link you send someone. - Let you enter the real premium or fund fee, so the net stops being an estimate.
- Show a path instead of a step. The layered graph was the wrong user interface (UI) for that, but the idea of comparing 2-change plans is still worth 1.
What I took away #
Deriving an answer from the implementation is not just less typing. It is the only version that stays true when a rate changes, because the thing that changes is the thing being asked.
An optimizer without a cost model is a sales pitch. The interesting work was not finding a higher rate, it was refusing the changes that cost more than they earn, and saying why in the row itself.
And a fast answer is a different thing from a correct one. Every shortcut in this page is visible somewhere: in a caveat, in a filter, or in a row that says the move costs more than it earns.
A savings account is also not the only way to earn more each month. If the goal is monthly income rather than a safe place to park cash you might need next year, an investment, a bond or another instrument can beat any HYSA, at a different risk and with less liquidity. This tool only models savings accounts, so it will always answer “which HYSA”, never “should this money be in a HYSA at all”.
You can try it on hysa.jh123x.com/optimize. If you want to see the page in motion instead of reading about it, 1 of the walkthrough tours walks through exactly this flow.