INNER CODE UNIT · Python
gap
renee-jia/trading-bot · ai_portfolio.py:89
gap = (price / ma - 1) * 100
return f"{_money(ma)} ({'↑' if gap >= 0 else '↓'}{abs(gap):.0f}%)"
def _item(n, row, card, plan):
ind = (row or {}).get("indicators") or {}
sr = (row or {}).get("score_result") or {}
price = _num(ind.get("price")) if row else _num((plan or {}).get("spot"))
levels = (plan or {}).get("levels") or {}
pick = (plan or {}).get("pick")
earnings = (plan or {}).get("earnings")
if hasattr(earnings, "strftime"):
earnings = earnings.strftime("%Y-%m-%d")
return {
"ticker": n,
"layer": LAYER.get(n, ""),
"name": (row or {}).get("name") or (plan or {}).get("name")
or (UNIVERSE.get(n) or {}).get("name") or n,