Skip to content
ShelpidPublic

About

Quantum Second Brain

Resources

Stars

2 stars

Watchers

0 watching

Forks

Latest commit

 

History

1 Commit

Folders and files

Repository files navigation

Quant Second Brain

Quant Second Brain

ci python license

Your second brain does the pre-market research while you sleep.

Quant Second Brain is a local markdown vault plus six small pipelines. Every night it reads what you saved during the day, links the fresh notes to everything you already wrote, backtests your trade ideas on daily prices, and at 06:30 leaves a brief with 3 ideas to check before the open.

It wakes you only when it matters: when a fresh note contradicts one of your active theses, or when an idea scores above 0.90.

Quant Second Brain graph view: fresh notes linking into the vault

One night inside Quant Second Brain

READER, LISTENER and POCKET feed the vault; CONNECTOR at 03:00, QUANT at 05:00, BRIEFER at 06:30

when pipeline what it does
all day READER articles, highlights, saved HTML pages, PDFs, URL lists → one idea per note
all day LISTENER podcast and call transcripts (.srt, .vtt), audio via faster-whisper → notes
all day POCKET anything you send the Telegram bot or qsb add → raw/pocket-*.md
03:00 CONNECTOR links fresh notes to old ones (TF-IDF, no API needed), flags notes that argue against an active thesis
05:00 QUANT backtests every idea on daily prices, keeps it only if n ≥ 15 trades and hit rate ≥ 55%
06:30 BRIEFER writes inbox/brief-DATE.md: 3 ideas with the why, the thesis of the week, alerts

The rules live in BRAIN.md at the root of the vault:

you are the research desk of a solo trader.

- every night: link fresh notes to old ones
- backtest every idea before it reaches me
- 06:30: 3 ideas + the thesis of the week
- wake me only if a note contradicts my thesis or an idea scores above 0.90
- never place orders. I decide.

Quickstart

git clone https://github.com/Shelpid/QSB
cd QSB
pip install -e .

qsb init demo --demo                        # a vault with the night from the video
qsb --vault demo night                      # ingest → connect → quant → brief
qsb --vault demo graph -o demo/graph.html   # 3D graph view, open it in a browser

Real output from the demo vault:

Quant Second Brain · demo · 2026-10-10 13:48
READER     5 notes
LISTENER   4 notes
POCKET     3 notes
CONNECTOR  +60 links · 19 strong · 1 contradiction
           [[rental-fleets-memo]] <-> [[capex-cycle]] 0.51
           [[rental-fleets-memo]] <-> [[equipment-rental-fleets-are-running-at-high-mar-2026]] 0.47
           [[transformer-shortage]] <-> [[grid-transformers-have-lead-times-above-two-aug-2026]] 0.47
