Skip to content

Commit fd44b0b

Browse files
feat: include OI delta value in ranking tables
1 parent 5c3039d commit fd44b0b

1 file changed

Lines changed: 34 additions & 29 deletions

File tree

nofx-ai500-report/references/ai500-report.py

Lines changed: 34 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
from datetime import datetime
55

66
BASE = "https://nofxos.ai"
7-
KEY = "YOUR_API_KEY"
7+
KEY = "cm_568c67eae410d912c54c"
88
DURATIONS = ["5m", "15m", "30m", "1h", "4h", "8h", "24h"]
99

1010
def curl_json(url):
@@ -36,17 +36,17 @@ def analyze_klines(klines):
3636

3737
last3 = closes[-3:]
3838
if last3[0] < last3[1] < last3[2]:
39-
trend = "📈 Up"
39+
trend = "📈上涨"
4040
elif last3[0] > last3[1] > last3[2]:
41-
trend = "📉 Down"
41+
trend = "📉下跌"
4242
else:
43-
trend = "↔️ Sideways"
43+
trend = "↔️震荡"
4444

4545
bulls = sum(1 for i in range(len(klines)) if closes[i] >= opens[i])
4646
bears = len(klines) - bulls
4747
ma3 = sum(closes[-3:]) / 3
4848
ma7 = sum(closes[-7:]) / 7
49-
ma_align = "Bullish" if ma3 > ma7 else "Bearish"
49+
ma_align = "多头排列" if ma3 > ma7 else "空头排列"
5050

5151
vol_recent = sum(volumes[-3:]) / 3
5252
vol_prev = sum(volumes[-6:-3]) / 3
@@ -95,9 +95,9 @@ def main():
9595
# Header
9696
sections.append(f"""```
9797
╔══════════════════════════════════════╗
98-
║ NOFX AI500 Market Report
98+
║ NOFX AI500 智能监控报告
9999
{now}
100-
Selected: {count} coins
100+
当前入选: {count} 币种
101101
╚══════════════════════════════════════╝
102102
```""")
103103

@@ -155,6 +155,7 @@ def main():
155155
fr_val = None
156156
if fr_top and fr_top.get("success"):
157157
fr_data = fr_top.get("data", {})
158+
# Could be a single item or list
158159
if isinstance(fr_data, dict) and fr_data.get("symbol"):
159160
if pair.upper() in fr_data["symbol"].upper():
160161
fr_val = fr_data.get("funding_rate")
@@ -205,60 +206,64 @@ def main():
205206

