r4lph.io

Free Build your own trading journal

Free prompt, from the video "One Prompt Built a Free Trading Journal. Then I Broke It."

The prompt that built my trading journal

Paste it into your AI coding agent. It builds Swing Log, a personal swing trading journal with stop loss and take profit alerts, and puts it online, in three pull requests.

Download prompt.md Free, with no sign-up. Set up the accounts below first.

prompt.md, 89 lines, MIT license GitHub
Build me a personal trading journal called "Swing Log" and put it online. It is for me alone. Do the whole job in this one session. Stop only when a PR is ready to merge.

## Step 1: the journal

Swing Log is a trading journal for my swing trades. Each row is one trade. I log the entry, then close it later with the exit. The journal shows what I made, what I risked, and whether I followed my plan.

Scope, and nothing more:

- Only I can use it. Sign in with Clerk, and make Convex reject every account except mine (`OWNER_EMAIL`).
- Log a trade: symbol, asset type (stock or crypto), side (long or short), quantity, entry price, entry date, fees, the dollars at risk, a setup tag, and a note. Only the symbol, side, quantity, entry price, and entry date are required. The asset type is the only switch. It picks where the live price comes from, and it keeps a stock and a coin with the same ticker apart.
- Close a trade with an exit price, an exit date, and exit fees. Store the realized P&L after fees.
- A trade table with open and closed tabs, sorting, and a search box. Edit and delete from each row.
- Stats for closed trades: net P&L, win rate, average win, average loss, profit factor, and average R (P&L divided by the dollars at risk). Show R only for trades that have a risk.
- An equity curve of cumulative closed P&L.
- A dev seed with 25 sample trades, open and closed, longs and shorts, stocks and crypto, so the stats and the curve have data on localhost. Seed nothing in production.

Stack: TanStack Start, Convex, Clerk, Tailwind, shadcn/ui on Base UI (never Radix), Vite, pnpm, TypeScript, and zod. This folder is the clone of my private GitHub repository `swing-log`. It has only a README and a `.gitignore` on `main`.

### Setup is done

I set up every account by hand before this prompt. Do not ask me for keys, and never print one.

- `.env.local` holds `VITE_CLERK_PUBLISHABLE_KEY`, `CLERK_SECRET_KEY`, `CLERK_FRONTEND_API_URL`, `ALPACA_API_KEY_ID`, `ALPACA_API_SECRET_KEY`, `RESEND_API_KEY`, and `OWNER_EMAIL`. Check that Git ignores it.
- Convex: link this folder to my existing project `swing-log` with `npx convex dev`. The CLI is signed in. Copy the server values into the dev deployment with `npx convex env set`, reading each one from the file.
- Clerk: a development instance, with the Convex integration on.
- Vercel: the project `swing-log` is connected to the repository, and `CONVEX_DEPLOY_KEY` is set for production only.
- Use `gh`, `npx convex`, and `vercel` for everything else. All three are signed in. Never open a dashboard in my browser: print the URL and I open it.
- Check each key with one real call before you build on it: a sign-in, one stock price and one crypto price, and one test email to me. If a key fails, stop and tell me which one and what the service said.
- Write `docs/setup.md`: what each account holds and each variable, so I can do the setup again later.

## Design

Match this mock: https://c4089l5fd2zx.postplan.dev ("Instrument Deck"). Open it in a browser and copy its layout. Leave out its account column. There is no account field.

- Colors: canvas `#0B0E13`, surface `#12161E`, elevated `#181D27`, border `#232A36`, accent `#F59E0B`, ink `#F1F5F9`, profit `#34D399`, loss `#FB7185`. Dark only.
- Fonts: Plus Jakarta Sans for text, JetBrains Mono for numbers. Radius 6, 8, and 12 px. Spacing on a 4 px base.
- Layout: the header has the wordmark, the alerts bell with its unread count, the user menu, and an amber "Log trade" button. Below it, a large equity card with net P&L and the curve sits beside six stat tiles. The trade table comes last. Each open row shows the stop and the target with the distance to each, and a meter for where the live price sits between them.
- Rules:
  1. Every ticker, price, P&L, R value, quantity, and date is in JetBrains Mono with tabular numbers.
  2. Profit and loss always have a + or − sign as well as the color.
  3. Amber is only for the primary action, focus rings, and unread alerts.

## Step 2: stop loss and take profit alerts

Open a second PR after I merge the first.

- A trade gets an optional stop loss and an optional take profit. Check that the stop and the target sit on the right sides of the entry for a long and for a short. When I set a stop, show the dollars at risk and use them for the risk field until I type my own. When I set both, show the reward in R.
- A Convex cron checks open trades with a level once an hour. These are swing trades, so hourly is enough. Get one price per symbol, never one per trade, and make no price calls when no trade has a level.
- All prices come from Alpaca's market data API. Stocks need my paper account key pair. Crypto needs no key. Some coins have no Alpaca price: show "no live price" for them and skip their alerts.
- The price feed fails sometimes. Plan for it now, so an old price never looks live:
  - Stocks and crypto fail on their own. A failed stock request must not stop crypto prices.
  - Store Alpaca's trade time with each price, and show the price's age. A price from the last close must look old.
  - Record each failed check and show it in the app: what failed, when, and when the next check runs.
  - On a 401 or 403, say that Alpaca rejected the key. Do not retry it before the next check.
  - On a 429, wait until the time in `X-Ratelimit-Reset` and try once more. Never fail without a word.
  - Add a "Check now" button with a cooldown, so it cannot spam Alpaca.
