feat: banques centrales (vote+dot plot+previsions), calendrier elargi, fix InvestingLive, M3 auto

Central bank governance (nouvel onglet Banques centrales) :
- lib/centralBankGovernance.ts + app/api/central-bank-sources : scraping live du
  vote de la derniere reunion, dot plot Fed (SEP), et desormais les previsions
  macro (PIB + inflation) publiees par chaque BC elle-meme (Fed SEP, Eurosystem
  staff projections, BoJ Outlook Report PDF, SNB conditional forecast, BoC MPR,
  RBA SMP). GBP/NZD laisses honnetement vides quand aucune source chiffree
  fiable n'est accessible (RBNZ bloque par Cloudflare).
- components/CentralBankSourcesTab.tsx : nouvel onglet avec cards par banque.

Taux directeurs + Money Supply M3 :
- data/rate_decisions.json corrige (JPY, EUR, NZD etc. etaient perimes d'1-2
  decisions) et desormais auto-maintenu : .github/workflows/update-rate-decisions.yml
  (horaire) detecte les changements de taux via Trading Economics et fait
  glisser current -> prev sans perte de donnee.
- data/money-supply-m3.json (nouveau) + .github/workflows/fetch-money-supply.yml
  (hebdo) : M3 par devise (proxy M2 pour l'USD, la Fed ne publiant plus M3
  depuis 2006), affiche dans CurrencyCard.

Calendrier economique elargi :
- lib/calendar-countries.ts, lib/calendar-taxonomy.ts, lib/fxstreetCalendar.ts :
  couverture pays elargie + classification des evenements + source FXStreet.

Fix InvestingLive :
- lib/investinglive.ts : l'ancienne API WordPress (wp-json) renvoyait 404 depuis
  leur migration Nuxt.js -> reecrit vers api.investinglive.com/api/homepage/articles,
  + fix crash silencieux (Tldr pas toujours un tableau).

Divers :
- .vercel/ ajoute au .gitignore (ne doit jamais etre commite, cf. son propre README).
- scripts/ (lancement PWA, push env Vercel), captures d'ecran, cache InvestingLive.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
This commit is contained in:
caty21
2026-07-08 16:47:59 +02:00
co-authored by Claude Sonnet 5
parent 82a732fbdf
commit 0657b50c07
38 changed files with 3257 additions and 443 deletions
+24 -16
View File
@@ -46,50 +46,58 @@ export interface ILExpectationsWithHistory {
interface ArticleRef { url: string; dateStr: string; daysAgo: number; }
// Teste les 4 variantes d'URL (/centralbank/ ou /news/, events pluriel ou singulier)
// en parallèle pour un jour donné — un seul aller-retour réseau au lieu de 4 séquentiels.
async function tryUrl(daysAgo: number): Promise<ArticleRef | null> {
const d = new Date(Date.now() - daysAgo * 86_400_000);
const yyyymmdd = d.toISOString().slice(0, 10).replace(/-/g, "");
const dateStr = `${yyyymmdd.slice(0,4)}-${yyyymmdd.slice(4,6)}-${yyyymmdd.slice(6,8)}`;
// Tester les 4 variantes : /centralbank/ ou /news/, events (pluriel) ou event (singulier)
const candidates = [
`https://investinglive.com/centralbank/how-have-interest-rate-expectations-changed-after-this-weeks-events-${yyyymmdd}/`,
`https://investinglive.com/centralbank/how-have-interest-rate-expectations-changed-after-this-weeks-event-${yyyymmdd}/`,
`https://investinglive.com/news/how-have-interest-rate-expectations-changed-after-this-weeks-events-${yyyymmdd}/`,
`https://investinglive.com/news/how-have-interest-rate-expectations-changed-after-this-weeks-event-${yyyymmdd}/`,
];
for (const url of candidates) {
const hits = await Promise.all(candidates.map(async (url) => {
try {
const res = await fetch(url, {
method: "GET",
headers: { "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36" },
cache: "no-store",
});
if (!res.ok) { res.body?.cancel().catch(() => {}); continue; }
res.body?.cancel().catch(() => {});
return { url, dateStr, daysAgo };
} catch { continue; }
return res.ok ? url : null;
} catch { return null; }
}));
const found = hits.find((u): u is string => u !== null);
return found ? { url: found, dateStr, daysAgo } : null;
}
// Cherche le jour le plus récent (daysAgo le plus petit) avec un article dans [start, end],
// par lots concurrents plutôt que séquentiellement — évite jusqu'à ~150 aller-retours
// réseau en série (risque de timeout sur les fonctions serverless Vercel).
async function findDayInRange(start: number, end: number, batchSize = 6): Promise<ArticleRef | null> {
for (let batchStart = start; batchStart <= end; batchStart += batchSize) {
const batchEnd = Math.min(batchStart + batchSize - 1, end);
const days = Array.from({ length: batchEnd - batchStart + 1 }, (_, i) => batchStart + i);
const results = await Promise.all(days.map(tryUrl));
const found = results
.filter((r): r is ArticleRef => r !== null)
.sort((a, b) => a.daysAgo - b.daysAgo)[0];
if (found) return found;
}
return null;
}
async function findArticleRefs(): Promise<{ current: ArticleRef | null; previous: ArticleRef | null }> {
let current: ArticleRef | null = null;
for (let d = 0; d <= 14; d++) {
const found = await tryUrl(d);
if (found) { current = found; break; }
}
const current = await findDayInRange(0, 14);
console.log(`[IL] article courant : ${current ? `day=${current.daysAgo} url=${current.url}` : "introuvable (014 jours)"}`);
if (!current) return { current: null, previous: null };
let previous: ArticleRef | null = null;
const searchFrom = current.daysAgo + 1;
const searchTo = current.daysAgo + 28;
for (let d = searchFrom; d <= searchTo; d++) {
const found = await tryUrl(d);
if (found) { previous = found; break; }
}
const previous = await findDayInRange(searchFrom, searchTo);
console.log(`[IL] article précédent : ${previous ? `day=${previous.daysAgo} url=${previous.url}` : `introuvable (day ${searchFrom}${searchTo})`}`);
return { current, previous };