INNER CODE UNIT · Python

_money

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

def _money(v):
    return "—" if v is None else f"${v:,.0f}" if v >= 100 else f"${v:,.2f}"


def _pct(v, digits=1):
    return "—" if v is None else f"{v:+.{digits}f}%"


def _levels(hist):
    """SMA20 / SMA50 / SMA200 / 21-day low / tape fallbacks from 1y history."""
    closes = hist["Close"].dropna()
    out = {"sma_20": None, "sma_50": None, "sma_200": None, "low_21d": None,
           "change_1d": None, "from_high": None, "rsi": None}
    if len(closes) >= 2:
        out["change_1d"] = float((closes.iloc[-1] / closes.iloc[-2] - 1) * 100)
        out["from_high"] = float((closes.iloc[-1] / closes.max() - 1) * 100)
    if len(closes) >= 15:
        diff = closes.diff().dropna().tail(14)

View source record →

📰 Research Paper
Loading…
⏳ Fetching content…