34 lines
1.4 KiB
Python
34 lines
1.4 KiB
Python
|
|
"""Dump first/last trade rows from each MT5 report to confirm test window."""
|
||
|
|
from pathlib import Path
|
||
|
|
from lxml import html
|
||
|
|
|
||
|
|
for label, fn in [("IS", "IS-ReportTester-52845377.html"), ("OOS", "OOS-ReportTester-52845377.html")]:
|
||
|
|
p = Path("reports") / fn
|
||
|
|
raw = p.read_bytes()
|
||
|
|
text = raw.decode("utf-16") if raw[:2] in (b"\xff\xfe", b"\xfe\xff") else raw.decode("utf-8", errors="replace")
|
||
|
|
tree = html.fromstring(text)
|
||
|
|
|
||
|
|
print(f"=== {label} ({fn}) ===")
|
||
|
|
# Trade rows have 13 cells (Time, Deal, Symbol, Type, Direction, Volume,
|
||
|
|
# Price, Order, Commission, Fee, Swap, Profit, Balance, Comment)
|
||
|
|
trade_rows = []
|
||
|
|
for row in tree.iter("tr"):
|
||
|
|
cells = row.findall("td")
|
||
|
|
if len(cells) != 13:
|
||
|
|
continue
|
||
|
|
# First cell is a timestamp like '2025.01.02 15:50:00'
|
||
|
|
first = (cells[0].text_content() or "").strip()
|
||
|
|
if "20" in first and ":" in first:
|
||
|
|
trade_rows.append([c.text_content().strip()[:30] for c in cells])
|
||
|
|
|
||
|
|
print(f" total trade rows: {len(trade_rows)}")
|
||
|
|
if trade_rows:
|
||
|
|
print(f" first 3 trades:")
|
||
|
|
for r in trade_rows[:3]:
|
||
|
|
print(f" {r[0]:<22} {r[3]:<5} {r[4]:<4} lots={r[5]:<6} price={r[6]:<10} pnl={r[10]:<8} bal={r[11]}")
|
||
|
|
print(f" last 3 trades:")
|
||
|
|
for r in trade_rows[-3:]:
|
||
|
|
print(f" {r[0]:<22} {r[3]:<5} {r[4]:<4} lots={r[5]:<6} price={r[6]:<10} pnl={r[10]:<8} bal={r[11]}")
|
||
|
|
print()
|
||
|
|
|