# engine/strategy.py
import numpy as np

def allocation(sp_price, gd_price, sp_sma, gd_sma,
               base=0.6, tilt_mult=1.5,
               max_tilt=0.25, min_eq=0.2, max_eq=0.9):

    rd = (sp_price / sp_sma) - (gd_price / gd_sma)
    tilt = np.clip(-rd * tilt_mult, -max_tilt, max_tilt)

    eq_w = np.clip(base * (1 + tilt), min_eq, max_eq)
    return eq_w, 1 - eq_w
