data + AI
MyStockTracker
# Overview
MyStockTracker is a private, single-user stock and investment tracker at mystocktracker.org. It's a ledger and journal, not a broker: it records what I own and what I paid, tracks prices and alerts, and keeps a dated journal of notes. It never places, routes, or requests trades.
It also has a small, documented API that lets an AI assistant read the state of the portfolio and write journal notes, which turns a daily portfolio check into a short written briefing.
# How it works
- Watchlist: tickers with price, daily change, and a 30-session sparkline.
- Portfolio lots: each buy is recorded as a lot with shares, price paid, date, and an optional note. Lots roll up into per-ticker totals with average cost and gain or loss.
- Cash and book value: ledger cash plus holdings value gives the total book.
- Alerts: price-above, price-below, and day-move alerts. Each shows how close it is to firing: watch, approaching (within 5% of a price line), or hit.
- Rules: a per-ticker policy (hold, wait for a price, or do not add) so notes and decisions stay consistent with the plan.
- Calendar: upcoming earnings reports and ex-dividend dates for the next 45 days.
- Daily marks: stored daily portfolio snapshots, so today can be compared with the last mark, including the biggest movers.
- Journal: dated notes, either written by hand or added by the assistant, each one tagged with its source.
The assistant API
The site publishes a plain-language contract that an AI assistant follows:
- Read one snapshot of the book: totals, holdings, watchlist, alerts with proximity, rules, calendar, and recent notes.
- Write one short, plain-English note grounded only in that snapshot.
- Change alerts or rules, or record a lot, only when the owner asks.
The contract has guardrails built in: never give buy or sell orders or price targets, follow the owner's rules, don't post repeat notes, and don't poll in a loop. Recording a lot is ledger-only. The lot and its cash change are written in one database transaction, and nothing is written if there isn't enough ledger cash.
# Tech stack
- App: Node.js, Express, and server-rendered EJS pages.
- Data: SQLite for the watchlist, lots, quotes, price history, alerts, alert events, journal, rules, daily snapshots, and sessions.
- Market data: delayed, unofficial Yahoo Finance quotes through the
yahoo-finance2library, cached with time limits. - Background work: a scheduled timer on the server runs periodic tasks.
- Time zone: dates are shown in US Central time.
# Security design
- Private by default: every page sits behind a login. The app is built for a single user.
- Login protection: credentials are compared in constant time, repeated failed logins are locked out for 15 minutes, and post-login redirects are limited to the site itself.
- Sessions: stored in the app's own database, so they last through restarts and deploys, with a fixed 7-day lifetime.
- The assistant's access: the assistant uses its own separate token, checked in constant time, and never uses the human login. The API is turned off unless that token is configured.
- Least privilege for the assistant: it can read the snapshot and write notes, alerts, rules, and ledger-only lots. It can't create watchlist entries, can't call internal maintenance tasks, and has no connection to any broker.
- Input validation: tickers are checked against the quote source before they're stored, share counts and prices must be positive, trade dates must be real dates that aren't in the future, and text fields have length limits.
- Secrets: stored outside the code, and kept out of the repository and out of journal notes.
# What it shows
- Statistics and data: average cost, unrealized gain and loss, day change, and how close alerts are to firing.
- Interfaces: a dashboard for me, plus a machine-readable contract for an AI assistant.
- AI with guardrails: the assistant observes and writes notes, and the human decides.
# Links
- Site: mystocktracker.org (private, login required)
- Source: private