INNER CODE UNIT · Python
_ma_cell
renee-jia/trading-bot · ai_portfolio.py:83
def _ma_cell(price, ma):
"""Level plus where price sits relative to it."""
if ma is None:
return "—"
if price is None:
return _money(ma)
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"):