← Back to blog

Writing / V-Star

Stop Hardcoding Everything

3 min read#actuarial#go#simulation#software
On this page

v0.7 was the moment the-spreadsheet-killer stopped being a fast script and started being a framework.

Before that it was just me abusing Go’s concurrency to make spreadsheet users miserable. 1M policies, 300ms, boom. I thought I had it figured out.

But here’s the thing: raw speed is easy. Architecture is the hard part.

v0.7.0 is where I stopped treating this like a script and started treating it like a framework. The big move? Interfaces.

The “Stop Hardcoding” Pivot

I realised I was trapped. If I wanted a different interest rate model, I had to rip out the guts of the simulator. Who does that? I did.

So I killed the concrete dependencies. Now we have PathGenerator, ContingencyCalculator, and MortalityTable as interfaces.

Until now, it was just Geometric Brownian Motion for path generation. Cool, but GBM just drifts. Real interest rates don’t do that, they mean-revert. Enter the Vasicek Model. Because I’m using a PathGenerator interface, I just plugged in a Vasicek generator and suddenly the simulation actually makes sense for real-world financial engineering. It’s not just a feature, it’s what makes the tool useful.

Same for the ContingencyCalculator. I stopped doing just present values and started doing actual actuarial science. Whole life, term insurance, deferred annuities, net single premiums. If it’s a life-contingent cash flow, the-spreadsheet-killer can probably calculate it without me rewriting the core engine.

One interface change unlocked all of that. That’s the power of programming to interfaces instead of concrete types.

The Unix Way

the-spreadsheet-killer was always CLI-first, but v0.7.0 makes it composable. I added StreamCensusFromReader. The engine doesn’t care if your data is in a file, an HTTP body, or some buffer in memory. It just wants an io.Reader.

You can literally curl a CSV and pipe it straight into the engine:

curl -s https://api.provider.com/census | ./the-spreadsheet-killer read --stdin --benchmark

And if you want the fastest possible I/O, there’s the mmap path. 10M rows in 0.80 seconds. Zero-copy parsing. As fast as the OS can read the disk.

The HTTP API

The biggest grown-up move in this version is the server. the-spreadsheet-killer is now a REST API. You don’t need Go to use it. Call it from Python, R, or even Excel via HTTP.

At this stage, a Monte Carlo risk report with VaR 95% and CTE 99% came from the /montecarlo endpoint. Later, I reworked the API into six routes, so this is a snapshot of that earlier version. Same engine, wrapped in a way that made it accessible to the rest of the stack.

The Flex (Benchmarks)

Because I can’t help myself:

  • PV Calculation: 380 million calls per second
  • Parallel Valuation: 272 million policies per second
  • Monte Carlo: 3.7 million paths per second

Combine that speed with the new interfaces and you’re not running a simulation. You’re running a professional-grade actuarial lab on your laptop.

The Boring Stuff That Matters

Parallel Monte Carlo, each worker gets its own RNG so they aren’t fighting over a lock. More cores = faster simulation.

Version injection via ldflags, no more hardcoding the version in main.go like a caveman. It’s a tiny change, but it’s the “I actually know how to build Go tools” flex.

What’s Next

The foundation is finally not made of cardboard. Custom mortality tables from real CSV files. Variance reduction with antithetic variates. Stepped and increasing benefits. The fun stuff.

Repo is now at github.com/lubasinkal/v-star. Go build it, or don’t. I don’t care.

Villard de Honnecourt Album de ... charpente. BNF

ABOUT THE IMAGE

Villard de Honnecourt Album de ... charpente. BNF

Creator
Villard de Honnecourt - XIIIe siècle
Date
13th century
Rights
CC0

Historical context

A drawing of medieval timber framing appears in Villard de Honnecourt’s thirteenth-century sketchbook. The French file description calls it a model of carpentry; the page records a construction scheme, and the sketchbook places it among the album’s engineering studies.

View original source and rights ↗

The article cover is a cropped, tinted adaptation of this image.