"""Deterministic synthetic OHLCV fixtures for worker tests. Every object here carries ``_synthetic: true`` and must never be used as a production fallback. Values are simple deterministic series so accounting assertions in backtest tests can be hand-verified. """ import pandas as pd _SYNTHETIC = {"_synthetic": True} def synthetic_daily(symbol: str = "SH#600000", start="2024-01-02", days=20, base=10.0, volume=1_000_000, extra_fields=True) -> pd.DataFrame: dates = pd.bdate_range(start, periods=days) rows = [] price = base for i, d in enumerate(dates): o = round(price, 2) c = round(price * 1.02, 2) if i % 2 == 0 else round(price * 0.98, 2) h = round(max(o, c) * 1.01, 2) l = round(min(o, c) * 0.99, 2) row = { "date": d.strftime("%Y-%m-%d"), "symbol": symbol, "open": o, "high": h, "low": l, "close": c, "volume": volume + i * 1000, } if extra_fields: # raw provider-style extra fields preserved verbatim row["amount"] = round((o + h + l + c) / 4 * (volume + i * 1000), 2) row["turnover"] = round(0.5 + i * 0.01, 3) rows.append(row) price = c df = pd.DataFrame(rows) df.attrs["synthetic"] = True return df SYNTH = _SYNTHETIC