fix(lme): eliminate zero-drop spikes caused by exchange bank holidays and reporting gaps

This commit is contained in:
alireza 2026-08-26 10:59:32 +03:30
parent 92a9c489fb
commit 2b22b032c1
2 changed files with 12 additions and 0 deletions

View File

@ -286,6 +286,7 @@ def get_entire_diagram_data(field: str, ttl_seconds: int = 3600):
series_type = "price" series_type = "price"
pts = [] pts = []
last_valid_y = None
for val in line: for val in line:
raw_x = val.attrib.get('x', '') # YYYY/MM/DD raw_x = val.attrib.get('x', '') # YYYY/MM/DD
date_iso = raw_x.replace('/', '-') date_iso = raw_x.replace('/', '-')
@ -298,6 +299,15 @@ def get_entire_diagram_data(field: str, ttl_seconds: int = 3600):
except: except:
y_val = 0.0 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({ pts.append({
"x": date_iso, "x": date_iso,
"date_display": date_display, "date_display": date_display,

View File

@ -752,6 +752,7 @@ export function LmeView() {
{/* Price Curve */} {/* Price Curve */}
{showPrice && ( {showPrice && (
<Area <Area
connectNulls={true}
yAxisId="price" yAxisId="price"
type="monotone" type="monotone"
dataKey="priceVal" dataKey="priceVal"
@ -767,6 +768,7 @@ export function LmeView() {
{/* Stock Curve (Mapped to Left Y-Axis) */} {/* Stock Curve (Mapped to Left Y-Axis) */}
{showStocks && stockLine && ( {showStocks && stockLine && (
<Line <Line
connectNulls={true}
yAxisId="stocks" yAxisId="stocks"
type="monotone" type="monotone"
dataKey="stockVal" dataKey="stockVal"