feat(x): viral live-prediction X auto-poster for Trump signals
When Trump posts an actionable buy/short signal, instantly tweet the call (entry/direction, hard time window, "ratio me" hook), then post a result follow-up X_FOLLOWUP_MINUTES later reporting the realised 15-min move plus a recent hit-rate brag with the site link. - New app/services/x_poster.py: OAuth 1.0a signed (stdlib hmac, no new dep, httpx reused). Fire-and-forget, fully degradable — no-op unless X creds + x_enabled. Dry-run logs tweet text. In-memory UTC-daily cap. 280-char hard cap on all templates (no Premium). - Gated to source=truth buy/short above x_min_confidence; scanner signals excluded (don't fit the "Trump just posted" format). - Hooked next to notify_signal in /signals/ingest + both Trump pollers (dedup via unique external_id → single tweet per post). - config.py + .env.example: X_API_KEY/SECRET, X_ACCESS_TOKEN/SECRET, X_ENABLED, X_MIN_CONFIDENCE, X_DAILY_CAP, X_FOLLOWUP_MINUTES, X_LINK_URL. 72 tests pass. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -64,6 +64,32 @@ class Settings(BaseSettings):
|
||||
# (no trading details, no /adopt CTA). Leave empty to disable.
|
||||
telegram_public_channel_id: str = ""
|
||||
|
||||
# ── X (Twitter) auto-poster ──────────────────────────────────────────────
|
||||
# OAuth 1.0a User Context — for posting from a single fixed bot account
|
||||
# (@TrumpAlpha_signals). Get all four from developer.x.com → your App →
|
||||
# "Keys and tokens". App permissions MUST be "Read and Write", and the
|
||||
# Access Token/Secret must be regenerated AFTER setting write permission.
|
||||
# Bearer Token / Client ID / Client Secret are NOT used (those are read /
|
||||
# OAuth2 web-flow credentials). Empty = X posting disabled (no-op).
|
||||
x_api_key: str = "" # = Consumer Key
|
||||
x_api_secret: str = "" # = Consumer Secret
|
||||
x_access_token: str = ""
|
||||
x_access_secret: str = ""
|
||||
# Master switch. Even with keys set, posting stays off unless this is true.
|
||||
# Lets you load creds without going live (dry-run = logs the tweet text).
|
||||
x_enabled: bool = False
|
||||
# Only post when ai_confidence >= this (0–100). Keeps low-quality noise off
|
||||
# the public timeline. Scanner signals carry their own score.
|
||||
x_min_confidence: int = 60
|
||||
# Hard daily cap on tweets (initial + follow-ups counted together) to stay
|
||||
# under Free-tier 1,500/mo and avoid spam flags. In-memory, resets at UTC
|
||||
# midnight. Single-process by design so a plain counter is safe.
|
||||
x_daily_cap: int = 40
|
||||
# Minutes after the initial prediction tweet to post the result follow-up.
|
||||
x_followup_minutes: int = 15
|
||||
# Public site URL appended to the follow-up tweet. Falls back to frontend_url.
|
||||
x_link_url: str = ""
|
||||
|
||||
model_config = {"env_file": ".env", "env_file_encoding": "utf-8", "extra": "ignore"}
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user