"""斐波计算(自 crypto_monitor 复制,期货共用)。""" def calc_fib_plan(direction, upper, lower, ratio): try: h = float(upper) l = float(lower) r = float(ratio) except (TypeError, ValueError): return None if h <= l or r <= 0 or r >= 1: return None span = h - l direction = (direction or "long").strip().lower() if direction == "short": entry = l + r * span return entry, h, l entry = h - r * span return entry, l, h