fix: pre-launch hardening — HYPE price feed, KOL wallet cleanup, Telegram Trump alert, rate limiting, brittle test
Batch of the pre-launch audit campaign (BUG-01…14 plus three new features): Pricing / TP-SL protection - Add app/services/hl_price_feed.py: supplemental HL allMids poller for HL-native assets (HYPE, PURR) not listed on Binance. Pumps price_store + tp_sl_monitor.on_price_tick so bot trades on these assets keep full stop-loss / take-profit / trailing protection instead of max-hold only. - Wire feed into main.py lifespan (startup task + graceful shutdown cancel). Telegram - Add format_trump_mention + PATH B in _dispatch: crypto-relevant Trump posts with no directional signal (relevant=True, signal=hold) now alert the public channel only (no per-subscriber noise). - Rate limiter (slowapi) on the API; assorted bot/digest fixes. KOL on-chain - seed_kol_wallets.py: KOL_FEEDS coverage cross-check; reversibly deactivate orphaned wallets (handle not in KOL_FEEDS → can never produce divergence) so the scanner stops burning cycles on them. Tests / misc - Fix brittle test_macro_ahr999_uses_same_formula_as_scanner: mock now uses realistic ms timestamps so the in-progress-day drop fires, matching the fetcher's bar count (was 0.3179 vs 0.3178 off-by-one). - Refresh stale notify_signal comment in truth_social.py. Frontend reduce-action type fix lives in the sibling repo. Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
This commit is contained in:
@@ -1,8 +1,12 @@
|
||||
"""
|
||||
把 AI 信号写回数据库。
|
||||
跳过纯RT/URL帖子和已有signal的帖子。
|
||||
并发执行提速,自动限速避免API超限。
|
||||
用法: python scripts/backfill_signals.py [--limit 500] [--overwrite]
|
||||
Backfill AI analysis onto historical Truth posts.
|
||||
|
||||
Safety rules:
|
||||
* Only re-analyze `source='truth'` rows. Technical/scanner posts already
|
||||
carry their own signal payloads and must not be sent through the Trump
|
||||
text analyzer.
|
||||
* Persist the full analysis payload so history doesn't become a mixed schema
|
||||
of old partial rows and new v5 rows.
|
||||
"""
|
||||
import asyncio
|
||||
import argparse
|
||||
@@ -38,8 +42,11 @@ async def process_one(post: Post, semaphore: asyncio.Semaphore, overwrite: bool)
|
||||
p.relevant = analysis["relevant"]
|
||||
p.prefilter_reason = analysis.get("prefilter_reason")
|
||||
p.analysis_version = analysis.get("analysis_version")
|
||||
if analysis["relevant"] and analysis["asset"] and not p.price_impact_asset:
|
||||
p.price_impact_asset = analysis["asset"]
|
||||
p.price_impact_asset = analysis["asset"] if analysis["relevant"] else None
|
||||
p.target_asset = analysis.get("target_asset")
|
||||
p.category = analysis.get("category")
|
||||
p.expected_move_pct = analysis.get("expected_move_pct")
|
||||
p.invalidation_price = analysis.get("invalidation_price")
|
||||
await db.commit()
|
||||
|
||||
sig = analysis["signal"]
|
||||
@@ -49,7 +56,10 @@ async def process_one(post: Post, semaphore: asyncio.Semaphore, overwrite: bool)
|
||||
async def main(limit: int, overwrite: bool):
|
||||
async with AsyncSessionLocal() as db:
|
||||
result = await db.execute(
|
||||
select(Post).order_by(Post.published_at.desc()).limit(limit)
|
||||
select(Post)
|
||||
.where(Post.source == "truth")
|
||||
.order_by(Post.published_at.desc())
|
||||
.limit(limit)
|
||||
)
|
||||
posts = result.scalars().all()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user