Class Checkpoint

java.lang.Object
com.quantfinlib.persist.Checkpoint

public final class Checkpoint extends Object
Multi-day persistence of learned state: everything the models learn across sessions — volume/vol/spread baselines, alpha weights and their out-of-sample IC evidence, venue and LP scorecards — is exactly what a desk does NOT want to relearn from zero every morning. A checkpoint is one binary file of named sections, written at end of day and restored at the next session start:

 try (var w = Checkpoint.writer(path)) {           // end of day
     w.section("volume.AAPL", volumeCurve::writeState)
      .section("alpha.AAPL", learner::writeState)
      .section("venues", scorecard::writeState);
 }                                                  // commits atomically

 var r = Checkpoint.reader(path);                   // next morning
 r.section("volume.AAPL", volumeCurve::readState);  // false if absent
 

Contract. Each model persists its learned (cross-day) state only; intraday state resets on read — you restore at session start, not mid-stream. The reading instance must be constructed with the same configuration (bucket count, venue count, …): a mismatch throws IOException rather than silently misaligning arrays. Each section payload carries its own version byte so models can evolve their format independently of the file format.

Durability. The writer buffers sections in memory and commits in Checkpoint.Writer.close(): temp file in the target directory, then an atomic rename over the old checkpoint — a crash mid-save leaves yesterday's file intact, never a torn one. (On the rare filesystem without atomic rename — some network mounts — the commit degrades to a plain replace, and a crash in that narrow window can lose the old file; keep checkpoints on a local disk if that guarantee matters.) If any section writer threw, nothing is committed. The reader loads the whole file up front (these files are kilobytes), skips unknown sections (forward compatibility), and rejects a section the model did not fully consume — the loudest possible signal of a writer/reader format drift.

Everything here is cold-path (end of day / session start); the hot lanes never see it. Naming convention: model.symbol ("volume.EURUSD", "venues"). For DayTypeProfiles, write one section per day type ("volume.AAPL.day0" …).