META={"id":"momentum","name":"Trend Rider (Momentum)","author":"house","style":"Momentum",
"desc":"Every 10 trading days, holds the 3 assets (incl. SPY, BTC) with the best 20-day return; cash if all negative."}
def strategy(ctx):
    if ctx.i%10 and ctx.weights: return None
    r=sorted([(ctx.ret(s,20),s) for s in ctx.available() if ctx.ret(s,20) is not None],reverse=True)
    top=[s for v,s in r[:3] if v>0]
    return {s:1/len(top) for s in top} if top else {}
