From d3c5340f9baf956c975025a85cb765d140b34c99 Mon Sep 17 00:00:00 2001 From: caty21 Date: Mon, 29 Jun 2026 17:43:49 +0200 Subject: [PATCH] =?UTF-8?q?feat:=20march=C3=A9s=204H=20+=20lien=20TradingV?= =?UTF-8?q?iew=20+=20cache=20IL=20+=20perf=20chargement?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - charts Marchés : interval D/W → 4H (240), hauteur 220 → 420px, grid 2col - TvAdvancedChart : bouton "↗ TradingView" par chart (outils tracé complets) - cache fichier IL 2h (data/il-enrichment-cache.json) : API rate-proba 13s → <500ms - stale-while-revalidate macro : affiche cache immédiatement, refetch 10s background - seuil cache rate-proba : 48h → 7j pour dev local Co-Authored-By: Claude Sonnet 4.6 --- app/page.tsx | 8 ++++---- components/TvChart.tsx | 29 ++++++++++++++++++++++++----- lib/rateprobability.ts | 30 +++++++++++++++++++++++++++--- 3 files changed, 55 insertions(+), 12 deletions(-) diff --git a/app/page.tsx b/app/page.tsx index 7fa1765..d59bd11 100644 --- a/app/page.tsx +++ b/app/page.tsx @@ -599,10 +599,10 @@ export default function Dashboard() {
- - - - + + + +
)} diff --git a/components/TvChart.tsx b/components/TvChart.tsx index 1c6b1ed..96c64e8 100644 --- a/components/TvChart.tsx +++ b/components/TvChart.tsx @@ -84,13 +84,16 @@ export function TvAdvancedChart({ backgroundColor: "rgba(8,12,20,0)", gridColor: "rgba(30,45,61,0.5)", hide_top_toolbar: false, + hide_side_toolbar: false, hide_legend: false, allow_symbol_change: false, calendar: false, hide_volume: false, isTransparent: true, save_image: true, + withdateranges: true, drawings_access: { type: "all" }, + support_host: "https://www.tradingview.com", container_id: containerId, }, height @@ -102,13 +105,29 @@ export function TvAdvancedChart({ }; }, []); // eslint-disable-line + const tvUrl = `https://www.tradingview.com/chart/?symbol=${encodeURIComponent(symbol)}&interval=${interval}`; + return (
- {label && ( -

- {label} -

- )} +
+ {label && ( +

{label}

+ )} + + + + + + + TradingView + +
{ + try { + const raw = readFileSync(IL_CACHE_FILE, "utf8"); + const cached = JSON.parse(raw) as { ts: number; data: ILExpectationsWithHistory }; + if (Date.now() - cached.ts < IL_CACHE_TTL) { + console.log(`[IL-cache] HIT (${Math.round((Date.now() - cached.ts) / 60000)}min old)`); + return cached.data; + } + console.log("[IL-cache] STALE — refetch"); + } catch { + console.log("[IL-cache] MISS — premier fetch"); + } + const data = await fetchILExpectationsWithHistory(); + try { + writeFileSync(IL_CACHE_FILE, JSON.stringify({ ts: Date.now(), data })); + } catch { /* /tmp read-only en prod Vercel — ignoré */ } + return data; +} // ── Types publics ────────────────────────────────────────────────────────────── @@ -291,7 +315,7 @@ function parseCBBody(ccy: Currency, body: Record): CBRatePath | export async function fetchAllCBPaths(): Promise { // GitHub Actions met à jour data/rate-probabilities.json toutes les heures // (CME FedWatch pour USD, Investing.com pour les autres, InvestingLive en fallback) - const [ilHistory] = await Promise.all([fetchILExpectationsWithHistory()]); + const [ilHistory] = await Promise.all([getCachedILHistory()]); const ilData = ilHistory.current; const ilPrev = ilHistory.prev; const prevDate = ilHistory.prevDate;