Spaces:
Running
Running
Update src/services/spot_engine.py
Browse files- src/services/spot_engine.py +67 -27
src/services/spot_engine.py
CHANGED
|
@@ -59,15 +59,15 @@ def spot_volume_tracker(user_keys, user_id) -> None:
|
|
| 59 |
|
| 60 |
def create_html_report(hot_tokens: List[Dict[str, Any]]) -> str:
|
| 61 |
"""
|
| 62 |
-
Generates
|
| 63 |
-
|
| 64 |
"""
|
| 65 |
date_prefix = datetime.datetime.now().strftime("%b-%d-%y_%H-%M")
|
| 66 |
user_dir = get_user_temp_dir(user_id)
|
| 67 |
html_file = user_dir / f"Spot_Analysis_Report_{date_prefix}.html"
|
| 68 |
current_time = now_str("%d-%m-%Y %H:%M:%S")
|
| 69 |
|
| 70 |
-
#
|
| 71 |
max_flip = max((t.get('flipping_multiple', 0) for t in hot_tokens), default=0)
|
| 72 |
large_cap_count = len([t for t in hot_tokens if t.get('large_cap')])
|
| 73 |
|
|
@@ -97,73 +97,102 @@ def spot_volume_tracker(user_keys, user_id) -> None:
|
|
| 97 |
}}
|
| 98 |
.header {{
|
| 99 |
background: linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
|
| 100 |
-
padding:
|
| 101 |
text-align: center;
|
| 102 |
border-bottom: 1px solid var(--border);
|
| 103 |
}}
|
| 104 |
-
.header h1 {{ margin: 0; font-size: 1.
|
| 105 |
-
.header p {{ margin:
|
| 106 |
|
| 107 |
.summary {{
|
| 108 |
background: var(--bg-card);
|
| 109 |
-
padding:
|
| 110 |
-
margin:
|
| 111 |
border-radius: 12px;
|
| 112 |
border: 1px solid var(--border);
|
| 113 |
-
font-size: 0.
|
| 114 |
-
line-height: 1.
|
|
|
|
| 115 |
}}
|
| 116 |
.summary b {{ color: var(--accent-green); }}
|
| 117 |
|
| 118 |
.table-container {{
|
| 119 |
-
|
| 120 |
-
margin: 0 20px;
|
| 121 |
border-radius: 12px;
|
| 122 |
border: 1px solid var(--border);
|
| 123 |
background: var(--bg-card);
|
|
|
|
| 124 |
}}
|
| 125 |
-
table {{ width: 100%; border-collapse: collapse; }}
|
|
|
|
| 126 |
th {{
|
| 127 |
background: rgba(0, 0, 0, 0.2);
|
| 128 |
color: var(--text-dim);
|
| 129 |
-
padding:
|
| 130 |
text-align: left;
|
| 131 |
-
font-size: 0.
|
| 132 |
text-transform: uppercase;
|
| 133 |
letter-spacing: 1px;
|
| 134 |
border-bottom: 1px solid var(--border);
|
|
|
|
| 135 |
}}
|
| 136 |
td {{
|
| 137 |
padding: 0;
|
| 138 |
border-bottom: 1px solid #2b3139;
|
| 139 |
-
height:
|
| 140 |
vertical-align: middle;
|
| 141 |
-
font-size: 0.
|
|
|
|
| 142 |
}}
|
| 143 |
tr:last-child td {{ border-bottom: none; }}
|
| 144 |
|
| 145 |
-
/* Large Cap Highlight Style */
|
| 146 |
tr.large-cap {{ background: rgba(16, 185, 129, 0.03); }}
|
| 147 |
tr.large-cap td:first-child {{ border-left: 3px solid var(--accent-green); }}
|
| 148 |
|
| 149 |
-
/*
|
| 150 |
.ticker-btn {{
|
| 151 |
-
display: block; width: 100%; height: 100%; padding:
|
| 152 |
color: var(--accent-green); text-decoration: none; font-weight: 800;
|
| 153 |
box-sizing: border-box; transition: background 0.2s;
|
| 154 |
}}
|
| 155 |
.ticker-btn:active {{ background: rgba(16, 185, 129, 0.1); }}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 156 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 157 |
.mono {{ font-family: 'JetBrains Mono', monospace; }}
|
| 158 |
.vol-high {{ color: #ef4444; font-weight: bold; }}
|
| 159 |
|
| 160 |
.footer {{
|
| 161 |
text-align: center;
|
| 162 |
-
padding:
|
| 163 |
font-size: 0.75rem;
|
| 164 |
color: var(--text-dim);
|
| 165 |
border-top: 1px solid var(--border);
|
| 166 |
-
margin-top: 20px;
|
| 167 |
}}
|
| 168 |
</style>
|
| 169 |
</head>
|
|
@@ -181,8 +210,12 @@ def spot_volume_tracker(user_keys, user_id) -> None:
|
|
| 181 |
<table>
|
| 182 |
<thead>
|
| 183 |
<tr>
|
| 184 |
-
<th style="width:
|
| 185 |
-
<th>Ticker</th>
|
|
|
|
|
|
|
|
|
|
|
|
|
| 186 |
</thead>
|
| 187 |
<tbody>
|
| 188 |
"""
|
|
@@ -193,15 +226,17 @@ def spot_volume_tracker(user_keys, user_id) -> None:
|
|
| 193 |
vtmr = token.get('flipping_multiple', 0)
|
| 194 |
vol_class = "vol-high" if vtmr >= 2 else ""
|
| 195 |
sym = token.get('symbol', '???')
|
|
|
|
|
|
|
| 196 |
link = f'<a href="/deep-diver?ticker={sym}" class="ticker-btn">{sym}</a>'
|
| 197 |
|
| 198 |
html_content += f"""
|
| 199 |
<tr class="{row_class}">
|
| 200 |
<td style="text-align:center; color:var(--text-dim);" class="mono">#{i+1}</td>
|
| 201 |
<td>{link}</td>
|
| 202 |
-
<td style="padding-left:
|
| 203 |
-
<td style="padding-left:
|
| 204 |
-
<td class="mono {vol_class}" style="padding-left:
|
| 205 |
</tr>
|
| 206 |
"""
|
| 207 |
|
|
@@ -209,6 +244,11 @@ def spot_volume_tracker(user_keys, user_id) -> None:
|
|
| 209 |
</tbody>
|
| 210 |
</table>
|
| 211 |
</div>
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 212 |
<div class="footer">
|
| 213 |
Report by QuantVat using SpotVolTracker v2.6
|
| 214 |
</div>
|
|
|
|
| 59 |
|
| 60 |
def create_html_report(hot_tokens: List[Dict[str, Any]]) -> str:
|
| 61 |
"""
|
| 62 |
+
Generates the 'Ultimate' branded HTML report.
|
| 63 |
+
Features: Fluid scaling for all screens, no-wrap data, and integrated navigation.
|
| 64 |
"""
|
| 65 |
date_prefix = datetime.datetime.now().strftime("%b-%d-%y_%H-%M")
|
| 66 |
user_dir = get_user_temp_dir(user_id)
|
| 67 |
html_file = user_dir / f"Spot_Analysis_Report_{date_prefix}.html"
|
| 68 |
current_time = now_str("%d-%m-%Y %H:%M:%S")
|
| 69 |
|
| 70 |
+
# Summary Metrics Calculation
|
| 71 |
max_flip = max((t.get('flipping_multiple', 0) for t in hot_tokens), default=0)
|
| 72 |
large_cap_count = len([t for t in hot_tokens if t.get('large_cap')])
|
| 73 |
|
|
|
|
| 97 |
}}
|
| 98 |
.header {{
|
| 99 |
background: linear-gradient(180deg, rgba(16, 185, 129, 0.1) 0%, transparent 100%);
|
| 100 |
+
padding: 30px 15px;
|
| 101 |
text-align: center;
|
| 102 |
border-bottom: 1px solid var(--border);
|
| 103 |
}}
|
| 104 |
+
.header h1 {{ margin: 0; font-size: 1.3rem; color: var(--accent-green); font-weight: 800; text-transform: uppercase; }}
|
| 105 |
+
.header p {{ margin: 8px 0 0; font-size: 0.8rem; color: var(--text-dim); font-family: 'JetBrains Mono', monospace; }}
|
| 106 |
|
| 107 |
.summary {{
|
| 108 |
background: var(--bg-card);
|
| 109 |
+
padding: 15px;
|
| 110 |
+
margin: 15px;
|
| 111 |
border-radius: 12px;
|
| 112 |
border: 1px solid var(--border);
|
| 113 |
+
font-size: 0.85rem;
|
| 114 |
+
line-height: 1.5;
|
| 115 |
+
text-align: center;
|
| 116 |
}}
|
| 117 |
.summary b {{ color: var(--accent-green); }}
|
| 118 |
|
| 119 |
.table-container {{
|
| 120 |
+
margin: 0 10px;
|
|
|
|
| 121 |
border-radius: 12px;
|
| 122 |
border: 1px solid var(--border);
|
| 123 |
background: var(--bg-card);
|
| 124 |
+
overflow: hidden; /* Manage fit via scaling, not scrolling */
|
| 125 |
}}
|
| 126 |
+
table {{ width: 100%; border-collapse: collapse; table-layout: fixed; }}
|
| 127 |
+
|
| 128 |
th {{
|
| 129 |
background: rgba(0, 0, 0, 0.2);
|
| 130 |
color: var(--text-dim);
|
| 131 |
+
padding: 12px 5px;
|
| 132 |
text-align: left;
|
| 133 |
+
font-size: 0.65rem;
|
| 134 |
text-transform: uppercase;
|
| 135 |
letter-spacing: 1px;
|
| 136 |
border-bottom: 1px solid var(--border);
|
| 137 |
+
white-space: nowrap;
|
| 138 |
}}
|
| 139 |
td {{
|
| 140 |
padding: 0;
|
| 141 |
border-bottom: 1px solid #2b3139;
|
| 142 |
+
height: 52px;
|
| 143 |
vertical-align: middle;
|
| 144 |
+
font-size: 0.85rem;
|
| 145 |
+
white-space: nowrap; /* Prevent data wrap */
|
| 146 |
}}
|
| 147 |
tr:last-child td {{ border-bottom: none; }}
|
| 148 |
|
|
|
|
| 149 |
tr.large-cap {{ background: rgba(16, 185, 129, 0.03); }}
|
| 150 |
tr.large-cap td:first-child {{ border-left: 3px solid var(--accent-green); }}
|
| 151 |
|
| 152 |
+
/* Redirection Link Button */
|
| 153 |
.ticker-btn {{
|
| 154 |
+
display: block; width: 100%; height: 100%; padding: 14px 8px;
|
| 155 |
color: var(--accent-green); text-decoration: none; font-weight: 800;
|
| 156 |
box-sizing: border-box; transition: background 0.2s;
|
| 157 |
}}
|
| 158 |
.ticker-btn:active {{ background: rgba(16, 185, 129, 0.1); }}
|
| 159 |
+
|
| 160 |
+
/* Fluid Scaling Logic for Mobile */
|
| 161 |
+
@media (max-width: 480px) {{
|
| 162 |
+
td {{ font-size: 0.72rem; }}
|
| 163 |
+
th {{ font-size: 0.58rem; padding: 10px 4px; }}
|
| 164 |
+
.ticker-btn {{ padding: 10px 4px !important; }}
|
| 165 |
+
.mono {{ font-size: 0.68rem; }}
|
| 166 |
+
.header h1 {{ font-size: 1.1rem; }}
|
| 167 |
+
.summary {{ font-size: 0.75rem; margin: 10px; }}
|
| 168 |
+
}}
|
| 169 |
|
| 170 |
+
/* Dashboard Navigation Button */
|
| 171 |
+
.nav-box {{ text-align: center; margin: 30px 0; }}
|
| 172 |
+
.back-btn {{
|
| 173 |
+
display: inline-flex;
|
| 174 |
+
align-items: center;
|
| 175 |
+
padding: 12px 24px;
|
| 176 |
+
background: transparent;
|
| 177 |
+
border: 1px solid var(--text-dim);
|
| 178 |
+
color: var(--text-dim);
|
| 179 |
+
border-radius: 8px;
|
| 180 |
+
text-decoration: none;
|
| 181 |
+
font-weight: 800;
|
| 182 |
+
font-size: 0.85rem;
|
| 183 |
+
transition: all 0.2s;
|
| 184 |
+
}}
|
| 185 |
+
.back-btn:hover {{ border-color: #fff; color: #fff; background: rgba(255,255,255,0.05); }}
|
| 186 |
+
|
| 187 |
.mono {{ font-family: 'JetBrains Mono', monospace; }}
|
| 188 |
.vol-high {{ color: #ef4444; font-weight: bold; }}
|
| 189 |
|
| 190 |
.footer {{
|
| 191 |
text-align: center;
|
| 192 |
+
padding: 30px 20px;
|
| 193 |
font-size: 0.75rem;
|
| 194 |
color: var(--text-dim);
|
| 195 |
border-top: 1px solid var(--border);
|
|
|
|
| 196 |
}}
|
| 197 |
</style>
|
| 198 |
</head>
|
|
|
|
| 210 |
<table>
|
| 211 |
<thead>
|
| 212 |
<tr>
|
| 213 |
+
<th style="width: 12%; text-align:center;">#</th>
|
| 214 |
+
<th style="width: 25%;">Ticker</th>
|
| 215 |
+
<th style="width: 23%;">Market Cap</th>
|
| 216 |
+
<th style="width: 22%;">Volume</th>
|
| 217 |
+
<th style="width: 18%;">Spot VTMR</th>
|
| 218 |
+
</tr>
|
| 219 |
</thead>
|
| 220 |
<tbody>
|
| 221 |
"""
|
|
|
|
| 226 |
vtmr = token.get('flipping_multiple', 0)
|
| 227 |
vol_class = "vol-high" if vtmr >= 2 else ""
|
| 228 |
sym = token.get('symbol', '???')
|
| 229 |
+
|
| 230 |
+
# redirection to Deep Diver
|
| 231 |
link = f'<a href="/deep-diver?ticker={sym}" class="ticker-btn">{sym}</a>'
|
| 232 |
|
| 233 |
html_content += f"""
|
| 234 |
<tr class="{row_class}">
|
| 235 |
<td style="text-align:center; color:var(--text-dim);" class="mono">#{i+1}</td>
|
| 236 |
<td>{link}</td>
|
| 237 |
+
<td style="padding-left:5px;" class="mono">${short_num(token.get('marketcap', 0))}</td>
|
| 238 |
+
<td style="padding-left:5px;" class="mono">${short_num(token.get('volume', 0))}</td>
|
| 239 |
+
<td class="mono {vol_class}" style="padding-left:5px;">{vtmr:.2f}x</td>
|
| 240 |
</tr>
|
| 241 |
"""
|
| 242 |
|
|
|
|
| 244 |
</tbody>
|
| 245 |
</table>
|
| 246 |
</div>
|
| 247 |
+
|
| 248 |
+
<div class="nav-box">
|
| 249 |
+
<a href="/home" class="back-btn">← BACK TO DASHBOARD</a>
|
| 250 |
+
</div>
|
| 251 |
+
|
| 252 |
<div class="footer">
|
| 253 |
Report by QuantVat using SpotVolTracker v2.6
|
| 254 |
</div>
|