QUANT      12 ideas tested · 3 kept · 9 rejected
BRIEFER    inbox/brief-2026-10-10.md · 3 ideas · 1 alert
           1. watch power equipment            0.79   n=92 hit 61%
           2. fade EV makers into earnings     0.75   n=84 hit 62%
           3. long AI-chip basket              0.65   n=129 hit 61%
           ! [[grid-power-limits]] contradicts your thesis [[dc-capex-thesis]] (bearish: can't, cap, limits · review before the open)

And the brief it leaves in inbox/ (excerpt):

# 06:30 brief · Sat 10 Oct 2026
Quant Second Brain · 3 ideas to check before the open. Nothing here is an order.

## Ideas
1. **watch power equipment** · confidence 0.79
   - why: [[transformer-shortage]] + [[grid-power-limits]]
   - backtest: n=92 · hit 61% · avg +1.2% · 5d
2. **fade EV makers into earnings** · confidence 0.75
   - why: [[ev-price-cuts]] + [[ev-margin-squeeze]]
   - backtest: n=84 · hit 62% · avg +1.7% · 5d
3. **long AI-chip basket** · confidence 0.65
   - why: [[supplier-call-notes]] + [[dc-capex-thesis]]
   - backtest: n=129 · hit 61% · avg +0.9% · 5d

## Thesis of the week
**[[dc-capex-thesis]]** · 2 supporting notes, 1 contradiction tonight

## Alerts
- ⚠ [[grid-power-limits]] contradicts your thesis [[dc-capex-thesis]]: bearish: can't, cap, limits · review before the open

The demo prices are synthetic (seeded random walks, three of them with a little structure so there is something to find). They are there to show the mechanics, not to say anything about any market.

The graph

qsb graph exports the whole vault as a single HTML file: topics are hubs, tonight's notes glow lime, theses are mint, ideas violet, contradictions pink. Drag to rotate, hover for titles. The vault itself is plain markdown with [[wikilinks]], so Obsidian's graph view and backlinks work on it too.

qsb graph export of the demo vault

Your own vault

qsb init                 # creates ./vault (or pass a path, or set QSB_VAULT)
vault/
  BRAIN.md     the rules
  qsb.yaml     thresholds, topics, notifications
  raw/         drop zone: anything you read, hear or capture
  notes/       written by READER / LISTENER / POCKET, linked by CONNECTOR
  theses/      what you believe right now
  ideas/       trade ideas with a testable signal
  inbox/       the 06:30 brief
  prices/      one CSV per ticker or basket (Date, Close)
  .qsb/        state, log.md, graph.json, quant.json

A thesis is a note in theses/ with a stance. Fresh notes that are close to it and read the other way get flagged:

---
type: thesis
stance: bull            # bull: the thesis expects growth; bear: it expects decline
---
# Data-center capex keeps compounding

Hyperscalers keep raising data center capex. GPU, networking and memory suppliers ride the build-out through 2027.

An idea is a note in ideas/ with a signal QUANT can test:

---
type: idea
ticker: CHIPS           # prices/CHIPS.csv
direction: long         # long | short
signal: pullback        # see the table below
params: {sma: 50, lookback: 20, depth: 0.04}
horizon: 5              # trading days
theses: [dc-capex-thesis]
---
# long AI-chip basket

Buy dips in the AI-chip basket while data center capex keeps compounding.

Prices: put any Date,Close CSV in prices/, or pip install -e ".[prices]" and call qsb.quant.fetch_prices(vault, "SPY") to pull 10 years of daily closes with yfinance.

signal fires when params (defaults)
pullback above its SMA and down depth from the lookback-day high sma 50, lookback 20, depth 0.05
breakout close at a new lookback-day high lookback 55
rsi_below / rsi_above RSI under / over level period 14, level 30 / 70
sma_cross_up / sma_cross_down fast SMA crosses the slow one fast 20, slow 100
momentum lookback-day return above min lookback 20, min 0.05
drawdown depth below the lookback-day high lookback 252, depth 0.2

Trades never overlap (after a signal QUANT skips horizon days), so n counts independent trades. Confidence is 0.15 + 0.45·edge + 0.15·size + 0.25·support, where edge is how far the hit rate beats 50% (capped at 70%), size is n/50 (capped at 1), and support is how close tonight's notes are to the idea.

Run it every night

macOS / Linux (crontab -e):

0 3 * * *  cd ~/QSB && QSB_VAULT=~/vault qsb night >> ~/vault/.qsb/cron.log 2>&1

Windows:

schtasks /create /tn "Quant Second Brain" /sc daily /st 03:00 /tr "cmd /c qsb --vault %USERPROFILE%\vault night"

Your phone

  • POCKET: create a bot with @BotFather, set QSB_TELEGRAM_TOKEN, run qsb pocket, send the bot a message, and it prints your chat id. Set QSB_TELEGRAM_CHAT to it and keep qsb pocket running. Texts and voice notes land in raw/ and go into tonight's run. Messages from any other chat are ignored.
  • Alerts: set QSB_NTFY_TOPIC (any private topic name on ntfy.sh) and/or the two Telegram variables. qsb night pushes only contradictions and ideas above 0.90; everything else waits in the brief.

Optional extras

pip install -e ".[llm]"      # set ANTHROPIC_API_KEY: a model judges contradictions and writes the thesis of the week
pip install -e ".[audio]"    # faster-whisper: transcribe podcasts and voice notes locally
pip install -e ".[pdf]"      # read PDFs dropped into raw/
pip install -e ".[prices]"   # yfinance price downloads

Without them everything still runs: the connector uses TF-IDF and a keyword lexicon, and LISTENER reads transcripts.

Commands

qsb init [DIR] [--demo]   create a vault
qsb night                 ingest → connect → quant → brief (--no-llm, --no-push)
qsb ingest | connect | quant
qsb add "text"            capture an idea into raw/
qsb pocket                Telegram capture bot
qsb graph [-o FILE]       3D graph view
qsb status                what's in the vault

The concept video

ingest, connect, quant, brief, alert

21 seconds, one night: docs/quant-second-brain-720p.mp4.

What Quant Second Brain is not

  • Not financial advice and not a signal service. It hands you ideas to check, with the notes and the backtest behind them.
  • It never places orders. You decide.
  • A backtest is history, not a forecast. The demo prices are synthetic.
  • Without an LLM, the contradiction check is a keyword heuristic: read the flagged note before you act on the flag.

Development

pip install -e ".[dev]"
pytest

MIT License.

About

Quantum Second Brain

Resources

Stars

2 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages