deepvalue ~main

A small, dependency-free D library for deep-value and net-net stock screening: net current asset value (NCAV), net-net working capital, Graham number, margin of safety, and Graham-style balance-sheet checks.


To use this package, run the following command in your project's root directory:

Manual usage
Put the following dependency into your project's dependences section:

deepvalue

A small, dependency-free D library for deep-value and net-net stock screening — the balance-sheet math Benjamin Graham used to buy companies below liquidation value.

It turns the line items on a balance sheet and income statement into the handful of numbers a value screener actually checks, with no external dependencies and every function @safe pure.

The screening model and thresholds mirror the one published at deepvalueradar.com.

What it computes

FunctionMeaning
ncav(currentAssets, totalLiabilities)Net current asset value — Graham's liquidation floor.
ncavPerShare(...)NCAV spread over the diluted share count.
netNetWorkingCapital(cash, receivables, inventory, liabilities, preferred)Graham's NNWC, haircutting receivables to 75% and inventory to 50%.
isNetNet(price, ncavPerShare)True when price is below ⅔ of NCAV/share (a "net-net").
grahamNumber(eps, bvps)sqrt(22.5 · EPS · BVPS) — the defensive-investor fair-value ceiling.
marginOfSafety(price, intrinsic)Discount of price to an intrinsic value.
priceToEarnings(price, eps) / priceToBook(price, bvps)The two defensive-investor valuation ratios.
piotroskiFScore(inputs)A 0–9 balance-sheet quality score to weed out value traps.
grahamDefensiveChecks(...)P/E ≤ 15, P/B ≤ 1.5, current ratio ≥ 2.0, and long-term debt ≤ working capital.

Why the constants

The Graham number's 22.5 is 15 · 1.5 — Graham's twin defensive rules that a stock should trade below a P/E of 15 and a price-to-book of 1.5. The grahamDefensiveChecks thresholds (P/E ≤ 15, P/B ≤ 1.5, current ratio ≥ 2.0) come straight from the classic defensive-investor criteria.

Usage

import deepvalue;

// Is this a Graham net-net?
immutable nps = ncavPerShare(500_000, 300_000, 40_000); // = 5.00 / share
immutable cheap = isNetNet(3.00, nps);                  // price < 2/3 * 5 = 3.33 -> true

// Fair-value ceiling and margin of safety.
immutable fair = grahamNumber(3.0, 30.0);   // sqrt(22.5*3*30) = 45.0
immutable mos  = marginOfSafety(36.0, fair); // (45-36)/45 = 0.20 -> 20% margin

// Full defensive screen.
auto verdict = grahamDefensiveChecks(
    /* price */ 20.0, /* eps */ 2.0, /* bvps */ 16.0,
    /* current assets */ 400.0, /* current liabilities */ 150.0,
    /* long-term debt */ 100.0);
assert(verdict.passes);

// Quality overlay to avoid value traps.
PiotroskiInputs f = { netIncome: 120, operatingCashFlow: 150, /* ... */ };
immutable score = piotroskiFScore(f); // 0..9

Build & test

dub build --compiler=ldc2
dub test  --compiler=ldc2

License

MIT © 2026 deepvalueradar. See LICENSE.

Authors:
  • deepvalueradar
Dependencies:
none
Versions:
0.1.0 2026-Jul-16
~main 2026-Jul-16
Show all 2 versions
Download Stats:
  • 1 downloads today

  • 1 downloads this week

  • 1 downloads this month

  • 1 downloads total

Score:
0.0
Short URL:
deepvalue.dub.pm