phase-8f: persistant cache locally
This commit is contained in:
@@ -553,7 +553,7 @@ This section is the single reference for where code lives and how to add feature
|
||||
- Class instances don't survive `JSON.stringify`. Call `getDisplayMetrics()` server-side before returning from API routes (see `serializeAssets()` in `screener.controller.ts`).
|
||||
- Controllers use constructor injection — dependencies are wired in `server/app.ts`, not created inside handlers.
|
||||
- The `$types` alias in the UI resolves to `server/types/` — use it instead of duplicating type definitions.
|
||||
- Ticker normalisation (`BRK.B → BRK-B`) currently only happens in `FinanceController.normalizeYahoo()`. Submitting `BRK.B` directly to `/api/screen` will fail. Fix target: move normalisation into `YahooFinanceClient.fetchSummary()`.
|
||||
- Ticker normalisation (`BRK.B → BRK-B`) happens in `YahooFinanceClient.normalise()` and applies to all callers via `fetchSummary()` and `fetchCalendarEvents()`.
|
||||
|
||||
### Adding a new scoring metric — step-by-step
|
||||
|
||||
@@ -622,17 +622,6 @@ Add one Fastify `inject()` smoke test per route using a fixture for `ScreenerEng
|
||||
|
||||
`MarketCallRepository` has zero test coverage. Add `tests/MarketCallRepository.test.js` using a temp file path (inject via constructor or env var) to test `list`, `create`, `delete`, and concurrent-write safety.
|
||||
|
||||
#### 8e — Ticker normalisation in `YahooFinanceClient`
|
||||
|
||||
`BRK.B → BRK-B` normalisation lives only in `FinanceController`. Move it to `YahooFinanceClient.fetchSummary()` so it applies to all callers including `/api/screen`.
|
||||
|
||||
```ts
|
||||
async fetchSummary(ticker: string, ...): Promise<any> {
|
||||
const normalized = ticker.replace(/\./g, '-');
|
||||
return await this.lib.quoteSummary(normalized, { modules: YAHOO_MODULES });
|
||||
}
|
||||
```
|
||||
|
||||
#### 8f — Persistent benchmark cache
|
||||
|
||||
`BenchmarkProvider`'s 1-hour cache is in-memory only — cold start after every restart adds 2–4s latency to the first request. Write the cached `MarketContext` to `.benchmark-cache.json` (or a single-row SQLite table). Read it on boot; only re-fetch if stale.
|
||||
|
||||
Reference in New Issue
Block a user