diff --git a/app/api/macro/route.ts b/app/api/macro/route.ts index 6668af7..0a61b43 100644 --- a/app/api/macro/route.ts +++ b/app/api/macro/route.ts @@ -127,9 +127,10 @@ export async function GET(req: NextRequest) { if (!key) return NextResponse.json({ error: "FRED_API_KEY missing" }, { status: 500 }); // Fields and which need period-over-period % conversion - // policyRate / unemployment → already in % → toIndicator - // cpiCore / gdp / retailSales / employment → index/level → toIndicatorPct (MoM% or QoQ%) - const PCT_FIELDS = new Set(["cpiCore", "gdp", "retailSales", "employment"]); + // policyRate / unemployment / retailSales → already in % → toIndicator + // (retailSales uses *SLRTTO01GPSAM series which report MoM% directly) + // cpiCore / gdp / employment → index/level → toIndicatorPct (MoM% or QoQ%) + const PCT_FIELDS = new Set(["cpiCore", "gdp", "employment"]); const fieldMap: Record = { policyRate: series.policyRate, diff --git a/lib/constants.ts b/lib/constants.ts index 8805369..4c01bb7 100644 --- a/lib/constants.ts +++ b/lib/constants.ts @@ -13,8 +13,13 @@ export const CURRENCY_META: Record = { USD: { policyRate: "FEDFUNDS", - cpiCore: "CPILFESL", - gdp: "GDPC1", - retailSales: "MARTSSM44W72USS", // correction : ex-RSXFS (discontinuée) + cpiCore: "CPILFESL", // indice niveau → MoM% + gdp: "GDPC1", // indice niveau → QoQ% + retailSales: "USASLRTTO01GPSAM", // déjà MoM% — ex-MARTSSM44W72USS (niveau) unemployment: "UNRATE", - employment: "PAYEMS", + employment: "PAYEMS", // niveau → MoM% }, EUR: { - policyRate: "ECBDFR", // ECB deposit rate — disponible sur FRED - cpiCore: null, // CP0000EZ20M086NEST n'existe pas sur FRED → ECB API - gdp: null, // CLVMNACSCAB1GQEA20 n'existe pas sur FRED → Eurostat - retailSales: "SLRTTO01DEM189S", // proxy Allemagne — OK sur FRED - unemployment: null, // LRHUTTTTEZM156S arrêtée 2023 → Eurostat + policyRate: "ECBDFR", // taux dépôt BCE + cpiCore: null, // → Eurostat dans /api/macro + gdp: null, // → Eurostat dans /api/macro + retailSales: "DEUSLRTTO01GPSAM", // proxy Allemagne, déjà MoM% + unemployment: null, // → Eurostat dans /api/macro employment: null, }, GBP: { - policyRate: null, // BoE API (IUDBEDR) — séries OECD FRED stale - cpiCore: "GBRCPIALLMINMEI", // OK — mars 2025 - gdp: "CLVMNACSCAB1GQGB", - retailSales: "SLRTTO01GBM189S", + policyRate: null, // → BoE API dans /api/macro + cpiCore: "GBRCPIALLMINMEI", // indice niveau → MoM% + gdp: "CLVMNACSCAB1GQGB", // indice niveau → QoQ% + retailSales: "GBRSLRTTO01GPSAM", // déjà MoM% unemployment: "LRHUTTTTGBM156S", - employment: "LNEMNACSCAB1GQGB", + employment: null, // pas de série mensuelle FRED pour GBP }, JPY: { policyRate: "IRSTCB01JPM156N", - cpiCore: "JPNCPIALLMINMEI", // correction : JPNCPICORMINMEI arrêtée 2021 → All Items - gdp: "JPNRGDPEXP", - retailSales: null, // METI Japan CSV — pas sur FRED + cpiCore: "JPNCPIALLMINMEI", // indice niveau → MoM% + gdp: "JPNRGDPEXP", // indice niveau → QoQ% + retailSales: "JPNSLRTTO01GPSAM", // déjà MoM% unemployment: "LRHUTTTTJPM156S", - employment: null, + employment: "LFEMTTTTJPM647S", // niveau mensuel → MoM% }, CHF: { policyRate: "IRSTCB01CHM156N", - cpiCore: "CHECPICORMINMEI", // OK — avr 2025 - gdp: "CHNGDPNQDSMEI", - retailSales: null, // OFS Suisse CSV + cpiCore: "CHECPICORMINMEI", // indice niveau → MoM% + gdp: "CHNGDPNQDSMEI", // indice niveau → QoQ% + retailSales: "CHESLRTTO01GPSAM", // déjà MoM% unemployment: "LRHUTTTTCHM156S", - employment: null, + employment: null, // pas de série FRED pour CHF }, CAD: { policyRate: "IRSTCB01CAM156N", - cpiCore: "CANCPICORMINMEI", // OK — mars 2025 - gdp: "CLVMNACSCAB1GQCA", - retailSales: "SLRTTO01CAM189S", + cpiCore: "CANCPICORMINMEI", // indice niveau → MoM% + gdp: "CLVMNACSCAB1GQCA", // indice niveau → QoQ% + retailSales: "CANSLRTTO01GPSAM", // déjà MoM% unemployment: "LRHUTTTTCAM156S", - employment: null, + employment: "LFEMTTTTCAM647S", // niveau mensuel → MoM% }, AUD: { policyRate: "IRSTCB01AUM156N", - cpiCore: "AUSCPIALLMINMEI", // trimestriel — pas d'alternative mensuelle FRED - gdp: "CLVMNACSCAB1GQAU", - retailSales: "SLRTTO01AUM189S", + cpiCore: "AUSCPIALLMINMEI", // trimestriel + gdp: "CLVMNACSCAB1GQAU", // indice niveau → QoQ% + retailSales: null, // pas de série mensuelle FRED pour AUD unemployment: "LRHUTTTTAUM156S", - employment: "LNEMNACSCAB1GQAU", + employment: "LFEMTTTTAUM647S", // niveau mensuel → MoM% }, NZD: { policyRate: "IRSTCB01NZM156N", cpiCore: "NZLCPIALLMINMEI", // trimestriel - gdp: "CLVMNACSCAB1GQNZ", - retailSales: null, // Stats NZ API trimestriel - unemployment: "LRUNTTTTNZQ156S", // correction : ex-LRHUTTTTNZM156S (inexistante) - employment: null, + gdp: "CLVMNACSCAB1GQNZ", // indice niveau → QoQ% + retailSales: null, // pas de série mensuelle FRED pour NZD + unemployment: "LRUNTTTTNZQ156S", + employment: "LFEMTTTTNZQ647S", // niveau trimestriel → QoQ% (proxy) }, };