INNER CODE UNIT · Python

buy_levels

renee-jia/trading-bot · ai_sell_put_plan.py:139

def buy_levels(spot, lv, ladder=None):
    """Three descending buy levels: 回踩 / 分批 / 接股."""
    if spot is None:
        return None
    s20, s50, low = lv.get("sma_20"), lv.get("sma_50"), lv.get("low_21d")
    l1 = s20 if s20 is not None and s20 < spot else spot * EARLY_STRIKE_PCT
    l2 = s50 if s50 is not None and s50 < l1 else l1 * 0.96
    l3 = low if low is not None and low < l2 else l2 * 0.96
    put_strike = min((x["strike"] for x in (ladder or [])), default=None)
    if put_strike is not None and put_strike < l3:
        l3 = put_strike
    return {"l1": l1, "l2": l2, "l3": l3}


def decide_entry(card, r, event, trend, held, vrp):
    """建仓 stance: whether this name should be entered via short puts."""
    score = card.get("score")
    if r is None or r.get("spot") is None:

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…