Your personal intelligence agent. Watches the world from multiple data sources and pings you when something changes.
feat(discord): actionable trade idea alerts for prediction markets
exe.dev userfe188ea97dc3
diff --git a/lib/alerts/discord.mjs b/lib/alerts/discord.mjsindex 673a4a5..f0d9564 100644--- a/lib/alerts/discord.mjs+++ b/lib/alerts/discord.mjs@@ -421,6 +421,119 @@ export class DiscordAlerter {};}+ // ─── Kalshi-Style Actionable Idea Alerts ────────────────────────────────++ /**+ * Post HIGH confidence, short-horizon ideas as actionable Kalshi-style alerts.+ * @param {Array} ideas — LLM-generated ideas from the sweep+ */+ async sendActionableIdeas(ideas) {+ if (!this.isConfigured || !ideas?.length) return;+ if (this._isMuted()) return;++ // Filter: HIGH confidence + short horizon (Intraday or Days)+ const actionable = ideas.filter(i =>+ i.confidence === 'HIGH' &&+ ['Intraday', 'Days', 'Weeks'].includes(i.horizon) &&+ ['LONG', 'SHORT', 'HEDGE'].includes(i.type)+ );++ if (actionable.length === 0) return;++ // Dedup: don't re-alert the same idea title within 6 hours+ const now = Date.now();+ if (!this._alertedIdeas) this._alertedIdeas = new Map();+ const fresh = actionable.filter(idea => {+ const key = idea.title.toLowerCase().replace(/\s+/g, '-');+ const last = this._alertedIdeas.get(key);+ if (last && (now - last) < 6 * 60 * 60 * 1000) return false;+ this._alertedIdeas.set(key, now);+ return true;+ });++ if (fresh.length === 0) return;++ for (const idea of fresh) {+ const typeEmoji = { LONG: '📈', SHORT: '📉', HEDGE: '🛡️' }[idea.type] || '👁️';+ const horizonEmoji = { Intraday: '⚡', Days: '📅', Weeks: '🗓️' }[idea.horizon] || '⏳';++ const embed = this._embed(+ `${typeEmoji} ACTIONABLE: ${idea.title}`,+ `**${idea.type}** ${idea.ticker} · Confidence: 🟢 HIGH · Horizon: ${horizonEmoji} ${idea.horizon}\n\n` ++ `${idea.rationale}\n\n` ++ `⚠️ **Risk:** ${idea.risk}`,+ idea.type === 'SHORT' ? 0xE74C3C : idea.type === 'HEDGE' ? 0x95A5A6 : 0x2ECC71+ );++ const fields = [+ { name: 'Ticker', value: idea.ticker || '—', inline: true },+ { name: 'Direction', value: idea.type, inline: true },+ { name: 'Horizon', value: idea.horizon, inline: true },+ ];++ if (idea.signals?.length) {+ fields.push({ name: 'Supporting Signals', value: idea.signals.join('\n'), inline: false });+ }++ fields.push({ name: '🎯 Prediction Market Angle', value: this._kalshiAngle(idea), inline: false });++ if (embed.setFields) {+ embed.setFields(fields);+ embed.setFooter({ text: `Crucix Actionable Ideas · ${new Date().toISOString().replace('T', ' ').substring(0, 19)} UTC` });+ } else {+ embed.fields = fields;+ embed.footer = { text: `Crucix Actionable Ideas · ${new Date().toISOString().replace('T', ' ').substring(0, 19)} UTC` };+ }++ await this.sendMessage(null, [embed]);+ console.log(`[Discord] Actionable idea sent: ${idea.type} ${idea.ticker} (${idea.horizon})`);+ }+ }++ /**+ * Generate a Kalshi-relevant angle for a given idea.+ */+ _kalshiAngle(idea) {+ const ticker = idea.ticker || '';+ const type = idea.type;+ const signals = (idea.signals || []).join(' ');++ // Oil / Energy+ if (/BNO|USO|WTI|Brent|CL=F/i.test(ticker + signals)) {+ return type === 'LONG'+ ? '🛢️ Look for YES on "Oil above $X" contracts or NO on "Oil below $X" contracts'+ : '🛢️ Look for YES on "Oil below $X" contracts';+ }+ // Gold / Metals+ if (/GLD|Gold|Silver|SLV/i.test(ticker + signals)) {+ return type === 'LONG'+ ? '🥇 Look for YES on "Gold above $X" contracts'+ : '🥇 Look for YES on "Gold below $X" contracts';+ }+ // Rates / Treasury+ if (/ZT|ZN|ZB|DGS|Treasury|Fed.*Fund|MORTGAGE/i.test(ticker + signals)) {+ return '📊 Look for Fed rate decision contracts or Treasury yield range contracts';+ }+ // Indexes+ if (/SPY|QQQ|SPX|NDX|IWM/i.test(ticker)) {+ return type === 'LONG'+ ? '📈 Look for YES on "S&P above X" or daily range contracts'+ : '📉 Look for YES on "S&P below X" or daily range contracts';+ }+ // Defense / Geopolitical+ if (/ITA|LMT|RTX|defense|conflict/i.test(ticker + idea.rationale)) {+ return '🌍 Look for geopolitical event contracts (conflict escalation, sanctions, etc.)';+ }+ // Crypto+ if (/BTC|ETH|crypto/i.test(ticker + signals)) {+ return type === 'LONG'+ ? '₿ Look for YES on "Bitcoin above $X" contracts'+ : '₿ Look for YES on "Bitcoin below $X" contracts';+ }+ // Generic+ return `Look for event contracts related to ${ticker || 'this sector'} directional moves`;+ }+// ─── Rule-Based Fallback (same logic as Telegram) ───────────────────────_ruleBasedEvaluation(signals, delta) {diff --git a/server.mjs b/server.mjsindex 330d77e..b45d869 100644--- a/server.mjs+++ b/server.mjs@@ -376,6 +376,13 @@ async function runSweepCycle() {}}+ // 7. Post actionable ideas to Discord (HIGH confidence, short horizon, Kalshi-style)+ if (discordAlerter.isConfigured && synthesized.ideas?.length > 0) {+ discordAlerter.sendActionableIdeas(synthesized.ideas).catch(err => {+ console.error('[Crucix] Discord idea alert error:', err.message);+ });+ }+// Prune old alerted signalsmemory.pruneAlertedSignals();