"""Growth-discipline blend: w·QQQ + (1−w)·multistrat book, on the intersection of their dates. Pure."""
from __future__ import annotations

from fxhnt.domain.strategies import multistrat


def daily_returns(qqq: dict[str, float], multistrat_closes: dict[str, dict[str, float]],
                  w_equity: float = 0.70) -> list[tuple[str, float]]:
    ms = dict(multistrat.book_series(multistrat_closes))
    qdates = sorted(qqq)
    # Intentional alignment choice vs foxhunt original: foxhunt samples QQQ on the book's date grid;
    # this port computes QQQ returns on QQQ's own consecutive dates then intersects with the book dates.
    # Identical on a clean shared trading calendar; on a data hole this drops the gap day's move rather
    # than bridging it as a mislabelled 1-day return.
    qret = {qdates[i]: qqq[qdates[i]] / qqq[qdates[i - 1]] - 1.0 for i in range(1, len(qdates))}
    common = sorted(set(ms) & set(qret))
    return [(d, w_equity * qret[d] + (1.0 - w_equity) * ms[d]) for d in common]
