pickuma.
Finance

T-Bill Ladders for Developers: Automating a Cash Management Strategy in Python

How I model and run a Treasury bill ladder for emergency funds and business cash — yield vs HYSA, TreasuryDirect vs brokerage, auto-roll, the state-tax-exempt angle, and a small Python model you can copy.

9 min read

I keep about six months of expenses in cash, plus a separate pile of business operating money I don’t touch between quarterly tax payments. For years that money sat in a high-yield savings account earning whatever the bank felt like paying that month, which is to say: less than the bank earned lending it out. Sometime in 2023 I did the math on what I was leaving on the table and switched the bulk of it into a Treasury bill ladder. I’ve run that ladder through three different rate regimes since, including the cuts that started rolling through in late 2024, and it has done exactly what I wanted: paid me a little more than the bank, kept the money government-backed, and stayed liquid enough that I never lay awake about it.

This is a guide for developers who have a cash position they want to manage deliberately rather than passively. If you can write a for-loop and read a yield curve, you can run a T-bill ladder. I’ll explain what the instrument actually is, why laddering beats lump-sum buying, where to hold it, the tax wrinkle that makes Treasuries quietly better than they look, and a small Python model you can adapt to size your own ladder. I’ll also be honest about when this is the wrong move.

What a T-bill actually is

A Treasury bill is a short-term debt obligation of the U.S. federal government, issued in maturities of 4, 8, 13, 17, 26, and 52 weeks. Bills don’t pay a coupon. You buy them at a discount to face value and they mature at face value, and the difference is your return. Buy a 26-week bill at $987.50 with a $1,000 face value and you collect $1,000 at maturity — that $12.50 is the interest, even though no “interest payment” ever lands in your account.

The yield is set at auction. The Treasury runs regular auctions (weekly for the shorter bills, every four weeks for the 52-week), and the auction clears at a rate driven by demand. When you buy at auction you take the auction yield; when you buy on the secondary market through a brokerage you take whatever the market is pricing at that moment. For cash management purposes the practical point is this: bills track short-term rates closely, so their yield moves with what the Fed is doing, which is the whole reason they tend to keep pace with — and usually slightly beat — a high-yield savings account.

The credit risk is, for practical purposes, zero. These are direct obligations of the U.S. Treasury. The risk you’re actually taking is reinvestment risk: when your bill matures, the rate you can get on the next one might be lower than what you just earned. That is precisely the risk a ladder is built to manage.

Why a ladder instead of one big bill

If you put your entire cash position into a single 52-week bill, two bad things can happen. First, all of it is locked into one rate for a year — great if rates fall right after you buy, painful if they rise. Second, if you need cash in month three, you have to sell that bill on the secondary market, possibly at a loss if rates moved against you, and pay a spread to do it.

A ladder fixes both. You split the money across several maturities — say 4, 8, 13, 26, and 52 weeks — so a rung is always coming due soon, and when each rung matures you roll it back out to the long end of the ladder. The effect is a portfolio with a blended yield somewhere between the short and long rates, with something maturing every few weeks for liquidity, and with reinvestment spread out over time so no single rate decision dominates your outcome. You’re dollar-cost-averaging across the yield curve.

The practical liquidity profile matters for an emergency fund. With a five-rung ladder, on any given month you’re rarely more than a few weeks from a scheduled maturity, and the shortest rung gives you a near-term exit without ever selling on the secondary market. You give up the instant-access nature of a savings account, but in exchange you get a meaningfully better-defined yield and a structure that survives rate cuts gracefully.

TreasuryDirect vs buying bills in a brokerage

There are two places to hold this, and the choice has real ergonomic consequences.

TreasuryDirect is the government’s own platform. You buy bills at auction directly, with zero fees, no markup, no middleman. The yield you get is the clean auction yield. The downsides are the experience: the site is a relic, the UI is from another era, linking a bank account can be slow, and — the big one — selling a bill before maturity is genuinely awkward (you have to transfer it out to a broker first). It does have an auto-roll feature called “Schedule Reinvestments” that will automatically reinvest a maturing bill into the next auction of the same term, which is the closest thing to set-and-forget the platform offers.

