mirror of
https://github.com/caty21/forex-dashboard.git
synced 2026-07-27 20:37:45 +00:00
auto: sync 2026-06-02 23:16
This commit is contained in:
+24
-2
@@ -5,7 +5,7 @@ import cpiOverridesRaw from "@/data/cpi_overrides.json";
|
||||
import rateDecisionsRaw from "@/data/rate_decisions.json";
|
||||
import { fetchFFThisWeek, fetchFFEvents } from "@/lib/forexfactory";
|
||||
import type { FFEvent } from "@/lib/forexfactory";
|
||||
import { fetchTECoreInflation, fetchTEMoMInflation, fetchTEInflationYoY, fetchTECoreCPIMoM, fetchTECoreConsumerPricesIndex, fetchTEPPIMoM, fetchTECoreInflationPages, fetchTEInflationYoYPages, fetchTEAUDCommodityYoY } from "@/lib/tecpi";
|
||||
import { fetchTECoreInflation, fetchTEMoMInflation, fetchTEInflationYoY, fetchTECoreCPIMoM, fetchTECoreConsumerPricesIndex, fetchTEPPIMoM, fetchTECoreInflationPages, fetchTEInflationYoYPages, fetchTEAUDCommodityYoY, fetchTEGDPGrowthRate } from "@/lib/tecpi";
|
||||
import { fetchTEInflationForecasts } from "@/lib/tradingeconomics";
|
||||
|
||||
const FRED_BASE = "https://api.stlouisfed.org/fred/series/observations";
|
||||
@@ -1025,7 +1025,7 @@ export async function GET(req: NextRequest) {
|
||||
// Remplace séries FRED stale/erronées.
|
||||
// Nouvelles données : cpiYoY headline, cpiCoreMoM (pages individuelles), ppiMoM
|
||||
{
|
||||
const [teCoreMap, teMoMMap, teYoYMap, teCoreMoMMap, teCoreIdxMap, tePPIMap, teCorePages, teYoYPages, teAUDComm] = await Promise.all([
|
||||
const [teCoreMap, teMoMMap, teYoYMap, teCoreMoMMap, teCoreIdxMap, tePPIMap, teCorePages, teYoYPages, teAUDComm, teGDPMap] = await Promise.all([
|
||||
fetchTECoreInflation(),
|
||||
fetchTEMoMInflation(),
|
||||
fetchTEInflationYoY(),
|
||||
@@ -1035,6 +1035,7 @@ export async function GET(req: NextRequest) {
|
||||
fetchTECoreInflationPages(),
|
||||
fetchTEInflationYoYPages(),
|
||||
currency === "AUD" ? fetchTEAUDCommodityYoY() : Promise.resolve(null),
|
||||
fetchTEGDPGrowthRate(),
|
||||
]);
|
||||
|
||||
const teCore = teCoreMap[currency];
|
||||
@@ -1134,6 +1135,27 @@ export async function GET(req: NextRequest) {
|
||||
};
|
||||
}
|
||||
|
||||
// GDP Growth Rate QoQ% — TE country-list (source autoritaire, remplace FRED stale)
|
||||
// FRED : retourne souvent l'indice niveau brut → QoQ% faux ou en retard de plusieurs trimestres
|
||||
// TE country-list/gdp-growth-rate : QoQ% publié directement, mis à jour à chaque release
|
||||
{
|
||||
const teGDP = teGDPMap[currency];
|
||||
if (teGDP) {
|
||||
const surprise = teGDP.prev !== null
|
||||
? parseFloat((teGDP.value - teGDP.prev).toFixed(4))
|
||||
: null;
|
||||
indicators.gdp = {
|
||||
value: teGDP.value,
|
||||
prev: teGDP.prev,
|
||||
surprise,
|
||||
trend: teGDP.prev !== null
|
||||
? (teGDP.value > teGDP.prev ? "up" : teGDP.value < teGDP.prev ? "down" : "flat")
|
||||
: null,
|
||||
lastUpdated: teGDP.refMonth,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// AUD Commodity Prices YoY
|
||||
if (teAUDComm) {
|
||||
const surprise = teAUDComm.prev !== null
|
||||
|
||||
@@ -609,3 +609,31 @@ export async function fetchTEAUDCommodityYoY(): Promise<InflationYoYPageEntry |
|
||||
return { value, prev, consensus, refMonth };
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
// ── GDP Growth Rate QoQ% ──────────────────────────────────────────────────────
|
||||
// Source : https://tradingeconomics.com/country-list/gdp-growth-rate
|
||||
// Une seule requête HTTP (cache 6h) couvre les 8 devises.
|
||||
// Remplace les séries FRED qui retournent souvent un indice niveau à la place
|
||||
// du QoQ% réel, et qui sont en retard d'1 à 4 trimestres selon la devise.
|
||||
|
||||
export async function fetchTEGDPGrowthRate(): Promise<CoreCPIMap> {
|
||||
try {
|
||||
const res = await fetch(
|
||||
"https://tradingeconomics.com/country-list/gdp-growth-rate?continent=world",
|
||||
{
|
||||
next: { revalidate: 21600 },
|
||||
headers: {
|
||||
"User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/124.0.0.0 Safari/537.36",
|
||||
"Accept": "text/html,application/xhtml+xml,application/xml;q=0.9,*/*;q=0.8",
|
||||
"Accept-Language": "en-US,en;q=0.9",
|
||||
},
|
||||
}
|
||||
);
|
||||
if (!res.ok) { console.warn("[tecpi-gdp] HTTP", res.status); return {}; }
|
||||
const html = await res.text();
|
||||
return parseCoreInflationHTML(html);
|
||||
} catch (err) {
|
||||
console.error("[tecpi-gdp] error:", err);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user