A Japanese value-stock screener on a Raspberry Pi 2
I keep a script that screens Japanese stocks across a bunch of value and quality strategies. It started out printing straight to a terminal. These days it builds a small site I can browse and filter. The whole pipeline, fetching, scoring, backtesting, and serving, runs on a Raspberry Pi 2, the oldest machine in the house. I built the first version on my Mac.
Files do all the work
The flow starts by pulling the latest prices and financials, then scoring each
name. The results get written out as plain JSON, and a static site reads that
file to render the tables and charts. It opens straight off file://. Everything
it needs is already sitting in that one JSON file, so nothing else has to run in
the background. (A separate pull from EDINET adds buyback and large-holding
filings the same way: fetch, then write a file.)
That “files only” choice is half of why an ancient Pi 2 can host the whole thing: it’s 32-bit with about a gig of RAM, nowhere near enough to comfortably run a real database. (This blog follows the same approach. See the tech behind this site if you’re curious.)
Same data, eight ways
One fetch, then each strategy reads the same numbers its own way: Graham deep-value, Buffett-style quality, high-dividend, GARP, net-cash, the TSE “PBR reform” angle, a Piotroski F-score, EV/EBIT. On the site you switch between them with a tap, and filter by universe, sector, or search.
Does it work?
There’s a backtest so I’m not fooling myself. It saves a snapshot each run and measures forward returns from each past date to a later one. The signal stays fixed at what it was then; the price is whatever happened afterward. It also runs a factor-adjusted check, to see whether a strategy has any edge left once you strip out the obvious size and value effects, along with momentum. The history is only an approximate point-in-time reconstruction. I know its limits, and every run adds a real snapshot that sharpens the picture. (Update: I’ve since built a proper fix for the financials side of that problem.)
Living within 1GB
Moving everything onto the Pi took some squeezing. A gig of RAM is tight for pulling and crunching this many names, so I freed up the memory the GPU reserves (a headless board doesn’t need it) and gave the work more room. I also pulled the parallel workers out of the backtest. They need more memory than this little board can spare, so now it just plods through one name at a time.
I spread the work out: the screen and the EDINET pull refresh daily, and the heavier backtest runs once a week. Serving is the easy part: static files behind Cloudflare Access, so it’s only me. It’s my own scratchpad, and I’d rather keep it closed than leave it open to whoever wanders past.
This is a personal research tool I use to make my own calls. If you’re after stock tips, look elsewhere. Still, I get a dozen strategies out of it, each with a backtest behind it, all glanceable from a decade-old board sitting under my desk.