INNER CODE UNIT · Python
cmd_train
initial-d/ml-quant-trading · src/mlquant/cli/main.py:255
def cmd_train(config_path: str) -> None:
cfg = load_config(config_path)
seed_everything(cfg.get("seed", 42))
art = _artifacts_dir(cfg)
panel = _load_panel(art)
feat_blob = torch.load(art / "features.pt", weights_only=False)
fwd_ret, _ = target_01(panel)
# Train only on dates before the out-of-sample window. Slicing to
# ``oos + 1`` keeps the label of the last training day (close at ``oos``),
# which is already known when the first out-of-sample signal is formed.
T = fwd_ret.shape[0]
oos = _oos_start(cfg, T)
ds = FactorDataset(
factors=feat_blob["factors"][: oos + 1],
mask=feat_blob["mask"][: oos + 1],
forward_returns=fwd_ret[: oos + 1],
)