From 9b1daf6f767fdb63680aebd86349c062c9eb7450 Mon Sep 17 00:00:00 2001 From: alireza Date: Wed, 26 Aug 2026 10:48:38 +0330 Subject: [PATCH] clean(lme): remove third-party labels, contango badges, and refresh button --- backend/scrape_lme.py | 3 - frontend/src/components/LmeView.tsx | 240 ++++++++++------------------ 2 files changed, 88 insertions(+), 155 deletions(-) diff --git a/backend/scrape_lme.py b/backend/scrape_lme.py index 90f3d61..8301b57 100644 --- a/backend/scrape_lme.py +++ b/backend/scrape_lme.py @@ -101,7 +101,6 @@ def fetch_raw(): "three_months_str": p["three_months_str"], "spread": spread, "spread_str": f"{spread:+,.2f}", - "market_condition": "Contango" if spread > 0 else ("Backwardation" if spread < 0 else "Flat"), "stocks": s_data.get("stocks", 0), "stocks_str": s_data.get("stocks_str", "-"), "stocks_change": s_data.get("change", 0), @@ -133,8 +132,6 @@ def fetch_raw(): }) return { - "source": "Westmetall GmbH / London Metal Exchange (LME)", - "source_url": "https://www.westmetall.com/en/markdaten.php", "date": date_str or datetime.utcnow().strftime("%d. %B %Y"), "updated_at": datetime.utcnow().isoformat(), "metals": combined_metals, diff --git a/frontend/src/components/LmeView.tsx b/frontend/src/components/LmeView.tsx index 23d80fa..a93ff51 100644 --- a/frontend/src/components/LmeView.tsx +++ b/frontend/src/components/LmeView.tsx @@ -1,16 +1,11 @@ import { useState, useEffect, useMemo } from "react"; import { Search, - ExternalLink, - RefreshCw, - TrendingUp, - TrendingDown, Warehouse, Coins, DollarSign, Layers, ArrowUpDown, - ShieldCheck, Globe } from "lucide-react"; import { API_BASE } from "@/lib/api"; @@ -26,7 +21,6 @@ export interface LmeMetal { three_months_str: string; spread: number; spread_str: string; - market_condition: "Contango" | "Backwardation" | "Flat"; stocks: number; stocks_str: string; stocks_change: number; @@ -46,8 +40,6 @@ export interface LmePrecious { } export interface LmeData { - source: string; - source_url: string; date: string; updated_at: string; metals: LmeMetal[]; @@ -56,35 +48,29 @@ export interface LmeData { precious_metals: LmePrecious[]; } -const METAL_COLORS: Record = { - Copper: { border: "border-amber-500/30", bg: "from-amber-500/10 to-orange-500/5", text: "text-amber-500", badge: "bg-amber-500/10 text-amber-600 dark:text-amber-400" }, - Aluminium: { border: "border-sky-500/30", bg: "from-sky-500/10 to-blue-500/5", text: "text-sky-500", badge: "bg-sky-500/10 text-sky-600 dark:text-sky-400" }, - Zinc: { border: "border-emerald-500/30", bg: "from-emerald-500/10 to-teal-500/5", text: "text-emerald-500", badge: "bg-emerald-500/10 text-emerald-600 dark:text-emerald-400" }, - Nickel: { border: "border-purple-500/30", bg: "from-purple-500/10 to-indigo-500/5", text: "text-purple-500", badge: "bg-purple-500/10 text-purple-600 dark:text-purple-400" }, - Lead: { border: "border-slate-500/30", bg: "from-slate-500/10 to-zinc-500/5", text: "text-slate-400", badge: "bg-slate-500/10 text-slate-600 dark:text-slate-300" }, - Tin: { border: "border-cyan-500/30", bg: "from-cyan-500/10 to-teal-500/5", text: "text-cyan-500", badge: "bg-cyan-500/10 text-cyan-600 dark:text-cyan-400" }, +const METAL_STYLES: Record = { + Copper: { border: "border-amber-500/30", bg: "from-amber-500/10 to-transparent", text: "text-amber-500" }, + Aluminium: { border: "border-sky-500/30", bg: "from-sky-500/10 to-transparent", text: "text-sky-500" }, + Zinc: { border: "border-emerald-500/30", bg: "from-emerald-500/10 to-transparent", text: "text-emerald-500" }, + Nickel: { border: "border-purple-500/30", bg: "from-purple-500/10 to-transparent", text: "text-purple-500" }, + Lead: { border: "border-slate-500/30", bg: "from-slate-500/10 to-transparent", text: "text-slate-400" }, + Tin: { border: "border-cyan-500/30", bg: "from-cyan-500/10 to-transparent", text: "text-cyan-500" }, }; export function LmeView() { const [data, setData] = useState(null); - const [loading, setLoading] = useState(true); const [error, setError] = useState(null); const [search, setSearch] = useState(""); - const [lastRefreshed, setLastRefreshed] = useState(""); const loadData = async () => { - setLoading(true); try { const res = await fetch(`${API}/api/lme`, { credentials: "include" }); if (!res.ok) throw new Error(`HTTP ${res.status}`); const json: LmeData = await res.json(); setData(json); setError(null); - setLastRefreshed(new Date().toLocaleTimeString("fa-IR")); } catch (err: any) { setError(err.message || "خطا در دریافت داده‌های LME"); - } finally { - setLoading(false); } }; @@ -107,50 +93,27 @@ export function LmeView() { return (
- {/* Header Banner */} -
-
-
-
- - - بورس فلزات لندن (London Metal Exchange) - -
-

- قیمت‌های رسمی LME & موجودی انبارها + {/* Clean Header */} +
+
+
+ +
+
+

+ بورس فلزات لندن (LME)

-

- بروزرسانی روزانه قیمت‌های تسویه نقدی (Cash Settlement)، قراردادهای ۳ ماهه و انبارداری از مرجع رسمی Westmetall +

+ قیمت‌های رسمی نقدی، قراردادهای ۳ ماهه و موجودی انبارها

- -
- {data?.date && ( -
- تاریخ بازار: {data.date} -
- )} - - - سایت Westmetall - - -
+ + {data?.date && ( +
+ تاریخ: {data.date} +
+ )}
{error && ( @@ -162,34 +125,28 @@ export function LmeView() { {/* KPI Cards Grid */}
{data?.metals.map((m) => { - const style = METAL_COLORS[m.metal] || { + const style = METAL_STYLES[m.metal] || { border: "border-border", - bg: "from-card to-card", + bg: "from-card to-transparent", text: "text-primary", - badge: "bg-primary/10 text-primary", }; - const isBackwardation = m.spread < 0; return (
{m.name_fa}
-
{m.metal} • {m.unit}
+
{m.metal} • USD/mt
+
+
+ + + {m.spread_str} $ +
- - {m.market_condition} -
{/* Prices Section */} @@ -201,37 +158,31 @@ export function LmeView() {
-
قرارداد ۳ ماهه (3M)
+
۳ ماهه (3-Month)
${m.three_months_str}

- {/* Spread & Warehouse Stocks */} + {/* Warehouse Stocks */}
- - اسپرد: - - {m.spread_str} $ - -
-
- {m.stocks_str} تن - {m.stocks_change !== 0 && ( - 0 - ? "text-emerald-600 dark:text-emerald-400 bg-emerald-500/10" - : "text-rose-600 dark:text-rose-400 bg-rose-500/10" - }`} - > - {m.stocks_change_str} - - )} + موجودی انبار: + {m.stocks_str} تن
+ {m.stocks_change !== 0 && ( + 0 + ? "text-emerald-600 dark:text-emerald-400" + : "text-rose-600 dark:text-rose-400" + }`} + > + {m.stocks_change > 0 ? "+" : ""}{m.stocks_change_str} تن + + )}
); @@ -243,7 +194,7 @@ export function LmeView() {
-

جدول جامع مظنه‌های رسمی LME (Westmetall)

+

جدول مظنه‌های رسمی LME

@@ -263,62 +214,47 @@ export function LmeView() { فلز (Metal) تسویه نقدی (Cash) - ۳ ماهه (3-Months) + ۳ ماهه (3-Month) اسپرد (3M - Cash) - وضعیت بازار - موجودی انبارها (LME Stocks) + موجودی انبارها (Stocks) تغییرات موجودی - {filteredMetals.map((m) => { - const isBackwardation = m.spread < 0; - return ( - - -
{m.name_fa}
-
{m.metal}
- - - ${m.cash_str} / mt - - - ${m.three_months_str} / mt - - - {m.spread_str} $ - - - - {m.market_condition} - - - - {m.stocks_str} تن - - - 0 - ? "text-emerald-600 dark:text-emerald-400" - : m.stocks_change < 0 - ? "text-rose-600 dark:text-rose-400" - : "text-muted-foreground" - }`} - > - {m.stocks_change > 0 ? "+" : ""} - {m.stocks_change_str} تن - - - - ); - })} + {filteredMetals.map((m) => ( + + +
{m.name_fa}
+
{m.metal}
+ + + ${m.cash_str} / mt + + + ${m.three_months_str} / mt + + + {m.spread_str} $ + + + {m.stocks_str} تن + + + 0 + ? "text-emerald-600 dark:text-emerald-400" + : m.stocks_change < 0 + ? "text-rose-600 dark:text-rose-400" + : "text-muted-foreground" + }`} + > + {m.stocks_change > 0 ? "+" : ""} + {m.stocks_change_str} تن + + + + ))}
@@ -331,7 +267,7 @@ export function LmeView() {
-

نرخ‌های برابری ارز LME & ECB (Exchange Rates)

+

نرخ‌های برابری ارز (Exchange Rates)

EUR / USD
@@ -354,7 +290,7 @@ export function LmeView() {
-

فلزات گرانبها (Precious Metals London)

+

فلزات گرانبها (Precious Metals)

Gold & Silver