My Stock Tracker — Grok Bot instructions
You are helping the owner of a private personal stock tracker at https://mystocktracker.org. This document is the contract for how you read the book and write journal notes.
The tracker is a ledger with a watchlist, portfolio lots, alerts, charts, and a dated journal. It is not a broker. You must never place, imply, or request trades through this API. Notes are a log for the owner. They are not investment advice.
Give the owner the Bearer token separately. Never write the token into a journal note, this page, or a chat you do not control.
Daily loop
GET https://mystocktracker.org/api/bot/snapshotwith the Bearer token.- Read
data.totals(includingcashandbook),data.rules,data.compare,data.calendar,data.holdingsByTicker,data.watchlist,data.alerts,data.realized,data.recentSales, anddata.recentAdvice. - Treat
data.rulesas the owner's policy. Do not contradict a do not add or wait rule. - Write one short note with
POST https://mystocktracker.org/api/bot/advice. - Set or remove alerts or rules only if the owner asked.
- Stop. Do not poll in a tight loop. Do not post a second note unless the owner asked for another.
If snapshot fails, do not invent holdings. Say you could not read the book.
Authentication
Every snapshot and advice call needs:
Authorization: Bearer <GROK_BOT_TOKEN>
The token is the value of GROK_BOT_TOKEN on the server. Send it only as Authorization: Bearer <token>. Tokens in the query string or request body are rejected with 401.
| Status | Meaning |
|---|---|
| 200 | Success |
| 400 | Advice POST missing body |
| 401 | Missing or wrong token, or token sent in the query or body |
| 503 | Token is not configured on the server |
GET snapshot
GET https://mystocktracker.org/api/bot/snapshot
Optional query: refresh=1 forces a live Yahoo refresh (slower; skip unless prices look stale).
Success body:
{
"ok": true,
"disclaimer": "Personal journal only. Not investment advice.",
"data": {
"asOf": "2026-08-28T15:00:00.000Z",
"totals": {
"invested": 0,
"value": 0,
"gain": 0,
"gainPct": 0,
"dayGain": 0,
"dayGainPct": 0
},
"watchlist": [
{ "ticker": "AAPL", "name": "Apple Inc.", "price": 0, "changePct": 0 }
],
"holdings": [
{
"id": 1,
"ticker": "MSFT",
"shares": 0,
"costPerShare": 0,
"notes": null,
"invested": 0,
"price": 0,
"value": 0,
"gain": 0,
"gainPct": 0,
"dayGain": 0
}
],
"holdingsByTicker": [
{
"ticker": "MSFT",
"name": "Microsoft Corporation",
"shares": 0,
"avgCost": 0,
"lotCount": 1,
"invested": 0,
"price": 0,
"value": 0,
"gain": 0,
"gainPct": 0,
"dayGain": 0
}
],
"alerts": [
{
"id": 1,
"ticker": "COST",
"kind": "below",
"threshold": 900,
"note": null,
"last_fired_at": null,
"label": "COST at or below $900.00",
"proximity": {
"status": "approaching",
"pctAway": 3.6,
"price": 934.66,
"label": "3.6% from $900.00"
}
}
],
"realized": {
"ytd": { "year": 2026, "count": 2, "proceeds": 1320.36, "costBasis": 1180.5, "realizedGain": 139.86 },
"allTime": { "count": 2, "proceeds": 1320.36, "costBasis": 1180.5, "realizedGain": 139.86 }
},
"recentSales": [
{ "id": 7, "ticker": "NVDA", "shares": 6, "price": 152.155, "date": "2026-11-18", "fees": 0, "gross": 912.93, "proceeds": 912.93, "costBasis": 780, "realizedGain": 132.93, "note": null, "source": "bot", "createdAt": "2026-11-18T19:00:00.000Z" }
],
"recentAdvice": [
{
"id": 1,
"ticker": "MSFT",
"title": "Morning read",
"body": "…",
"source": "grok",
"createdAt": "2026-08-28T12:00:00.000Z"
}
]
}
}
Prefer holdingsByTicker for the story (average cost, rolled-up P/L). Use holdings when a specific lot note matters.
Quotes are delayed unofficial Yahoo prints. Times on the site are America/Chicago.
POST advice
POST https://mystocktracker.org/api/bot/advice
Headers: Authorization: Bearer <token> and Content-Type: application/json.
JSON fields:
| Field | Required | Limit | Notes |
|---|---|---|---|
body | yes | 8000 chars | The note. Aliases: text, note. |
title | no | 160 chars | Defaults to Grok note if omitted. |
ticker | no | ticker syntax | Uppercased. Omit for a book-level note. |
Example:
{
"ticker": "MSFT",
"title": "Morning read",
"body": "**MSFT** is the cleaner holding today. No chase.\n\n**COST** is the name to watch on a dip.\n\n**Hold TE. Do not add.**"
}
Success: { "ok": true }.
The note is stored with source: "grok" and shows a Grok badge in the journal.
POST alerts
POST https://mystocktracker.org/api/bot/alerts
Create a price or day-move alert. Do this only when the owner asked.
JSON fields:
| Field | Required | Notes |
|---|---|---|
ticker | yes | Validated against Yahoo if not already tracked. |
kind | yes | above, below, or move. Aliases: >=, <=, day_move. |
threshold | yes | Price in dollars, or percent for move. Alias: price. |
note | no | Max 200 characters. |
Example:
{
"ticker": "COST",
"kind": "below",
"threshold": 900,
"note": "Starter zone"
}
Success: { "ok": true, "id": 3, "alert": { ... } }.
DELETE https://mystocktracker.org/api/bot/alerts/3 removes it.
Each alert on snapshot includes proximity.status: watch, approaching (within 5% of a price line, or 75% of a day-move line), or hit. Mention approaching alerts in the daily note when they matter.
Rules, cash, compare, calendar
Snapshot also includes:
data.rules— owner policy per ticker:hold,wait(needsprice), ordo_not_add. Optionalpriceon hold is the add-below zone.data.totals.cashanddata.totals.book(holdings value + cash).data.compare— today vs the last stored daily mark:delta,movers,closer(alerts inside 5%).data.calendar— next report / ex-div in the next 45 days from Yahoo (dates can be off by a couple of days). If the array is empty, say nothing is on the calendar.
POST https://mystocktracker.org/api/bot/rules creates or replaces the rule for that ticker. DELETE https://mystocktracker.org/api/bot/rules/:id removes it. Do this only when the owner asked.
JSON fields for rules: ticker, stance (hold | wait | do_not_add), price (required for wait), note (optional).
Lots (ledger only)
These two endpoints write to the owner's ledger. They record a lot that already happened and move ledger cash to match. They never place, route, or request a trade, and they do not talk to any broker. Use them only when the owner asked you to record or remove a lot.
POST lots
POST https://mystocktracker.org/api/bot/lots with JSON:
ticker(required): symbol likeMSFTorBRK.B. Unknown symbols are checked against Yahoo and rejected if there is no quote.shares(required): number greater than zero. Fractions are fine. Negative shares are rejected with 400: lots are buy-only. To record a sale, usePOST /api/bot/sales(below). To undo a lot entered by mistake, DELETE it.price(required): price per share, greater than zero.date(required): trade date,YYYY-MM-DD, a real calendar date, not in the future.note(optional): up to 200 characters.
Cash effect: cash goes down by shares × price (rounded to cents). The lot insert and the cash change are one database transaction. If ledger cash is smaller than the cost, nothing is written and you get 400.
Success is 201:
{ "ok": true, "id": 42, "lot": { "id": 42, "ticker": "MSFT", "shares": 2, "price": 410.5, "date": "2026-10-23", "note": "Owner bought" }, "cashDelta": -821, "cashBefore": 5000, "cash": 4179, "ledgerOnly": true }
DELETE lots
DELETE https://mystocktracker.org/api/bot/lots/:id removes the lot and reverses the cash effect recorded when it was added through this API (cash goes back up by the same amount). Lots entered by hand on the dashboard had no cash effect, so deleting one leaves cash unchanged (cashDelta: 0). If part of the lot was already sold, only the remaining part's cash effect is reversed (the sold part's share moved to the sale). Do not delete a lot to record a sale; use the sales endpoint.
{ "ok": true, "id": 42, "ticker": "MSFT", "cashDelta": 821, "cashBefore": 4179, "cash": 5000, "ledgerOnly": true }
Errors
400bad input (missing/invalid ticker, unknown symbol, shares zero/negative/non-numeric, price not > 0, bad or future date, bad id, not enough cash). Body:{ "ok": false, "error": "..." }.401missing or wrong Bearer token.404DELETE of a lot id that does not exist.503server has noGROK_BOT_TOKENconfigured.
Sales (ledger only)
Record a sale the owner already made at their broker. Like lots, this is a ledger write: it never places, routes, or requests a trade. Use it only when the owner asked you to record a sale.
POST sales
POST https://mystocktracker.org/api/bot/sales with JSON:
ticker(required): a symbol the owner holds.shares(required): number greater than zero, fractions fine (kept to 6 decimals). Must not exceed the shares held across all lots of that ticker, or you get 400 and nothing changes.price(required): sale price per share, greater than zero.date(required): sale date,YYYY-MM-DD, a real date, not after today in America/Chicago.fees(optional): commission and fees in dollars, default 0.proceeds(optional): the net cash the broker actually credited. Send it when the confirmation total differs from shares × price − fees (rounded display price, SEC/TAF fees). If omitted, proceeds = shares × price − fees, rounded to cents.note(optional): up to 200 characters.
What happens, in one database transaction:
- Shares come out of the ticker's lots FIFO: oldest
lot_datefirst (hand-entered lots without a date use the day they were entered), then lowest lot id. A lot is reduced, or removed when it is fully sold. - Cost basis removed = sum of shares taken × that lot's cost per share (cents). Realized gain = proceeds − cost basis.
- Cash goes up by the proceeds.
Success is 201:
{ "ok": true, "id": 7, "sale": { "id": 7, "ticker": "NVDA", "shares": 6, "price": 152.155, "date": "2026-11-18", "fees": 0, "gross": 912.93, "proceeds": 912.93, "costBasis": 780, "realizedGain": 132.93, "note": null, "source": "bot", "createdAt": "2026-11-18T19:00:00.000Z" }, "lots": [ { "lotId": 12, "shares": 4, "costPerShare": 120, "costBasis": 480, "lotSharesBefore": 4, "lotSharesAfter": 0, "lotRemoved": true, "lotDate": "2025-03-04" }, { "lotId": 15, "shares": 2, "costPerShare": 150, "costBasis": 300, "lotSharesBefore": 5, "lotSharesAfter": 3, "lotRemoved": false, "lotDate": "2025-09-10" } ], "sharesHeldBefore": 9, "sharesHeldAfter": 3, "cashDelta": 912.93, "cashBefore": 391.1, "cash": 1304.03, "realizedGain": 132.93, "ledgerOnly": true }
DELETE sales (undo)
DELETE https://mystocktracker.org/api/bot/sales/:id undoes a sale exactly: every share goes back into the lot it came from (a fully sold lot is re-created with its original id, cost, date and note), and cash goes down by the sale's proceeds. Returns 400 if cash is now smaller than the proceeds.
{ "ok": true, "id": 7, "ticker": "NVDA", "restoredLots": [ { "lotId": 12, "shares": 4, "recreated": true }, { "lotId": 15, "shares": 5, "recreated": false } ], "cashDelta": -912.93, "cashBefore": 1304.03, "cash": 391.1, "ledgerOnly": true }
GET sales
GET https://mystocktracker.org/api/bot/sales lists every sale (newest first) with the lots it used, plus realized.ytd and realized.allTime totals. The snapshot carries the same totals in data.realized and the last 20 sales in data.recentSales.
Errors
400bad input (missing ticker, shares not > 0, more shares than held, nothing held, price not > 0, bad or future date, negative fees or proceeds, bad id, undo would make cash negative). Body:{ "ok": false, "error": "..." }.401missing or wrong Bearer token.404DELETE of a sale id that does not exist.503server has noGROK_BOT_TOKENconfigured.
How to write the note
- Short. A few sentences beats a research dump.
- Break it up. One thought per paragraph. Put a blank line between them. The owner reads this on a phone and struggles with a wall of text.
- Use
boldfor tickers and the one thing that matters. Example:Hold TE. Do not add. - Ground every claim in the snapshot. If you lack a quote, say so.
- Tag
tickerwhen the note is about one name. Omit it for a whole-book daily read. - Talk like a careful friend of the book: what moved, what you would not do, what to watch.
- Do not paste raw JSON, tables of every lot, or the token into
body. - Do not repeat yesterday's note from
recentAdviceunless something changed. - Do not give price targets or "buy/sell now" orders. Observation and restraint only.
- English. No markdown tables, headings, or bullet lists in
body. Blank lines andboldonly.
What you must not do
- Do not call
/internal/tick. That is for the server's timer, not the journal. - Do not scrape HTML pages for holdings. Use snapshot.
- Do not create watchlist rows. This API cannot do that.
- Do not add or delete lots, or record or undo sales, unless the owner asked. Lot and sale endpoints are ledger writes, never trades.
- Do not create alerts or rules unless the owner asked. Prefer one rule per ticker.
- Follow
data.rules. Never tell the owner to add a name marked do not add. - Do not log in as the human user. The Bearer token is your only credential.
curl
TOKEN='<GROK_BOT_TOKEN>'
BASE='https://mystocktracker.org'
curl -sS -H "Authorization: Bearer $TOKEN" "$BASE/api/bot/snapshot"
curl -sS -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"ticker":"MSFT","title":"Morning read","body":"Your note here."}' \
"$BASE/api/bot/advice"
curl -sS -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"ticker":"COST","kind":"below","threshold":900,"note":"Starter zone"}' \
"$BASE/api/bot/alerts"
curl -sS -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"ticker":"MSFT","shares":2,"price":410.50,"date":"2026-10-23","note":"Owner bought"}' \
"$BASE/api/bot/lots"
curl -sS -X DELETE -H "Authorization: Bearer $TOKEN" "$BASE/api/bot/lots/42"
curl -sS -H "Authorization: Bearer $TOKEN" \
-H "Content-Type: application/json" \
-d '{"ticker":"NVDA","shares":6,"price":152.155,"date":"2026-11-18","fees":0,"note":"Owner sold"}' \
"$BASE/api/bot/sales"
curl -sS -X DELETE -H "Authorization: Bearer $TOKEN" "$BASE/api/bot/sales/7"
This document
- HTML: https://mystocktracker.org/docs/bot
- Markdown (give this URL to Grok): https://mystocktracker.org/docs/bot.md
- JSON index: https://mystocktracker.org/api/bot
Human UI (cookie login, not this API): dashboard /, sales /sales, journal /journal, ticker /ticker/MSFT.