mirror of
https://github.com/caty21/forex-dashboard.git
synced 2026-08-16 22:18:06 +00:00
fix: Sem. préc. HEAD→GET, prevMeetings cache, remove footer
- investinglive: tryUrl HEAD→GET + res.body?.cancel() (WordPress bloque HEAD) fenêtre recherche article préc. élargie 21→28 jours - rateprobability: CBRatePath + prevMeetings/prevWeekDate, loadPrevWeekCachedBody() fetchAllCBPaths enrichit prevMeetings depuis snapshot GitHub Actions - fetch-rate-data.mjs: rotation current→previousWeek (5–9 jours) pour Rate Curve - CurrencyCard: rateCurveData préfère prevMeetings (exact/meeting) > ilDelta (approx) légende hasPrevCurve pilote affichage ligne bleue et label date - page.tsx: suppression footer Sources/LLM, remplacement par pb-12 Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
1a7468d718
commit
a978f19088
@@ -44,6 +44,8 @@ export interface CBRatePath {
|
||||
yearEndImplied: number | null; // taux impliqué à la dernière réunion connue (SOFR)
|
||||
ilCurrent?: ILCurrent; // valeurs absolues de l'article IL courant
|
||||
ilDelta?: ILWeeklyDelta; // delta vs article IL semaine précédente
|
||||
prevMeetings?: RateProbMeeting[]; // réunions semaine précédente (snapshot RP)
|
||||
prevWeekDate?: string; // date du snapshot semaine précédente
|
||||
}
|
||||
|
||||
export type RateProbData = Partial<Record<Currency, CBRatePath>>;
|
||||
@@ -244,6 +246,21 @@ function loadCachedRPBody(ccy: string, slug: string): Record<string, unknown> |
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
function loadPrevWeekCachedBody(ccy: string): { body: Record<string, unknown>; date: string } | null {
|
||||
try {
|
||||
const filePath = join(process.cwd(), "data", "rate-probabilities.json");
|
||||
const raw = readFileSync(filePath, "utf8");
|
||||
const parsed = JSON.parse(raw) as { previousWeek?: Record<string, unknown>; previousWeekFetchedAt?: string };
|
||||
if (!parsed.previousWeek || !parsed.previousWeekFetchedAt) return null;
|
||||
const entry = parsed.previousWeek[ccy] as Record<string, unknown> | undefined;
|
||||
if (!entry) return null;
|
||||
const ageMs = Date.now() - new Date(parsed.previousWeekFetchedAt).getTime();
|
||||
// Le snapshot semaine précédente doit dater de 4 à 10 jours
|
||||
if (ageMs < 3 * 86400000 || ageMs > 11 * 86400000) return null;
|
||||
return { body: entry, date: parsed.previousWeekFetchedAt.slice(0, 10) };
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
// Reparse un body brut de rateprobability.com (même format que fetchCBPath)
|
||||
function parseCBBody(ccy: Currency, body: Record<string, unknown>): CBRatePath | null {
|
||||
const today = body["today"] as Record<string, unknown> | undefined;
|
||||
@@ -301,6 +318,18 @@ export async function fetchAllCBPaths(): Promise<RateProbData> {
|
||||
}
|
||||
}
|
||||
|
||||
// Enrichissement prevMeetings depuis snapshot semaine précédente (GitHub Actions)
|
||||
for (const [ccy] of CB_KEYS) {
|
||||
const path = data[ccy as Currency];
|
||||
if (!path) continue;
|
||||
const prev = loadPrevWeekCachedBody(ccy);
|
||||
if (!prev) continue;
|
||||
const prevPath = parseCBBody(ccy as Currency, prev.body);
|
||||
if (prevPath?.meetings.length) {
|
||||
data[ccy as Currency] = { ...path, prevMeetings: prevPath.meetings, prevWeekDate: prev.date };
|
||||
}
|
||||
}
|
||||
|
||||
// CHF/SNB : rateprobability ne couvre pas la SNB → InvestingLive est la seule source
|
||||
if (!data["CHF"] && ilData["CHF"]) {
|
||||
const snbPath = buildSNBPath(ilData, 0.00); // taux actuel SNB = 0%
|
||||
|
||||
Reference in New Issue
Block a user