Skip to content

feat(discord): actionable trade idea alerts for prediction markets#99

Open
webframp wants to merge 5 commits intocalesthio:masterfrom
webframp:feat/actionable-idea-alerts
Open

feat(discord): actionable trade idea alerts for prediction markets#99
webframp wants to merge 5 commits intocalesthio:masterfrom
webframp:feat/actionable-idea-alerts

Conversation

@webframp
Copy link
Copy Markdown

Summary

Adds automatic Discord alerts for high-confidence, short-horizon trade ideas — designed for users acting on prediction markets (Kalshi, Polymarket, etc.) or short-term trades.

How It Works

After each sweep, if the LLM generates trade ideas, the new sendActionableIdeas() method filters for:

  • HIGH confidence only
  • Short horizon: Intraday, Days, or Weeks
  • Actionable types: LONG, SHORT, or HEDGE (not WATCH/AVOID)

Ideas that pass the filter are posted as rich Discord embeds.

What Each Alert Contains

Field Description
Ticker Primary instrument (e.g., BNO, GLD, SPY)
Direction LONG / SHORT / HEDGE with color-coded embed
Rationale LLM-generated explanation citing specific OSINT data
Risk Key risk factor for the thesis
Supporting Signals The raw signals that informed the idea
Prediction Market Angle Contextual suggestion for relevant contract types

The prediction market angle adapts to the asset class — oil, gold, rates, indexes, defense/geopolitical, crypto — with specific guidance rather than generic advice.

Deduplication

Same idea title won't re-alert for 6 hours, so sweeps every 15 minutes won't spam the channel with the same thesis.

Embed Styling

  • 🟢 Green = LONG
  • 🔴 Red = SHORT
  • ⚪ Gray = HEDGE

Changes

  • lib/alerts/discord.mjs: Added sendActionableIdeas(), _kalshiAngle(), and idea dedup logic
  • server.mjs: Wired into sweep cycle (step 7, after idea generation)

Example

Ideas that would trigger alerts from a typical sweep:

  • 📈 LONG BNO (Brent Crude) — HIGH confidence, Days horizon, backed by Middle East escalation signals
  • 📈 LONG GLD (Gold) — HIGH confidence, Days horizon, backed by geopolitical safe-haven demand

exe.dev user and others added 5 commits April 20, 2026 04:16
The custom .env parser did not handle quoted values, causing passwords
and API keys containing special characters (|, ^, ", >, [, etc.) to
include the quote characters as part of the value or parse incorrectly.

This adds quote stripping for both single and double-quoted values,
matching the behavior of dotenv and other standard .env parsers.

Co-authored-by: Shelley <shelley@exe.dev>
Slash command registration was called before client.login(), so
client.user.id was undefined and fell back to the string "me",
causing a Discord API error:

  Invalid Form Body
  application_id[NUMBER_TYPE_COERCE]: Value "me" is not snowflake.

This moves command registration into the ready event handler and
attaches that handler before login() to avoid a race condition
where the ready event fires before the listener is attached.

Co-authored-by: Shelley <shelley@exe.dev>
When running behind a reverse proxy or on a remote host, the /status
command in Telegram and Discord shows http://localhost:PORT which is
not reachable by users.

Adds a PUBLIC_URL env var that, when set, replaces the hardcoded
localhost URL in bot status responses. Falls back to localhost when
unset, so existing setups are unaffected.

Example: PUBLIC_URL=https://my-crucix.example.com
Co-authored-by: Shelley <shelley@exe.dev>
Three issues when using Gemini 2.5 Flash/Pro models:

1. Gemini 2.5 models return multi-part responses where the first part
   is a "thinking" part and the second is the actual content. The
   provider only read parts[0], getting thinking text instead of the
   response. Fixed by filtering out thought parts.

2. Thinking tokens consumed the maxOutputTokens budget, causing
   truncated JSON responses (cut mid-object). Added thinkingConfig
   with a 1024-token budget to keep reasoning concise, and bumped
   idea generation to 8192 output tokens.

3. The ideas response parser failed on Gemini output because it only
   handled code blocks at string boundaries. Rewrote to extract code
   blocks from anywhere in the response and fall back to finding the
   JSON array if no code block is present.

Co-authored-by: Shelley <shelley@exe.dev>
Adds automatic Discord alerts for HIGH confidence, short-horizon
(Intraday/Days/Weeks) trade ideas after each sweep. Designed for
users acting on prediction markets like Kalshi.

Each alert includes:
- Ticker, direction (LONG/SHORT/HEDGE), confidence, and horizon
- Full rationale and risk from the LLM analysis
- Supporting OSINT signals that back the thesis
- A prediction market angle suggesting relevant contract types
  (oil/gold/rates/indexes/defense/crypto with contextual guidance)

Features:
- Filters: only HIGH confidence + actionable types (LONG/SHORT/HEDGE)
- Dedup: same idea title suppressed for 6 hours
- Color-coded embeds: green=LONG, red=SHORT, gray=HEDGE
- Works with any LLM provider

Wired into the sweep cycle in server.mjs — fires after idea
generation, independent of the delta-based alert pipeline.

Co-authored-by: Shelley <shelley@exe.dev>
@webframp webframp requested a review from calesthio as a code owner April 20, 2026 05:22
@webframp
Copy link
Copy Markdown
Author

webframp commented Apr 20, 2026

An idea I worked through a bit but haven't fully used, since prediction market still seem super volatile to me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant