02 / 06 記帳與台股提醒Ledger & TW stock reminders

LedgerLion

本地優先的個人記帳與台股公開資訊提醒 Agent

A local-first personal bookkeeping and Taiwan-stock public-info reminder agent

帳本留在你的電腦裡,最後買進日不再因連假算錯。

Your ledger stays on your machine — and the last-buy day survives the long weekend.

LedgerLion icon
資料Data
本機 SQLiteLocal SQLite
模型Models
Ollama · Anthropic · OpenAI · 不使用Ollama · Anthropic · OpenAI · none
通知Notify
Telegram · Discord · iCalendarTelegram · Discord · iCalendar
技術Built with
  • SQLite
  • Hono
  • Vue 3
  • Vite
  • Tailwind CSS v4
  • Ollama

(01) 為什麼Why

資料全部存在本機 SQLite。它解決三件事:雲端記帳的隱私疑慮、自動分類不會記住你的修正,以及股東會紀念品最後買進日遇到連假容易算錯。

Everything lives in a local SQLite file. It solves three things: the privacy worry of cloud bookkeeping, auto-categorisers that never remember your corrections, and shareholder-gift last-buy days miscalculated around long holidays.

(02) 06 項items

它做什麼What it does

  1. 01

    匯入你真正拿得到的帳單Imports the statements you actually have

    國泰世華、中國信託、玉山信用卡 CSV、財政部電子發票 CSV、銀行對帳 CSV、文字型與加密 PDF 帳單(密碼只留在記憶體),以及自訂欄位的通用 CSV。

    Cathay United, CTBC and E.SUN card CSVs, Ministry of Finance e-invoice CSV, bank statement CSV, text and encrypted PDF statements (the password stays in memory) and a generic CSV with custom columns.

  2. 02

    重複匯入新增 0 筆Re-import adds zero rows

    去重、卡號只留末四碼、信用卡與電子發票同筆消費自動合併、外幣換算、訂閱偵測。

    Deduplication, card numbers kept to the last four digits, card and e-invoice entries merged, FX conversion and subscription detection.

  3. 03

    修正一次,永久記住Correct once, remembered forever

    三層分類:規則 → 歷史交易 → 模型。修正一次即建立永久規則,命中規則就不呼叫模型。

    Three-layer categorisation: rules → history → model. One correction becomes a permanent rule, and a rule hit never calls the model.

  4. 04

    算對的交易日曆A trading calendar that gets it right

    涵蓋週末、國定假日與春節,可手動補登颱風假;推算最後過戶日與 T+2 最後買進日,保留來源與計算過程。

    Weekends, national holidays and Lunar New Year, plus manually added typhoon days; it derives the last transfer date and the T+2 last-buy day, keeping sources and every step.

  5. 05

    公開資料來源Public data sources

    資料來自 TWSE 與 TPEx OpenAPI(上櫃股東會紀念品需以 watch add --gift 手動登錄);公告改期會自動重算。

    Data from the TWSE and TPEx OpenAPIs (TPEx shareholder gifts are added manually with watch add --gift); rescheduled announcements are recalculated automatically.

  6. 06

    規則決定提醒,模型只寫文案Rules decide, the model only writes

    紀念品 D-3 / D-1、除權息 D-1、預算 80% / 100%、每月摘要由固定規則決定;LLM 只負責文案,失敗時退回固定模板。

    Gift D-3 / D-1, ex-dividend D-1, budget 80% / 100% and monthly summaries are fixed rules; the LLM only writes the wording and falls back to a template if it fails.

(03) 怎麼運作How it works

從帳單到提醒From statement to reminder

  1. 01

    匯入Import

    CSV、PDF 或電子發票。

    CSV, PDF or e-invoices.

  2. 02

    分類Categorise

    規則 → 歷史 → 模型,低信心時交給你 review。

    Rules → history → model; low confidence goes to your review.

  3. 03

    觀察Watch

    watch add 追蹤紀念品與除權息。

    watch add tracks gifts and dividends.

  4. 04

    推算Calculate

    交易日曆推出 T+2 最後買進日。

    The trading calendar derives the T+2 last-buy day.

  5. 05

    提醒Remind

    Web UI、Telegram、Discord 或 iCalendar。

    Web UI, Telegram, Discord or iCalendar.

(04) README

快速開始Quick start

Web UI 需要啟動時印出的存取 Token。README 實測(claude-haiku-5-5):單筆分類約 1.5 秒、3 筆批次約 0.9 秒。

The Web UI needs the access token printed at startup. README measurement (claude-haiku-5-5): ~1.5 s per single categorisation, ~0.9 s for a batch of 3.

Docker Compose(含本地 Ollama)Docker Compose (with local Ollama)
cp .env.example .env
docker compose up -d
本機Local
npm install
npm run db:migrate
npm run build
npm run dev
# Web UI: http://127.0.0.1:3600
CLICLI
npm run cli -- import ./examples/sample-cathay.csv
npm run cli -- watch add 2330 --track gift,dividend --gift "環保隨行杯"
npm run cli -- calc last-buy 2330 --closure-start 2025-11-05

(05) 隱私Privacy

隱私Privacy

  • 預設不呼叫外部模型;預設提供者是本地 Ollama。No external model by default — the default provider is local Ollama.
  • 啟用雲端模型時只送出去識別化的商家名、金額區間與發票品項,不含日期、帳戶或卡號;每次外送都記錄在 llm_audit_log。With a cloud model, only de-identified merchant names, amount ranges and invoice items leave — no dates, accounts or card numbers — and every call is logged in llm_audit_log.
  • API 需 Bearer Token,只接受 localhost 的 Host/Origin;Telegram 只回應白名單 chat。The API needs a bearer token and only accepts localhost Host / Origin; Telegram answers whitelisted chats only.
  • 不構成投資建議:日期請以 TWSE、TPEx、公開資訊觀測站及發行公司公告為準。Not investment advice: always confirm dates with TWSE, TPEx, MOPS and the issuer.

目前狀態Status

  • Repo 目前為私有,準備開源中。Repo currently private — coming to open source.
  • README 宣告 MIT 授權。README declares the MIT licence.

想先試用 LedgerLion?Want to try LedgerLion early?

所有 repo 目前都是私有的,準備開源中。想搶先試用,請透過 GitHub 個人頁聯絡。All repos are private for now and on their way to open source. To try one early, get in touch via the GitHub profile.