mirror of
https://github.com/caty21/forex-dashboard.git
synced 2026-07-27 20:37:45 +00:00
auto: sync 2026-06-02 23:52
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, fetchTEGDPGrowthRate } from "@/lib/tecpi";
|
||||
import { fetchTECoreInflation, fetchTEMoMInflation, fetchTEInflationYoY, fetchTECoreCPIMoM, fetchTECoreConsumerPricesIndex, fetchTEPPIMoM, fetchTECoreInflationPages, fetchTEInflationYoYPages, fetchTEAUDCommodityYoY, fetchTEGDPGrowthRate, fetchTEUnemploymentRate } 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, teGDPMap] = await Promise.all([
|
||||
const [teCoreMap, teMoMMap, teYoYMap, teCoreMoMMap, teCoreIdxMap, tePPIMap, teCorePages, teYoYPages, teAUDComm, teGDPMap, teUneMap] = await Promise.all([
|
||||
fetchTECoreInflation(),
|
||||
fetchTEMoMInflation(),
|
||||
fetchTEInflationYoY(),
|
||||
@@ -1036,6 +1036,7 @@ export async function GET(req: NextRequest) {
|
||||
fetchTEInflationYoYPages(),
|
||||
currency === "AUD" ? fetchTEAUDCommodityYoY() : Promise.resolve(null),
|
||||
fetchTEGDPGrowthRate(),
|
||||
fetchTEUnemploymentRate(),
|
||||
]);
|
||||
|
||||
const teCore = teCoreMap[currency];
|
||||
@@ -1156,6 +1157,27 @@ export async function GET(req: NextRequest) {
|
||||
}
|
||||
}
|
||||
|
||||
// Unemployment Rate — TE country-list (taux national officiel, toutes devises)
|
||||
// Remplace FRED qui publie souvent le taux ILO harmonisé (2-3pp supérieur au taux national,
|
||||
// notamment CHF ~5% ILO vs ~3% SECO, GBP ~4% ILO vs ONS, etc.)
|
||||
{
|
||||
const teUne = teUneMap[currency];
|
||||
if (teUne) {
|
||||
const surprise = teUne.prev !== null
|
||||
? parseFloat((teUne.value - teUne.prev).toFixed(4))
|
||||
: null;
|
||||
indicators.unemployment = {
|
||||
value: teUne.value,
|
||||
prev: teUne.prev,
|
||||
surprise,
|
||||
trend: teUne.prev !== null
|
||||
? (teUne.value > teUne.prev ? "up" : teUne.value < teUne.prev ? "down" : "flat")
|
||||
: null,
|
||||
lastUpdated: teUne.refMonth,
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
// AUD Commodity Prices YoY
|
||||
if (teAUDComm) {
|
||||
const surprise = teAUDComm.prev !== null
|
||||
|
||||
@@ -610,6 +610,34 @@ export async function fetchTEAUDCommodityYoY(): Promise<InflationYoYPageEntry |
|
||||
} catch { return null; }
|
||||
}
|
||||
|
||||
// ── Unemployment Rate ─────────────────────────────────────────────────────────
|
||||
// Source : https://tradingeconomics.com/country-list/unemployment-rate?continent=world
|
||||
// Une seule requête HTTP (cache 6h) pour les 8 devises.
|
||||
// Donne le taux national officiel (ex : SECO ~3% pour CHF) au lieu du taux ILO harmonisé
|
||||
// FRED qui peut être de 2-3 pp supérieur (ex : LRHUTTTTCHQ156S ~5% pour CHF).
|
||||
|
||||
export async function fetchTEUnemploymentRate(): Promise<CoreCPIMap> {
|
||||
try {
|
||||
const res = await fetch(
|
||||
"https://tradingeconomics.com/country-list/unemployment-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-une] HTTP", res.status); return {}; }
|
||||
const html = await res.text();
|
||||
return parseCoreInflationHTML(html);
|
||||
} catch (err) {
|
||||
console.error("[tecpi-une] error:", err);
|
||||
return {};
|
||||
}
|
||||
}
|
||||
|
||||
// ── GDP Growth Rate QoQ% ──────────────────────────────────────────────────────
|
||||
// Source : https://tradingeconomics.com/country-list/gdp-growth-rate
|
||||
// Une seule requête HTTP (cache 6h) couvre les 8 devises.
|
||||
|
||||
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user