SQLite Token Tracker & Budget Gate

Automated Financial Circuit Breaker

Published: 2026-06-20  |  Project: BayesianPivot  |  Discipline: Distributed Systems & High-Throughput State

Author: Nicholas Alexander MacAskill — Founder & CTO, Flocano Labs  |  Canonical: https://www.nicholasmacaskill.com/dossier/bp-tracker

Tracking Database
smc_alpha.db
Verified Invariant
Fallback Action
Math-Only Loop
Verified Invariant

The SQLite Token Usage Tracker & Budget Gate

To safeguard against billing runaways in continuous scanning environments, the stack runs a local monitoring client.

Implementation details (`token_tracker.py`)

Every Gemini API call logs its exact prompt_tokens and candidate_tokens to a local SQLite table.

SQLPRODUCTION RUNTIME
-- Token log schema
CREATE TABLE IF NOT EXISTS token_logs (
    id INTEGER PRIMARY KEY AUTOINCREMENT,
    timestamp DATETIME DEFAULT CURRENT_TIMESTAMP,
    prompt_tokens INTEGER,
    candidate_tokens INTEGER,
    cost REAL
);

The Budget Circuit Breaker

If total token expenditure exceeds a daily ceiling of $2.00: 1. The tracker automatically alerts the trader via Telegram. 2. It suspends LLM calls, forcing the trading infrastructure to fallback to local, math-only execution (Structural Alpha). 3. This prevents billing runaways during highly volatile, high-frequency scan sessions.

SIGNAL_DETECTED:"system online // first dossier lesson logged"//TARGET:sovereign layer////////////////////////
Flocano Labs
ARCHITECTURELAYER
Memoirs
TASTELAYER
Nicholas Alexander MacAskill
IDENTITYLAYER
Biography
ABOUTFOUNDER