"""Pure 60/40 daily-rebalanced return: for each consecutive date pair, the weighted mean of per-asset
returns on adjusted closes. No I/O."""
from __future__ import annotations


def daily_returns(closes: dict[str, dict[str, float]], weights: list[tuple[str, float]]) -> list[tuple[str, float]]:
    syms = [s for s, _ in weights]
    dates = sorted(set.intersection(*[set(closes[s]) for s in syms]))
    out: list[tuple[str, float]] = []
    for i in range(1, len(dates)):
        d, dprev = dates[i], dates[i - 1]
        r = sum(w * (closes[s][d] / closes[s][dprev] - 1.0) for s, w in weights)
        out.append((d, r))
    return out
