Journal Engine
The loop that keeps the journal alive.
One pass per closed minute. It reads what closed, writes only what is new, then waits for the next minute. Nothing more.
# recover, then one pass per minute written = load_this_month() while True: closed = read_closed_trades() for t in closed: if t.id not in written: journal(t) # write row written.add(t.id) sleep_to_next_minute() # stay quiet
One minute, one pass, forever
It boots once by recovering the tickets already written this month, then turns the same short circle every closed minute.
A restart never duplicates a row
On boot the engine reads back the tickets already on disk for this month. Everything past is remembered, so no closed trade is ever journaled twice.
Restartthe engine comes back up
Recover this monthtickets already written are loaded
Only truly new trades get a row
Loud only when it matters
When nothing closed, the pass does nothing. Work happens only when a trade is real.
Recover
→
Read closed
→
New only
→
Write
→
Sleep