META={"id":"dip-buyer","name":"Dip Diver (Mean Reversion)","author":"house","style":"Mean reversion",
"desc":"Weekly: buys the 3 income ETFs with the worst 10-day drop (must be down >=5%); otherwise holds equal-weight SPY."}
def strategy(ctx):
    if ctx.i%5 and ctx.weights: return None
    r=sorted([(ctx.ret(s,10),s) for s in (ctx.income_available() or ctx.available()) if ctx.ret(s,10) is not None])
    dips=[s for v,s in r[:3] if v<=-0.05]
    return {s:1/len(dips) for s in dips} if dips else ({"SPY":1.0} if "SPY" in ctx.universe else {})
