Spaces:
Running
Running
Upload pmct/digest.py with huggingface_hub
Browse files- pmct/digest.py +22 -9
pmct/digest.py
CHANGED
|
@@ -148,10 +148,20 @@ def _wallet_md(w: str) -> str:
|
|
| 148 |
return f"[{w[:6]}β¦{w[-4:]}](https://polymarket.com/profile/{w})"
|
| 149 |
|
| 150 |
|
| 151 |
-
def
|
| 152 |
-
"""
|
| 153 |
-
|
| 154 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 155 |
|
| 156 |
|
| 157 |
def render_markdown(selected: pd.DataFrame, moves: list[Move],
|
|
@@ -168,21 +178,24 @@ def render_markdown(selected: pd.DataFrame, moves: list[Move],
|
|
| 168 |
"",
|
| 169 |
"## Top moves right now",
|
| 170 |
"",
|
| 171 |
-
"_Signal
|
| 172 |
-
"
|
| 173 |
-
"
|
|
|
|
| 174 |
"verify it on Polymarket._",
|
| 175 |
"",
|
| 176 |
]
|
| 177 |
if not moves:
|
| 178 |
lines.append("_No qualifying fresh moves in the window. Check back next run._")
|
| 179 |
else:
|
|
|
|
|
|
|
| 180 |
lines.append("| Signal | Trader | Move | Price | Size | Conviction |")
|
| 181 |
lines.append("|---|---|---|---|---|---|")
|
| 182 |
-
for m in
|
| 183 |
title = (m.title[:46] + "β¦") if len(m.title) > 47 else m.title
|
| 184 |
lines.append(
|
| 185 |
-
f"| {
|
| 186 |
f"| {_wallet_md(m.wallet)} | {title} "
|
| 187 |
f"({m.outcome}) | {m.price:.2f} | ${m.usdc:,.0f} | {m.conviction:.0%} |"
|
| 188 |
)
|
|
|
|
| 148 |
return f"[{w[:6]}β¦{w[-4:]}](https://polymarket.com/profile/{w})"
|
| 149 |
|
| 150 |
|
| 151 |
+
def _rank_dots(vals: list[float]) -> list[str]:
|
| 152 |
+
"""Relative 1β5 dot rank WITHIN the shown batch, so the bars actually spread
|
| 153 |
+
instead of clustering (raw signals bunch around 0.5β0.7). Weakest shown move
|
| 154 |
+
gets βββββ, strongest βββββ, the rest spaced by percentile rank."""
|
| 155 |
+
n = len(vals)
|
| 156 |
+
if n == 0:
|
| 157 |
+
return []
|
| 158 |
+
order = sorted(range(n), key=lambda i: vals[i])
|
| 159 |
+
dots = [""] * n
|
| 160 |
+
for pos, i in enumerate(order):
|
| 161 |
+
pct = pos / (n - 1) if n > 1 else 1.0
|
| 162 |
+
k = 1 + int(round(pct * 4)) # 1..5
|
| 163 |
+
dots[i] = "β" * k + "β" * (5 - k)
|
| 164 |
+
return dots
|
| 165 |
|
| 166 |
|
| 167 |
def render_markdown(selected: pd.DataFrame, moves: list[Move],
|
|
|
|
| 178 |
"",
|
| 179 |
"## Top moves right now",
|
| 180 |
"",
|
| 181 |
+
"_Signal = our quality score for a move: the trader's consistency blended "
|
| 182 |
+
"with how big this bet is for them (conviction) and how far the price is "
|
| 183 |
+
"from a coin-flip (edge). Dots are a **relative rank among today's moves** β "
|
| 184 |
+
"βββββ = strongest signal in this list, βββββ = weakest. Tap any address to "
|
| 185 |
"verify it on Polymarket._",
|
| 186 |
"",
|
| 187 |
]
|
| 188 |
if not moves:
|
| 189 |
lines.append("_No qualifying fresh moves in the window. Check back next run._")
|
| 190 |
else:
|
| 191 |
+
shown = moves[:top_moves]
|
| 192 |
+
dot_bars = _rank_dots([m.signal_quality for m in shown])
|
| 193 |
lines.append("| Signal | Trader | Move | Price | Size | Conviction |")
|
| 194 |
lines.append("|---|---|---|---|---|---|")
|
| 195 |
+
for m, bar in zip(shown, dot_bars):
|
| 196 |
title = (m.title[:46] + "β¦") if len(m.title) > 47 else m.title
|
| 197 |
lines.append(
|
| 198 |
+
f"| {bar} {m.signal_quality:.2f} "
|
| 199 |
f"| {_wallet_md(m.wallet)} | {title} "
|
| 200 |
f"({m.outcome}) | {m.price:.2f} | ${m.usdc:,.0f} | {m.conviction:.0%} |"
|
| 201 |
)
|