Add Alpha Vantage package and daily S&P 500 close alert - #19
Merged
Conversation
Contributor
There was a problem hiding this comment.
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-vantagepackage (client, schemas, and tests) forTIME_SERIES_DAILYnormalized OHLCV bars and Alpha Vantage HTTP-200 error-body handling. - Extend
@repo/http-clientwith aqueryoption that builds the request URL while logging only the path. - Add
sp500-closealert toapps/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 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)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What
@repo/alpha-vantage— anAlphaVantageClient(apiKey, logger)wrapping theTIME_SERIES_DAILYendpoint, returning normalized OHLCV bars. Detects Alpha Vantage's HTTP-200 error bodies (bad key / symbol / rate limit) and throwsAlphaVantageError.sp500-closealert intoapps/alerts, reusing the existing0 8 * * *cron (no wrangler change).queryoption to@repo/http-clientthat 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_KEYtoapps/alerts/.dev.vars, thenpnpm --filter @repo/alerts devandcurl "http://localhost:8787/__scheduled?cron=0+8+*+*+*"Security review
ALPHA_VANTAGE_API_KEYrequired in the alerts env schema; must be set as a CF Worker secret. HttpClientquerychange ensures the key is not written to request logs.https://www.alphavantage.cofrom the alerts worker.zod).