A brokerage (Fidelity, Schwab, Vanguard, and others) lets you buy bills both at auction and on the secondary market, usually with no commission on Treasuries bought at auction. The experience is dramatically better: real interfaces, instant visibility into your whole ladder, the ability to sell a bill mid-flight in seconds if you genuinely need the cash, and consolidated tax reporting. Many brokers also offer auto-roll on auction purchases. The tradeoff is that secondary-market purchases carry a bid-ask spread, and you have to trust the broker’s plumbing.

For most developers I’d point at a brokerage. The liquidity and the consolidated view are worth more than the few basis points TreasuryDirect saves you, and the ability to actually sell a rung in an emergency is the difference between a real emergency fund and a theoretical one. Use TreasuryDirect if you’re allergic to brokers or buying I-bonds (which live only there).

ToolVenueFeesMid-term sellingBest for
TreasuryDirect Best for Buy-and-hold purists, I-bond buyersNone — clean auction yieldAwkward (must transfer to a broker)
Brokerage (auction) Best for Most cash-management laddersUsually $0 on auction buysEasy — sell on secondary in seconds
Brokerage (secondary) Best for Filling odd maturities or buying off-auctionSmall bid-ask spreadEasy — full liquidity

The tax wrinkle that makes Treasuries quietly better

Here is the part people miss. Interest from Treasury bills is exempt from state and local income tax. It’s fully taxable at the federal level, but your state can’t touch it. A high-yield savings account, by contrast, is taxed at both federal and state level.

That exemption is worth real money if you live somewhere with a meaningful state income tax. To compare a T-bill yield against a savings account honestly, you have to gross up the bill’s yield by your state tax savings — the “taxable-equivalent yield.” Roughly, the equivalent yield is the bill’s yield divided by (1 minus your state marginal rate). If you’re in a state with a 9% income tax and a savings account and a bill both nominally pay the same rate, the bill is the clearly better deal after tax, because that last slice of the savings-account interest goes to the state and the bill’s doesn’t. If you live in a no-income-tax state, this whole paragraph doesn’t apply to you and the comparison is just nominal yield against nominal yield.

One reporting note: the discount income on a bill is reported on Form 1099-INT in the year the bill matures, in the box for Treasury interest, so it flows through your return cleanly. Keep your brokerage’s year-end statements; the math is done for you there.

A small Python model for sizing your ladder

You don’t need a library for this. Here’s a compact model that takes a cash amount and a set of current bill yields, splits the money evenly across the rungs, computes the blended yield, and prints the reinvestment schedule so you can see when each rung comes due. Plug in real yields from the latest auction results or your broker’s quote screen.

from datetime import date, timedelta
# Current annualized yields per maturity (decimals). Replace with real quotes.
rungs = {
"4-week": 0.0440,
"8-week": 0.0438,
"13-week": 0.0435,
"26-week": 0.0430,
"52-week": 0.0425,
}
weeks = {"4-week": 4, "8-week": 8, "13-week": 13, "26-week": 26, "52-week": 52}
cash = 50_000
per_rung = cash / len(rungs) # equal-weight each rung
start = date.today()
print(f"Ladder: ${cash:,.0f} across {len(rungs)} rungs "
f"(${per_rung:,.0f} each)\n")
blended = 0.0
for name, y in rungs.items():
matures = start + timedelta(weeks=weeks[name])
# discount-style interest earned over the bill's life
interest = per_rung * y * (weeks[name] / 52)
blended += y / len(rungs)
print(f"{name:8} yield {y:6.3%} matures {matures} "
f"interest ${interest:7,.2f}")
print(f"\nBlended annualized yield: {blended:.3%}")
# Taxable-equivalent yield vs a savings account, given a state marginal rate
state_rate = 0.093 # your state marginal income tax; 0.0 if none
te_yield = blended / (1 - state_rate)
print(f"Taxable-equivalent yield (state {state_rate:.1%}): {te_yield:.3%}")

