INNER CODE UNIT · Python

_oos_start

initial-d/ml-quant-trading · src/mlquant/cli/main.py:79

def _oos_start(cfg, n_dates: int) -> int:
    """First out-of-sample date index; the model only trains on dates before it."""
    train_frac = float(cfg.get("train_frac", 0.6))
    if not 0.0 < train_frac < 1.0:
        raise click.BadParameter(f"train_frac must be in (0, 1), got {train_frac}")
    return max(1, min(n_dates - 2, int(n_dates * train_frac)))


def _date_str(value) -> str:
    return str(np.datetime_as_string(np.datetime64(value, "D")))


def _write_backtest_summary(
    output_dir: Path,
    metrics: dict,
    *,
    config_path: str,
    costs_bps: float,

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…