INNER CODE UNIT · Python

_paper_trades_file

aaryansinha16/AI-trader · backend/app.py:85

def _paper_trades_file(mode: str) -> Path:
    return _PAPER_TRADES_DIR / f"trades_{mode}.jsonl"


def _load_paper_trade_history():
    """Load closed paper trade history from JSONL files on startup."""
    global _closed_trades_by_mode
    _PAPER_TRADES_DIR.mkdir(exist_ok=True)
    for mode in ("test", "live"):
        fpath = _paper_trades_file(mode)
        if fpath.exists():
            try:
                trades = []
                for line in fpath.read_text().splitlines():
                    line = line.strip()
                    if line:
                        trades.append(json.loads(line))
                _closed_trades_by_mode[mode] = trades

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…