← All projects

Open source

V-STAR

A fast, readable actuarial engine in Go. Valuation, annuities, reserves, Monte Carlo and risk measures, with zero dependencies.

Why I built it

Ask anyone who has valued a large policy census in a spreadsheet. Excel freezes or crashes, VBA macros that nobody fully understands hold the process together, and proprietary tools hide the maths. I wanted the opposite: an engine where the formulas are right there in the source, that processes a large census in seconds, and that anyone can run.

V-STAR is that engine. It brings actuarial operations that are usually prototyped in spreadsheets or scripts into a codebase that can be inspected, tested and run as software.

Where the name comes from

It started as a joke in class. If premiums compound at a rate j but you discount at i, the new discount factor is v* = (1 + j) × v. The star marks the difference, and it stuck.

What it covers

AreaWhat it does
Present valueStandard and v* discount factors, the base of everything else.
AnnuitiesWhole life, term and deferred, using real mortality tables.
ReservesNet and gross premium, prospective and retrospective.
Monte CarloGeometric Brownian motion and Vasicek mean-reverting rate models.
Risk measuresVaR, CTE and expected shortfall, with confidence intervals.
Multiple decrementsDeath, lapse and disability combined into one table.
CSV streamingProcess millions of policy rows without loading the file into memory.
HTTP APIThe same calculations as REST endpoints, usable from any language.

Design choices

  • Zero dependencies. Standard library only, so there is no package manager, no version conflicts and nothing to audit beyond the project itself.
  • Readable on purpose. Every formula is visible in the source. For actuarial work, being able to audit the calculation matters as much as getting the answer.
  • Concurrency where it helps. Go makes parallelism straightforward. Valuation and Monte Carlo both run in parallel, and a generic worker pool supports context cancellation.
  • Small, composable interfaces. Stochastic generators, contingency calculators and record writers are defined as interfaces, so concrete types plug in without ceremony. Census data can be streamed from any io.Reader, including a file, standard input or an HTTP body.
  • One binary. The command line tool and the HTTP server ship as a single executable that runs anywhere Go does.

Performance

These figures come from the project's own benchmark suite, run on an Intel i5-8250U laptop with an NVMe drive, plugged in. They show what this engine does on this machine, not a universal ranking, and each tool was measured on one observed run.

Reading a 10 million row CSV (288 MB)

ToolTimeMemory
V-STAR (memory-mapped)0.80 s1.3 GB, as OS page cache
V-STAR (streaming)1.12 sAbout 0.2 MB, constant
PolarsAbout 535 msAbout 500 MB
PandasAbout 30 sOver 2 GB

Read that table honestly. Polars parses the file faster than V-STAR does. What V-STAR offers is a streaming mode that keeps memory flat at a fraction of a megabyte however large the file gets, plus a memory-mapped mode that reads in under a second with no copying. Which one wins depends on whether time or memory is the constraint.

Monte Carlo, 100,000 paths

ToolTime
V-STAR27 ms
Python with NumPyAbout 2 s
RAbout 5 s

Individual operations

OperationTime
Present value (single call, direct)2.6 ns
Whole life annuity (90 terms)512 ns
Monte Carlo (100k paths, 10 steps)27 ms
VaR and CTE report (100k losses)0.42 ms
Valuation (10M policies, parallel)37 ms

Timings vary with hardware and comparison setup. Run ./v-star bench and --benchmark locally to compare on your own machine.

Using it

V-STAR works as a Go library, a command line tool and an HTTP service.

# install the library
go get github.com/lubasinkal/v-star

# process a policy CSV and time it
./v-star read policies.csv --benchmark

# run a Monte Carlo simulation
./v-star montecarlo --paths=100000 --steps=10 --seed=42

# start the HTTP server
./v-star serve --port=8080

The HTTP API exposes the same engine at /health, /value, /simulate, /annuity and /reserve, returning JSON. That makes it usable from Python, R, JavaScript or even Excel VBA. The repository has client examples in several languages, and it is the source of truth for current APIs and setup.

Where it is used

Actuworry, my live life insurance calculator, uses V-STAR for its Monte Carlo, risk, rate conversion and retrospective reserve endpoints.

What is next

The roadmap points at a v0.8.0 release with more reserve methods, a census source interface, profit testing and a Dockerfile, followed by v1.0.0 with a stable API and broader test coverage. The full plan lives in the repository's roadmap.

Hand-siphon for Greek fire, medieval illumination

ABOUT THE IMAGE

Hand-siphon for Greek fire, medieval illumination

Date
9th or 11th century AD
Rights
Public domain claim (jurisdiction may vary)

Historical context

This manuscript illustration shows a hand-siphon firing Greek fire from a siege tower towards defenders on a wall. It belongs to the Byzantine military-technology tradition; the source identifies the manuscript as Codex Vaticanus Graecus 1605, but its dating is uncertain.

View original source and rights ↗

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