- A long hits its stop at or below the stop and its target at or above the target. A short is the mirror image. Each level alerts once. Moving a level arms it again.
- An alert never closes a trade. It tells me, and I close the trade myself.
- Three channels: in the app (always on), a browser notification through Web Push and a service worker (turned on per device), and email (turned on in settings). Make the VAPID keys yourself. Send email through Resend with a plain `fetch`, no new package, from `onboarding@resend.dev` to `OWNER_EMAIL`. That needs no domain, but Resend then delivers only to the email of my Resend account, so `OWNER_EMAIL` must be that address.
- A bell in the header with an unread count opens the alerts. Each alert has "Close at <level>", which opens the close dialog with that price filled in, "Edit levels", and "Dismiss".
- Focused tests for the hit rule, firing once, re-arming, one price call per symbol, and each price feed failure above.

## Step 3: put it online

Open a third PR after I merge the alerts. Set up real CI/CD, so a merge to `main` deploys everything with no manual step.

- Host it on Vercel on its free `.vercel.app` address. The project `swing-log` exists and is connected to the repository.
- Use a Convex production deployment. A production build runs `npx convex deploy` and then builds the site, so each merge to `main` deploys the Convex functions and the site together.
- Vercel cannot detect TanStack Start in this repository, so a plain import serves a 404. Add the Nitro Vite plugin (`nitro/vite`) so the build writes Vercel output. In `vercel.json`, set `"framework": "tanstack-start"` and a build command that runs `npx convex deploy --cmd 'pnpm build' --cmd-url-env-var-name VITE_CONVEX_URL` when `VERCEL_ENV` is `production`, and only `pnpm build` otherwise.
- Preview builds for pull requests must not fail. They use the dev Convex deployment and never deploy Convex.
- `CONVEX_DEPLOY_KEY` is already in Vercel for production only. Do not change it.
- Keep the Clerk development instance. A Clerk production instance needs a domain I own, and this app does not need one.
- Set every other production value with the Vercel and Convex CLIs, reading each one from `.env.local`. Ask me before the first production deploy.
- Prove the pipeline. This PR gets a working preview. When I merge it, show the build log in the terminal with `vercel inspect --logs`, where Convex deploys, then the live URL.
- Check it on the live URL: I sign in, log a trade, set a stop that the next check hits, and get the alert in the app, in the browser, and by email. A second account must be refused.

## Rules

- Do not touch any other project on this computer or in my accounts.
- Never show or log real trades, balances, or P&L from any other app or account.
- Never print a token or put one in a command argument.
- When you finish, report the live URL, the elapsed time from the first start to the last merge, and the number of PRs.

Before you paste the prompt

Everything is free. You need no domain and no paid plan.

AccountWhat to doWhat goes in .env.local
GitHub Create a private repository with a README. Clone it, and add .env* to its .gitignore. Goes in .env.local: Nothing
Convex Create a project. Sign in the CLI with npx convex login. Goes in .env.local: Nothing. The agent links the folder.
Clerk Create an application with email sign-in. Pick TanStack Start for the key names. Turn on the Convex integration. Goes in .env.local: VITE_CLERK_PUBLISHABLE_KEY, CLERK_SECRET_KEY, CLERK_FRONTEND_API_URL
Alpaca Open a free paper trading account and generate an API key. The secret shows once, so copy it now. Goes in .env.local: ALPACA_API_KEY_ID, ALPACA_API_SECRET_KEY
Resend Create an API key with sending access. Goes in .env.local: RESEND_API_KEY
Vercel Import the repository. Create a Convex production deploy key and add it in Vercel as CONVEX_DEPLOY_KEY, for Production only. Goes in .env.local: Nothing. Keep the deploy key out of .env.local.
You Your email. It must be the email of your Resend account and the one you sign in with. Goes in .env.local: OWNER_EMAIL

Install and sign in the CLIs the agent uses: gh, npx convex, and vercel.

Check your Alpaca keys before you start. Crypto needs no key; a stock needs both:

curl -s "https://data.alpaca.markets/v1beta3/crypto/us/latest/trades?symbols=BTC/USD"; echo
set -a; source .env.local; set +a
curl -s -H "APCA-API-KEY-ID: $ALPACA_API_KEY_ID" -H "APCA-API-SECRET-KEY: $ALPACA_API_SECRET_KEY" \
  "https://data.alpaca.markets/v2/stocks/AAPL/trades/latest"; echo

Run it

  1. Open your agent (Claude Code, Codex, T3 Code, Cursor, or another) in the cloned folder.
  2. Paste the prompt. The copy button gives you everything below the line in prompt.md.
  3. Test each step like a user before you merge its pull request. When something is wrong, say what you saw.

Things I learned on camera

  • A price feed can fail without a word. With a wrong Alpaca key, my first build kept showing old prices as if they were live, and the error was only in the browser console. The prompt now asks for a visible price status and the age of each price.
  • Vercel cannot detect TanStack Start in a repository that starts empty, so the first deploy served a blank page. The prompt now sets the framework and the build in vercel.json.
  • Resend without a domain sends only to the email of your Resend account. That is why OWNER_EMAIL must be that address.
  • Some coins have no Alpaca price, for example SUI. The journal says "no live price" and skips its alerts.

This is a personal tool and an experiment in what AI agents can build, not trading advice. The prompt is free to use, change and share.

More free stuff

The code from my trading system tests, free on the same terms.

Pine Script + Python

Mars-Jupiter aspects

The aspect trade lost 0.36% a trade after costs, worse than 84% of random calendars. SPY made 8.7% a year.

Get the code
Python

Tom Basso's trend rules

Before costs, coin-flip entries beat his entry rule. After costs, his system made 0.4% a year. SPY made 10.7%.

Get the code
Pine Script + Python

Gann square of nine

On 50 markets, Gann's levels held about as often as random lines, and no version made money after costs.

Get the code

All free stuff The channel on YouTube

↓