mirror of
https://github.com/caty21/forex-dashboard.git
synced 2026-08-25 18:38:07 +00:00
Fix macro indicators: add working retail sales and employment FRED series
Retail Sales: switch all currencies to *SLRTTO01GPSAM format (OECD monthly, already in MoM%) — covers USD, EUR(DEU proxy), GBP, JPY, CHF, CAD. Remove retailSales from PCT_FIELDS since values are already percentages. Employment: add LFEMTTTT*647S series (monthly levels → MoM%) for JPY, CAD, AUD and quarterly for NZD. These replace null/non-existent FRED series. PMI stays ⚠ — no free real-time source found. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Sonnet 4.6
parent
abf04aabbd
commit
3fcb72a25e
@@ -127,9 +127,10 @@ export async function GET(req: NextRequest) {
|
|||||||
if (!key) return NextResponse.json({ error: "FRED_API_KEY missing" }, { status: 500 });
|
if (!key) return NextResponse.json({ error: "FRED_API_KEY missing" }, { status: 500 });
|
||||||
|
|
||||||
// Fields and which need period-over-period % conversion
|
// Fields and which need period-over-period % conversion
|
||||||
// policyRate / unemployment → already in % → toIndicator
|
// policyRate / unemployment / retailSales → already in % → toIndicator
|
||||||
// cpiCore / gdp / retailSales / employment → index/level → toIndicatorPct (MoM% or QoQ%)
|
// (retailSales uses *SLRTTO01GPSAM series which report MoM% directly)
|
||||||
const PCT_FIELDS = new Set(["cpiCore", "gdp", "retailSales", "employment"]);
|
// cpiCore / gdp / employment → index/level → toIndicatorPct (MoM% or QoQ%)
|
||||||
|
const PCT_FIELDS = new Set(["cpiCore", "gdp", "employment"]);
|
||||||
|
|
||||||
const fieldMap: Record<string, string | null> = {
|
const fieldMap: Record<string, string | null> = {
|
||||||
policyRate: series.policyRate,
|
policyRate: series.policyRate,
|
||||||
|
|||||||
+41
-36
@@ -13,8 +13,13 @@ export const CURRENCY_META: Record<Currency, { name: string; flag: string; cb: s
|
|||||||
NZD: { name: "Nouvelle-Zélande", flag: "🇳🇿", cb: "Reserve Bank of New Zealand", cbShort: "RBNZ" },
|
NZD: { name: "Nouvelle-Zélande", flag: "🇳🇿", cb: "Reserve Bank of New Zealand", cbShort: "RBNZ" },
|
||||||
};
|
};
|
||||||
|
|
||||||
// FRED series IDs — corrections audit 2026-05-26
|
// FRED series IDs — corrections audit 2026-05-28
|
||||||
// null = série inexistante ou stale sur FRED → source alternative dans /api/macro
|
// null = série inexistante sur FRED → source alternative dans /api/macro
|
||||||
|
//
|
||||||
|
// Retail Sales : séries GPSAM (déjà en MoM%, ne pas convertir)
|
||||||
|
// Format : {PAYS3}SLRTTO01GPSAM (OECD monthly retail trade, % growth prev. period, SA)
|
||||||
|
// EUR utilise l'Allemagne comme proxy (plus grande économie, données mensuelles récentes)
|
||||||
|
// Employment : séries LFEMTTTT*647S (niveaux en milliers → MoM% calculé localement)
|
||||||
export const FRED_SERIES: Record<Currency, {
|
export const FRED_SERIES: Record<Currency, {
|
||||||
policyRate: string | null;
|
policyRate: string | null;
|
||||||
cpiCore: string | null;
|
cpiCore: string | null;
|
||||||
@@ -25,67 +30,67 @@ export const FRED_SERIES: Record<Currency, {
|
|||||||
}> = {
|
}> = {
|
||||||
USD: {
|
USD: {
|
||||||
policyRate: "FEDFUNDS",
|
policyRate: "FEDFUNDS",
|
||||||
cpiCore: "CPILFESL",
|
cpiCore: "CPILFESL", // indice niveau → MoM%
|
||||||
gdp: "GDPC1",
|
gdp: "GDPC1", // indice niveau → QoQ%
|
||||||
retailSales: "MARTSSM44W72USS", // correction : ex-RSXFS (discontinuée)
|
retailSales: "USASLRTTO01GPSAM", // déjà MoM% — ex-MARTSSM44W72USS (niveau)
|
||||||
unemployment: "UNRATE",
|
unemployment: "UNRATE",
|
||||||
employment: "PAYEMS",
|
employment: "PAYEMS", // niveau → MoM%
|
||||||
},
|
},
|
||||||
EUR: {
|
EUR: {
|
||||||
policyRate: "ECBDFR", // ECB deposit rate — disponible sur FRED
|
policyRate: "ECBDFR", // taux dépôt BCE
|
||||||
cpiCore: null, // CP0000EZ20M086NEST n'existe pas sur FRED → ECB API
|
cpiCore: null, // → Eurostat dans /api/macro
|
||||||
gdp: null, // CLVMNACSCAB1GQEA20 n'existe pas sur FRED → Eurostat
|
gdp: null, // → Eurostat dans /api/macro
|
||||||
retailSales: "SLRTTO01DEM189S", // proxy Allemagne — OK sur FRED
|
retailSales: "DEUSLRTTO01GPSAM", // proxy Allemagne, déjà MoM%
|
||||||
unemployment: null, // LRHUTTTTEZM156S arrêtée 2023 → Eurostat
|
unemployment: null, // → Eurostat dans /api/macro
|
||||||
employment: null,
|
employment: null,
|
||||||
},
|
},
|
||||||
GBP: {
|
GBP: {
|
||||||
policyRate: null, // BoE API (IUDBEDR) — séries OECD FRED stale
|
policyRate: null, // → BoE API dans /api/macro
|
||||||
cpiCore: "GBRCPIALLMINMEI", // OK — mars 2025
|
cpiCore: "GBRCPIALLMINMEI", // indice niveau → MoM%
|
||||||
gdp: "CLVMNACSCAB1GQGB",
|
gdp: "CLVMNACSCAB1GQGB", // indice niveau → QoQ%
|
||||||
retailSales: "SLRTTO01GBM189S",
|
retailSales: "GBRSLRTTO01GPSAM", // déjà MoM%
|
||||||
unemployment: "LRHUTTTTGBM156S",
|
unemployment: "LRHUTTTTGBM156S",
|
||||||
employment: "LNEMNACSCAB1GQGB",
|
employment: null, // pas de série mensuelle FRED pour GBP
|
||||||
},
|
},
|
||||||
JPY: {
|
JPY: {
|
||||||
policyRate: "IRSTCB01JPM156N",
|
policyRate: "IRSTCB01JPM156N",
|
||||||
cpiCore: "JPNCPIALLMINMEI", // correction : JPNCPICORMINMEI arrêtée 2021 → All Items
|
cpiCore: "JPNCPIALLMINMEI", // indice niveau → MoM%
|
||||||
gdp: "JPNRGDPEXP",
|
gdp: "JPNRGDPEXP", // indice niveau → QoQ%
|
||||||
retailSales: null, // METI Japan CSV — pas sur FRED
|
retailSales: "JPNSLRTTO01GPSAM", // déjà MoM%
|
||||||
unemployment: "LRHUTTTTJPM156S",
|
unemployment: "LRHUTTTTJPM156S",
|
||||||
employment: null,
|
employment: "LFEMTTTTJPM647S", // niveau mensuel → MoM%
|
||||||
},
|
},
|
||||||
CHF: {
|
CHF: {
|
||||||
policyRate: "IRSTCB01CHM156N",
|
policyRate: "IRSTCB01CHM156N",
|
||||||
cpiCore: "CHECPICORMINMEI", // OK — avr 2025
|
cpiCore: "CHECPICORMINMEI", // indice niveau → MoM%
|
||||||
gdp: "CHNGDPNQDSMEI",
|
gdp: "CHNGDPNQDSMEI", // indice niveau → QoQ%
|
||||||
retailSales: null, // OFS Suisse CSV
|
retailSales: "CHESLRTTO01GPSAM", // déjà MoM%
|
||||||
unemployment: "LRHUTTTTCHM156S",
|
unemployment: "LRHUTTTTCHM156S",
|
||||||
employment: null,
|
employment: null, // pas de série FRED pour CHF
|
||||||
},
|
},
|
||||||
CAD: {
|
CAD: {
|
||||||
policyRate: "IRSTCB01CAM156N",
|
policyRate: "IRSTCB01CAM156N",
|
||||||
cpiCore: "CANCPICORMINMEI", // OK — mars 2025
|
cpiCore: "CANCPICORMINMEI", // indice niveau → MoM%
|
||||||
gdp: "CLVMNACSCAB1GQCA",
|
gdp: "CLVMNACSCAB1GQCA", // indice niveau → QoQ%
|
||||||
retailSales: "SLRTTO01CAM189S",
|
retailSales: "CANSLRTTO01GPSAM", // déjà MoM%
|
||||||
unemployment: "LRHUTTTTCAM156S",
|
unemployment: "LRHUTTTTCAM156S",
|
||||||
employment: null,
|
employment: "LFEMTTTTCAM647S", // niveau mensuel → MoM%
|
||||||
},
|
},
|
||||||
AUD: {
|
AUD: {
|
||||||
policyRate: "IRSTCB01AUM156N",
|
policyRate: "IRSTCB01AUM156N",
|
||||||
cpiCore: "AUSCPIALLMINMEI", // trimestriel — pas d'alternative mensuelle FRED
|
cpiCore: "AUSCPIALLMINMEI", // trimestriel
|
||||||
gdp: "CLVMNACSCAB1GQAU",
|
gdp: "CLVMNACSCAB1GQAU", // indice niveau → QoQ%
|
||||||
retailSales: "SLRTTO01AUM189S",
|
retailSales: null, // pas de série mensuelle FRED pour AUD
|
||||||
unemployment: "LRHUTTTTAUM156S",
|
unemployment: "LRHUTTTTAUM156S",
|
||||||
employment: "LNEMNACSCAB1GQAU",
|
employment: "LFEMTTTTAUM647S", // niveau mensuel → MoM%
|
||||||
},
|
},
|
||||||
NZD: {
|
NZD: {
|
||||||
policyRate: "IRSTCB01NZM156N",
|
policyRate: "IRSTCB01NZM156N",
|
||||||
cpiCore: "NZLCPIALLMINMEI", // trimestriel
|
cpiCore: "NZLCPIALLMINMEI", // trimestriel
|
||||||
gdp: "CLVMNACSCAB1GQNZ",
|
gdp: "CLVMNACSCAB1GQNZ", // indice niveau → QoQ%
|
||||||
retailSales: null, // Stats NZ API trimestriel
|
retailSales: null, // pas de série mensuelle FRED pour NZD
|
||||||
unemployment: "LRUNTTTTNZQ156S", // correction : ex-LRHUTTTTNZM156S (inexistante)
|
unemployment: "LRUNTTTTNZQ156S",
|
||||||
employment: null,
|
employment: "LFEMTTTTNZQ647S", // niveau trimestriel → QoQ% (proxy)
|
||||||
},
|
},
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user