Set fixed width for live mt5 account cards.
This commit is contained in:
+19
-2
@@ -111,14 +111,31 @@ def _extract_report_date(raw: bytes) -> str | None:
|
||||
|
||||
def refresh_account(cfg: dict, account_folder: str, label: str = "") -> dict:
|
||||
"""Download, parse, cache one account. Returns {df, stats, error}."""
|
||||
import traceback
|
||||
from mt5_parser import detect_and_parse, calc_stats
|
||||
|
||||
raw = ftp_download_report(cfg, account_folder)
|
||||
if raw is None:
|
||||
st.warning(f"[{account_folder}] ftp_download_report returned None")
|
||||
return {"error": f"No report found for {account_folder}"}
|
||||
df, fmt = detect_and_parse(raw, f"{account_folder}.htm")
|
||||
|
||||
st.write(f"[{account_folder}] raw bytes: {len(raw)}, first 4 bytes: {raw[:4]}")
|
||||
|
||||
try:
|
||||
df, fmt = detect_and_parse(raw, f"{account_folder}.htm")
|
||||
except Exception as e:
|
||||
st.error(f"[{account_folder}] detect_and_parse raised: {e}")
|
||||
st.code(traceback.format_exc())
|
||||
return {"error": str(e)}
|
||||
|
||||
st.write(f"[{account_folder}] fmt={fmt}, df={'None' if df is None else f'shape {df.shape}'}")
|
||||
|
||||
if df is None:
|
||||
st.warning(f"[{account_folder}] detect_and_parse returned None df")
|
||||
return {"error": f"Could not parse report for {account_folder}"}
|
||||
|
||||
stats = calc_stats(df) if not df.empty else {}
|
||||
|
||||
from mt5_parser import parse_open_positions
|
||||
df_open = parse_open_positions(raw)
|
||||
|
||||
@@ -689,7 +706,7 @@ cache/
|
||||
|
||||
card = (
|
||||
'<div style="background:rgba(255,255,255,0.03);border:1px solid rgba(255,255,255,0.07);'
|
||||
'border-radius:8px;padding:12px 16px;flex:1;min-width:220px">'
|
||||
'border-radius:8px;padding:12px 16px;flex:0 0 280px;min-width:280px;max-width:280px">'
|
||||
f'<div style="display:flex;justify-content:space-between;align-items:center;margin-bottom:4px">'
|
||||
f'<span style="font-size:15px;font-weight:600">{d["label"]}</span>'
|
||||
f'<span style="font-size:12px;padding:2px 8px;border-radius:4px;background:{badge_bg};font-weight:600">{acc_type}</span>'
|
||||
|
||||
Reference in New Issue
Block a user