Skip to content

Add Alpha Vantage package and daily S&P 500 close alert - #19

Merged
valuecodes merged 1 commit into
mainfrom
alpha-vantage
Jul 12, 2026
Merged

Add Alpha Vantage package and daily S&P 500 close alert#19
valuecodes merged 1 commit into
mainfrom
alpha-vantage

Conversation

@valuecodes

Copy link
Copy Markdown
Owner

What

  • We need to pull ETF timeseries (S&P 500 / Nasdaq-100) for future alerts; there was no market-data client.
  • Adds @repo/alpha-vantage — an AlphaVantageClient(apiKey, logger) wrapping the TIME_SERIES_DAILY endpoint, returning normalized OHLCV bars. Detects Alpha Vantage's HTTP-200 error bodies (bad key / symbol / rate limit) and throws AlphaVantageError.
  • Wires a sample sp500-close alert into apps/alerts, reusing the existing 0 8 * * * cron (no wrangler change).
  • Adds a query option to @repo/http-client that builds the URL but keeps params out of the logged path, so API keys never reach logs.

How to test

pnpm typecheck
pnpm lint
pnpm format:check
pnpm test
Recommended: add ALPHA_VANTAGE_API_KEY to apps/alerts/.dev.vars, then pnpm --filter @repo/alerts dev and curl "http://localhost:8787/__scheduled?cron=0+8+*+*+*"

Security review

  • Secrets / env vars: new ALPHA_VANTAGE_API_KEY required in the alerts env schema; must be set as a CF Worker secret. HttpClient query change ensures the key is not written to request logs.
  • Network / API calls: new outbound GET to https://www.alphavantage.co from the alerts worker.
  • Dependencies: new internal workspace package only; no new external deps (reuses existing zod).

Copilot AI review requested due to automatic review settings July 12, 2026 07:39

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

Adds a new internal market-data client (@repo/alpha-vantage) and wires a daily S&P 500 close alert into the alerts worker, alongside a small enhancement to @repo/http-client to support query parameters without leaking secrets into request logs.

Changes:

  • Add @repo/alpha-vantage package (client, schemas, and tests) for TIME_SERIES_DAILY normalized OHLCV bars and Alpha Vantage HTTP-200 error-body handling.
  • Extend @repo/http-client with a query option that builds the request URL while logging only the path.
  • Add sp500-close alert to apps/alerts (env schema, registry wiring, docs, and tests) reusing the existing daily cron.

Reviewed changes

Copilot reviewed 18 out of 19 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pnpm-lock.yaml Lockfile updates for new workspace package and dependency resolution changes.
package.json Adds vite devDependency and updates pnpm.overrides.
apps/operator/package.json Bumps hono dependency version.
packages/http-client/src/types.ts Introduces query?: Record<string, string> request option.
packages/http-client/src/http-client.ts Appends query params to URL while logging only { method, path }.
packages/http-client/src/tests/http-client.test.ts Adds tests for query-string construction and log redaction.
packages/alpha-vantage/package.json Defines new workspace package metadata, exports, scripts, and deps.
packages/alpha-vantage/tsconfig.json TypeScript config for the new package (Vitest globals).
packages/alpha-vantage/eslint.config.ts ESLint config for the new package.
packages/alpha-vantage/vitest.config.ts Vitest config for the new package.
packages/alpha-vantage/src/types.ts Zod schemas + normalization for Alpha Vantage daily timeseries payloads.
packages/alpha-vantage/src/alpha-vantage.ts Implements AlphaVantageClient and AlphaVantageError.
packages/alpha-vantage/src/alpha-vantage.test.ts Unit tests for normalization, query params, and error-body handling.
apps/alerts/package.json Adds dependency on @repo/alpha-vantage.
apps/alerts/src/types/env.ts Requires ALPHA_VANTAGE_API_KEY in env schema.
apps/alerts/src/alerts/sp500-close.ts New daily alert that reports latest SPY close.
apps/alerts/src/alerts/index.ts Registers sp500-close alongside existing alerts.
apps/alerts/src/scheduled.test.ts Updates scheduled tests to cover the additional daily alert.
apps/alerts/README.md Documents the new Alpha Vantage secret and setup steps.
Files not reviewed (1)
  • pnpm-lock.yaml: Generated file

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +114 to +117
const url = mockFetch.mock.calls[0]?.[0] as string;
expect(url).toBe(
"https://api.example.com/query?function=TIME_SERIES_DAILY&symbol=SPY&apikey=sk_1"
);
Comment thread package.json
Comment on lines +30 to +34
"esbuild": ">=0.28.1",
"undici": ">=7.28.0",
"ws": ">=8.21.0",
"js-yaml": ">=4.2.0",
"@babel/core": ">=7.29.6"
volume: Number(bar["5. volume"]),
})
)
.sort((a, b) => (a.date < b.date ? 1 : -1));
@valuecodes
valuecodes merged commit aca606c into main Jul 12, 2026
8 checks passed
@valuecodes
valuecodes deleted the alpha-vantage branch July 12, 2026 07:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants