CoolFace
Apppublic

BluefxPraise/The_Oracle

sourceHugging Faceupdated 5mo agoView on Hugging Face
0likes
csv_exporter.py33 linesDownload Raw Back to exports
1"""CSV exporter."""2 3import csv4import os5from datetime import datetime, timezone6from typing import List7 8import memory9 10EXPORT_DIR = "data/exports"11os.makedirs(EXPORT_DIR, exist_ok=True)12 13 14def export_signals_csv() -> str:15    rows = memory.recent_signals(limit=1000)16    fname = f"signals_{datetime.now(timezone.utc).strftime('%Y%m%d_%H%M%S')}.csv"17    path = os.path.join(EXPORT_DIR, fname)18    with open(path, "w", newline="", encoding="utf-8") as f:19        w = csv.writer(f)20        w.writerow([21            "id", "ts", "pair", "direction", "entry", "sl", "tp", "rr",22            "confidence", "regime", "status", "outcome", "pnl",23            "closed_ts", "broadcast", "observation", "reason",24        ])25        for r in rows:26            w.writerow([27                r["id"], r["ts"], r["pair"], r["direction"], r["entry"],28                r["sl"], r["tp"], r["rr"], r["confidence"], r["regime"],29                r["status"], r["outcome"], r["pnl"], r["closed_ts"],30                r["broadcast"], r["observation"], r["reason"],31            ])32    return path33