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:
@@ -8,6 +8,7 @@ from sqlalchemy import (
|
||||
DateTime,
|
||||
Float,
|
||||
ForeignKey,
|
||||
Index,
|
||||
Integer,
|
||||
String,
|
||||
Text,
|
||||
@@ -84,6 +85,12 @@ class Candle(Base):
|
||||
|
||||
class BotTrade(Base):
|
||||
__tablename__ = "bot_trades"
|
||||
__table_args__ = (
|
||||
# Composite index for the two most common query patterns:
|
||||
# circuit_breaker: WHERE wallet_address=? AND closed_at>=? AND pnl_usd IS NOT NULL
|
||||
# trades API: WHERE wallet_address=? ORDER BY closed_at DESC
|
||||
Index("ix_bot_trades_wallet_closed", "wallet_address", "closed_at"),
|
||||
)
|
||||
|
||||
id: Mapped[int] = mapped_column(Integer, primary_key=True, index=True)
|
||||
asset: Mapped[str] = mapped_column(String(8), nullable=False)
|
||||
@@ -242,6 +249,12 @@ class Subscription(Base):
|
||||
# acknowledges + clears a tripped circuit breaker (human-in-the-loop).
|
||||
auto_trade: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
|
||||
# ── Module on/off toggles ───────────────────────────────────────────────
|
||||
# Both default False so newly-subscribed users start with the bot idle
|
||||
# until they explicitly enable a module and save settings.
|
||||
trump_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
macro_enabled: Mapped[bool] = mapped_column(Boolean, nullable=False, default=False)
|
||||
|
||||
|
||||
class KolPost(Base):
|
||||
"""A long-form post (Substack) or tweet from a tracked KOL, with inline
|
||||
|
||||
Reference in New Issue
Block a user