From 2b22b032c12cb3bf47d8b36fb81ce3035c0a1d74 Mon Sep 17 00:00:00 2001 From: alireza Date: Wed, 26 Aug 2026 10:59:32 +0330 Subject: [PATCH] fix(lme): eliminate zero-drop spikes caused by exchange bank holidays and reporting gaps --- backend/scrape_lme.py | 10 ++++++++++ frontend/src/components/LmeView.tsx | 2 ++ 2 files changed, 12 insertions(+) diff --git a/backend/scrape_lme.py b/backend/scrape_lme.py index 4bd6b63..8fe6ece 100644 --- a/backend/scrape_lme.py +++ b/backend/scrape_lme.py @@ -286,6 +286,7 @@ def get_entire_diagram_data(field: str, ttl_seconds: int = 3600): series_type = "price" pts = [] + last_valid_y = None for val in line: raw_x = val.attrib.get('x', '') # YYYY/MM/DD date_iso = raw_x.replace('/', '-') @@ -298,6 +299,15 @@ def get_entire_diagram_data(field: str, ttl_seconds: int = 3600): except: y_val = 0.0 + # Filter out bank holiday / reporting zero anomalies (e.g. market closed) + if y_val <= 0: + if last_valid_y is not None: + y_val = last_valid_y + else: + continue + else: + last_valid_y = y_val + pts.append({ "x": date_iso, "date_display": date_display, diff --git a/frontend/src/components/LmeView.tsx b/frontend/src/components/LmeView.tsx index f99818d..cc4854b 100644 --- a/frontend/src/components/LmeView.tsx +++ b/frontend/src/components/LmeView.tsx @@ -752,6 +752,7 @@ export function LmeView() { {/* Price Curve */} {showPrice && (