Run it and you get a per-rung interest estimate, a blended yield, and the taxable-equivalent yield to compare against a savings account. The auto-roll logic is the easy part conceptually: when a rung matures, you reinvest the proceeds into a new bill at the longest rung’s term, which keeps the ladder’s shape intact and pushes that money back out to the end of the line. In practice you let your broker’s or TreasuryDirect’s reinvestment feature do this automatically rather than logging in every four weeks. The model’s job is to tell you the shape and the expected yield before you commit, not to execute trades.

A caveat on the interest math: this uses a simple linear approximation of discount yield, which is close enough for sizing decisions but isn’t the exact discount-vs-investment-rate convention the Treasury uses. Don’t use these numbers for your taxes — use the broker’s 1099.

Who should run a T-bill ladder

This is a good fit if you have a cash position you genuinely won’t need to spend in the next few weeks: an emergency fund, a house down payment a year out, business operating cash between tax payments, a sabbatical fund. It’s especially worth it if you live in a high-tax state, because the state-tax exemption widens the gap over a savings account.

It’s a bad fit for money you might need tomorrow — keep your true checking buffer in checking. It’s also less compelling if you’re in a no-income-tax state and your bank’s HYSA is already paying a competitive rate, because then you’re trading liquidity for a thin margin. And it’s the wrong tool for long-term growth: bills are cash management, not investing. If your time horizon is five-plus years, that money belongs in a diversified portfolio inside a tax-advantaged account, not a bill ladder. (If you want the mechanics of building that longer-horizon side, our fixed-income and tax-advantaged-account guides cover where bonds and bond funds fit, and how to use the tax shelters first.)

The honest summary: a ladder is a deliberate, low-effort way to make idle cash work a little harder with essentially no credit risk. The edge is modest and rate-dependent. If you’re the kind of developer who already automates the boring parts of your life, this fits right in — model it, build the rungs, turn on auto-roll, and check the curve once a quarter.

FAQ

Is a T-bill ladder safer than a high-yield savings account?+
The credit risk is arguably lower — T-bills are direct obligations of the U.S. Treasury, while a bank deposit relies on FDIC insurance up to the coverage limit. The tradeoff is liquidity: a savings account gives instant access, while a ladder gives you access only as rungs mature (or by selling on the secondary market through a broker). For money you won't touch for weeks, the ladder is comparably safe and usually pays a bit more.
How much money do I need to start a ladder?+
Treasury bills are sold in $100 increments, so technically you can start small. But a sensible five-rung ladder works better with a few thousand dollars so each rung is a meaningful size and the transaction friction is negligible relative to the interest. There's no required minimum beyond the $100 unit.
What happens to my ladder when interest rates fall?+
Each rung keeps its locked-in yield until it matures, so you don't lose anything already booked. As rungs mature you reinvest at the new, lower rate, so the ladder's blended yield drifts down gradually rather than all at once — which is exactly the reinvestment-smoothing the ladder is designed for. A single long bill would have locked in the higher rate longer, but you can't know in advance which way rates will move.
Do I pay state income tax on T-bill interest?+
No. Interest from Treasury bills is exempt from state and local income tax, though it is fully taxable at the federal level. This is what makes the taxable-equivalent yield higher than the nominal yield for anyone in a state with an income tax, and it's a meaningful edge over a savings account, whose interest is taxed at both levels.
Can I sell a T-bill before it matures if I need the cash?+
Yes, if you hold it in a brokerage account — you sell it on the secondary market, usually within seconds, though you pay a small bid-ask spread and the price reflects current rates, so you could realize a small gain or loss. Selling from TreasuryDirect is more awkward and requires transferring the bill to a broker first, which is the main reason most people run cash-management ladders inside a brokerage.

Related reading

See all Finance articles →

Get the best tools, weekly

One email every Friday. No spam, unsubscribe anytime.