stock-portfolio-tracker
Daily portfolio tracker. Reads your stock holdings from a Google Sheet, fetches current prices from Yahoo Finance, appends a row per ticker to a Prices history tab, appends a daily summary to a Summary tab, computes total value and profit/loss, and emails a digest to the owner. Builds a searchable price history over time. Cross-platform — uses the python runtime InTouch auto-creates on every OS.
Use case
The existing stock-price-report workflow emails current prices once and forgets them. The upgrade: keep the data. With every run appending to a Prices Sheet, you build a year-over-year price history searchable inside Sheets (graph it, pivot it, export it). The Summary tab gives you a single row per day with total portfolio value and P&L, perfect for a line chart of net worth over time.
Holdings live in a Sheet you control. Add a row to buy, remove a row to sell, edit the cost basis. The next run picks up the change automatically.
Setup
- Credentials (Credentials view):
-
google-workspace— Google Workspace service-account JSON - Runtime environment (Runtime Environments view):
-
python— auto-created by InTouch on every OS install - Portfolio Sheet (one-time):
- Create a new Sheet with three tabs:
Portfolio(3 cols):ticker | qty | cost_basis— your holdings; you maintain thisPrices(4 cols):date | ticker | price | currency— the workflow appends here; one row per ticker per runSummary(5 cols):date | total_value | total_cost | profit_loss | pct_change— the workflow appends here; one row per run- Row 1 of each tab is the header.
- Populate
Portfoliowith your tickers, share counts, and cost bases (e.g.AAPL | 100 | 180.50). - Copy the spreadsheet ID from the URL.
- Edit
workflow.yaml— replace the two placeholders: -<<PORTFOLIO_SHEET_ID>>— spreadsheet ID -<<OWNER_PUBLISHER>>— your contact user name (for the digest) - Schedule the workflow daily, 4:30 PM in your timezone (after US market close).
Pipeline
- track —
runtimeenv(python). ReadsPortfolio!A2:C, fetches each ticker's current price from Yahoo Finance (query1.finance.yahoo.com/v8/finance/chart/<SYM>), appends allPricesrows in one Sheets call, appends the daily summary toSummary, prints a formatted digest to stdout. - notify —
message. Pipes{{track.stdout}}to your owner contact.
Sample digest
PORTFOLIO — 2026-05-10
Total value: $ 142,587.20
Total cost: $ 115,800.00
Profit / loss: $ +26,787.20 (+23.13%)
BY POSITION
AAPL qty=100 @ $ 201.45 value=$ 20,145.00 day +1.23%
MSFT qty=50 @ $ 442.10 value=$ 22,105.00 day +0.45%
GOOGL qty=30 @ $ 178.92 value=$ 5,367.60 day -0.81%
NVDA qty=80 @ $ 892.30 value=$ 71,384.00 day +2.14%
...
Customization
- Schedule frequency — daily 4:30 PM is the default (after-close prices). Hourly during market hours is fine too; just be aware each run hits Yahoo Finance once per ticker.
- Different data source — Yahoo Finance is free and unauthenticated but rate-limited. For higher reliability or international tickers, swap the
fetch_pricefunction to use Polygon, Alpha Vantage, Tiingo, IEX Cloud, or your broker's API. - Multi-currency — add a currency-conversion call after fetching each ticker's local price (FX rates from any of the providers above, or ECB), then store in your home currency in the Summary tab.
- Crypto — Yahoo Finance accepts crypto tickers (
BTC-USD,ETH-USD). Add them to the Portfolio tab the same way. - Cost-basis updates from broker — if you maintain a separate Sheet of buy/sell transactions, you can recompute cost basis automatically via a Sheets formula in the Portfolio tab's
cost_basiscolumn. - Alerts on big moves — branch in the python script: if a position's day_change_pct exceeds threshold, send a separate alert message.
- Charting — insert a chart in the Summary tab plotting
datevstotal_value— Sheets handles this natively, no extra automation needed.
Differences from stock-price-report
stock-price-report |
stock-portfolio-tracker |
|
|---|---|---|
| Data persistence | None — emails once and forgets | Two history tabs (Prices, Summary) accumulate every day |
| Source of holdings | YAML-embedded ticker list | Portfolio tab in a Sheet (editable, no YAML changes) |
| P&L calculation | None | Total value, total cost, day-over-day change, % gain |
| Charting | None | Native Sheets charts on the Summary tab |
| Runtime cost | Email send only | Email send + N Sheets writes per day (negligible) |
Verified
gog sheets get/append, Yahoo Finance v8 chart endpoint, and the variadic pipe-separated cell format for sheets append all verified against the bundled gog v0.19.0 (2026-06-01) for flag/command syntax (re-verify output shapes on first run) and the existing stock-price tool's Yahoo Finance pattern. Cross-platform Python runtime confirmed in Server.kt:265-266.
Source
See workflow.yaml.