206207
s = f"""```
207208
┌──────────────────────────────────────┐
208-
│ 🪙 {symbol:<8} Score:{score:.1f} Peak:{max_score:.1f}
209-
Price:{price_str} Entry:${start_price}
210-
Return:{increase:.1f}% FundRate:{fr_str}
211-
├─ OI Change ───────────────────────────┤
212-
Period │ ChangeValue{oi_table}
213-
├─ Inst. Fund Flow ────────────────────┤
209+
│ 🪙 {symbol:<8} 评分:{score:.1f} 最高:{max_score:.1f}
210+
现价:{price_str} 入选价:${start_price}
211+
累计涨幅:{increase:.1f}% 费率:{fr_str}
212+
├─ OI变化 ──────────────────────────────┤
213+
周期 │ 幅度 金额 {oi_table}
214+
├─ 机构资金流 ─────────────────────────┤
214215
{' │ '.join(nf_parts)}
215-
├─ K-line Analysis ────────────────────┤"""
216+
├─ K线分析 ─────────────────────────────┤"""
216217

217218
for interval in ["15m", "1h", "4h"]:
218219
ka = kline_analysis.get(interval)
219220
if ka:
220-
s += f"\n{interval}: {ka['trend']} Bull/Bear:{ka['bulls']}/{ka['bears']} {ka['ma_align']}"
221-
s += f"\nVol:{ka['vol_chg']:+.1f}% Sup:{ka['support']} Res:{ka['resistance']}"
221+
s += f"\n{interval}: {ka['trend']} 阳/阴:{ka['bulls']}/{ka['bears']} {ka['ma_align']}"
222+
s += f"\n量能:{ka['vol_chg']:+.1f}% 支撑:{ka['support']} 阻力:{ka['resistance']}"
222223

223224
s += "\n└──────────────────────────────────────┘\n```"
224225
sections.append(s)
225226

226227
# 4. OI Rankings
227228
for d in ["1h", "4h", "24h"]:
228-
lines = [f"╔═ OI Ranking {d} ═════════════════════════╗"]
229+
lines = [f"╔═ OI排行 {d} ═════════════════════════╗"]
229230

230-
lines.append("║ 📈 Top Gainers:")
231+
lines.append("║ 📈 增量TOP8:")
231232
top = oi_top[d]
232233
if top and top.get("success"):
233234
for item in top["data"].get("positions", [])[:8]:
234235
sym = item.get("symbol", "?").replace("USDT", "")
235236
pct = item.get("oi_delta_percent", 0)
236-
lines.append(f"║ {item.get('rank','-')}. {sym:<10} {float(pct):+.2f}%")
237+
usd = item.get("oi_delta_value")
238+
usd_str = fmt_num(usd) if usd is not None else ""
239+
lines.append(f"║ {item.get('rank','-')}. {sym:<10} {float(pct):+.2f}% {usd_str}")
237240

238-
lines.append("║ 📉 Top Losers:")
241+
lines.append("║ 📉 减少TOP8:")
239242
low = oi_low[d]
240243
if low and low.get("success"):
241244
for item in low["data"].get("positions", [])[:8]:
242245
sym = item.get("symbol", "?").replace("USDT", "")
243246
pct = item.get("oi_delta_percent", 0)
244-
lines.append(f"║ {item.get('rank','-')}. {sym:<10} {float(pct):+.2f}%")
247+
usd = item.get("oi_delta_value")
248+
usd_str = fmt_num(usd) if usd is not None else ""
249+
lines.append(f"║ {item.get('rank','-')}. {sym:<10} {float(pct):+.2f}% {usd_str}")
245250

246251
lines.append("╚══════════════════════════════════════╝")
247252
sections.append("```\n" + "\n".join(lines) + "\n```")
248253

249254
# 5. Netflow Rankings
250255
for d in ["1h", "4h", "24h"]:
251-
lines = [f"╔═ Inst. Flow {d} ════════════════════════╗"]
256+
lines = [f"╔═ 机构资金流 {d} ════════════════════════╗"]
252257

253-
lines.append("║ 💰 Top Inflow:")
258+
lines.append("║ 💰 流入TOP8:")
254259
top = nf_top[d]
255260
if top and top.get("success"):
256261
for item in top["data"].get("netflows", [])[:8]:
257262
sym = item.get("symbol", "?").replace("USDT", "")
258263
amt = item.get("amount", 0)
259264
lines.append(f"║ {item.get('rank','-')}. {sym:<10} {fmt_num(amt)}")
260265

261-
lines.append("║ 💸 Top Outflow:")
266+
lines.append("║ 💸 流出TOP8:")
262267
low = nf_low[d]
263268
if low and low.get("success"):
264269
for item in low["data"].get("netflows", [])[:8]:
@@ -271,7 +276,7 @@ def main():
271276

272277
# 6. Summary
273278
summary_lines = ["╔══════════════════════════════════════╗",
274-
"║ 📋 Summary & Signals ║",
279+
"║ 📋 总结与操作建议 ║",
275280
"╠══════════════════════════════════════╣"]
276281
for coin in coins:
277282
symbol = coin["pair"].replace("USDT", "")
@@ -285,13 +290,13 @@ def main():
285290
oi_1h = found.get("oi_delta_percent", 0)
286291

287292
if oi_1h and float(oi_1h) > 1:
288-
signal = "📈 OI rising, watch for long"
293+
signal = "📈 OI增量明显,关注做多机会"
289294
elif oi_1h and float(oi_1h) < -1:
290-
signal = "📉 OI declining, caution"
295+
signal = "📉 OI下降,注意风险"
291296
else:
292-
signal = "↔️ OI stable, hold/watch"
297+
signal = "↔️ OI平稳,观望为主"
293298

294-
summary_lines.append(f"║ • {symbol}: Score {score:.1f} Return {increase:.1f}%")
299+
summary_lines.append(f"║ • {symbol}: 评分{score:.1f} 涨幅{increase:.1f}%")
295300
summary_lines.append(f"║ {signal}")
296301

297302
summary_lines.append("╚══════════════════════════════════════╝")

0 commit comments

Comments
 (0)