Private System · Internal Use v3.0 · Scheduled Pipeline Google Apps Script · Cloud Firestore · GCP IAM Gemini · Python NLP · MV3

Daily Stock Performer

An autonomous market-day portfolio telemetry, risk-regime, and AI catalyst-briefing pipeline built for personal operations. Pairs deterministic moving-average, drawdown, and benchmark-tracking rules with parallel RSS news grounding, Gemini synthesis, and IAM-hardened Cloud Firestore state.

Why there is no public launch link: This system runs privately against personal brokerage tax lots inside an IAM-locked Google Workspace and GCP project. Below is a sanitized breakdown of its architecture, security controls, and local test harness.

System Flow

End-to-End Market-Day Pipeline

  1. 01 · Ingest

    Trade-Lot & Price Sync

    A private Manifest V3 Chrome extension ingests dated brokerage CSV activity lots into Google Sheets, where live GOOGLEFINANCE valuation, 50d/200d moving averages, and 52-week drawdowns are computed.

  2. 02 · Gate

    Calendar-Aware Cadence

    Time-driven triggers check market state before mutating anything—automatically skipping weekends and NYSE holidays so closed-market days never duplicate signals, while logging every run’s status and duration.

  3. 03 · Evaluate

    3-Layer Regime & Grounded AI

    Scores holdings across Core, Benchmark-Tracked, and Tactical layers against date-matched SPY shadow benchmarks. Fetches 7-day RSS news in parallel (UrlFetchApp.fetchAll) at zero API cost to ground Gemini briefs in real catalysts.

  4. 04 · Persist

    Fail-Safe IAM Firestore

    Writes daily alert snapshots and position-layer state to Cloud Firestore via GCP IAM OAuth2 tokens, guarded by field-level updateMask patches and a PropertiesService backup snapshot.

Engineering & Security

Testing & Least-Privilege Design

Local Node vm Test Gate for Apps Script

Google Apps Script lacks a native local test runner, making it easy to push broken code directly into scheduled jobs. To close that gap, npm run push compiles all six Apps Script modules inside a local Node vm sandbox—mocking SpreadsheetApp, UrlFetchApp, and ScriptApp—and blocks clasp deployment unless the full verification suite passes.

Sanitized excerpt — local VM verification & deploy gate
// package.json — deployment blocked if sandbox suite fails
"scripts": {
  "test": "node tests/verify_3layer_hybrid.js",
  "push": "npm test && npx @google/clasp push -f"
}

// tests/verify_3layer_hybrid.js — syntax + runtime assertions
for (const file of srcFiles) {
  const source = fs.readFileSync(path.join(srcDir, file), "utf8");
  new vm.Script(source, { filename: file });
}
vm.runInNewContext(bundle, mockedAppsScriptGlobals);

Zero-Client-Write Firestore & Secret Isolation

Even for a single-owner system, credentials and state follow defense-in-depth. Production writes authenticate server-side via Google Cloud IAM (datastore OAuth2 scope). Client SDK writes are denied globally, api_secrets documents are completely unreachable from client SDKs, and read failures refuse to overwrite existing Firestore documents.

Sanitized excerpt — firestore.rules
service cloud.firestore {
  match /databases/{database}/documents {
    // Server-only secret vault: denied to all client SDKs
    match /portfolio_config/api_secrets {
      allow read, write: if false;
    }

    // Telemetry collections: verified owner read-only; IAM-only writes
    match /daily_runs/{date} {
      allow get, list: if isVerifiedOwner();
      allow create, update, delete: if false;
    }
  }
}

Supporting Modules

Companion Tooling & Validation

Bias-Free Backtesting Suite

Node backtester and forecaster evaluating multi-year trade lots and historical exits against date-matched total-return SPY series—including all exited positions to prevent survivorship and look-ahead bias.

Private MV3 CSV-Sync Extension

Minimal-permission Manifest V3 helper (storage + scoped Apps Script host permissions) that parses brokerage trade-lot exports and syncs normalized lot records directly into Sheets.

Python Company Sentiment CLI

Standalone Python aggregator (sentiment-analysis.py) combining RSS feeds, Reddit PRAW signals, and Google Trends through NLTK VADER or HuggingFace transformers into JSONL/CSV logs.