[object Object]

← back to Bertha

chore(alshi-dash): update 1 file (.js) [+81/-3]

a6976baffc554bc0c0061835dff332bb89228b92 · 2026-02-14 18:41:24 +0000 · DW Commit Agent

Files touched

Diff

commit a6976baffc554bc0c0061835dff332bb89228b92
Author: DW Commit Agent <commit-agent@dw-agents.com>
Date:   Sat Feb 14 18:41:24 2026 +0000

    chore(alshi-dash): update 1 file (.js) [+81/-3]
---
 kalshi-dash/server.js | 84 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 81 insertions(+), 3 deletions(-)

diff --git a/kalshi-dash/server.js b/kalshi-dash/server.js
index 143dcd3..9e2327a 100644
--- a/kalshi-dash/server.js
+++ b/kalshi-dash/server.js
@@ -1612,6 +1612,37 @@ async function scrapeTildes() {
   } catch { return []; }
 }
 
+// ── Manifold Markets (open prediction market — public API) ──
+async function scrapeManifold(queries) {
+  const results = [];
+  for (const q of queries) {
+    try {
+      const controller = new AbortController();
+      const timeout = setTimeout(() => controller.abort(), 8000);
+      const res = await fetch(`https://manifold.markets/api/v0/search-markets?term=${encodeURIComponent(q)}&sort=liquidity&limit=10`, {
+        signal: controller.signal, headers: { 'Accept': 'application/json' },
+      });
+      clearTimeout(timeout);
+      if (!res.ok) continue;
+      const markets = await res.json();
+      for (const m of (markets || [])) {
+        if (m.question && m.probability != null && (m.volume || 0) > 100) {
+          results.push({
+            title: m.question,
+            url: m.url || `https://manifold.markets/${m.creatorUsername}/${m.slug}`,
+            source: 'Manifold',
+            probability: Math.round((m.probability || 0) * 100),
+            volume: Math.round(m.volume || 0),
+            liquidity: Math.round(m.totalLiquidity || 0),
+          });
+        }
+      }
+    } catch {}
+    await new Promise(r => setTimeout(r, 500));
+  }
+  return results;
+}
+
 // ── Mastodon/Fediverse trending (public API, no auth) ──
 async function scrapeMastodon() {
   const instances = ['mastodon.social', 'mas.to'];
@@ -1903,7 +1934,14 @@ async function redditIntelligenceLoop() {
     }
 
     // Also scrape hot posts from key subreddits for general intelligence
-    const hotSubs = ['politics', 'worldnews', 'economics', 'wallstreetbets', 'news'];
+    const hotSubs = ['politics', 'worldnews', 'economics', 'wallstreetbets', 'news',
+      // Prediction market communities — direct market intelligence
+      'Kalshi', 'Polymarket', 'PredictionMarket', 'sportsbook',
+      // Trading/options communities — sentiment on market moves
+      'wallstreetbetsOGs', 'options', 'thetagang', 'stocks', 'investing',
+      // Crypto prediction markets
+      'CryptoMarkets', 'defi',
+    ];
     for (const sub of hotSubs) {
       const hotPosts = await scrapeSubredditHot(sub, 10);
       for (const post of hotPosts) {
@@ -1993,6 +2031,45 @@ async function redditIntelligenceLoop() {
       console.log(`[Ken] Metaculus failed: ${e.message}`);
     }
 
+    // ── Manifold Markets (cross-reference prediction probabilities) ──
+    let manifoldTotal = 0;
+    try {
+      const manifoldQueries = ['trump', 'fed rate', 'election 2028', 'ukraine', 'tariff', 'bitcoin', 'recession', 'greenland', 'deportation', 'government shutdown'];
+      const manifoldMkts = await scrapeManifold(manifoldQueries);
+      for (const m of manifoldMkts) {
+        const sentiment = scoreSentiment(m.title);
+        await kenQ(`
+          INSERT INTO ken_sentiment (source, subreddit, keyword, post_title, post_url, score, num_comments, sentiment_score, raw_text)
+          VALUES ('manifold', 'manifold', $1, $2, $3, $4, 0, $5, $6)
+          ON CONFLICT DO NOTHING
+        `, [m.source, m.title, m.url, m.volume || 0, sentiment, `prob:${m.probability}% vol:${m.volume}`]);
+        manifoldTotal++;
+      }
+    } catch {}
+    console.log(`[Ken] Manifold Markets: ${manifoldTotal} prediction markets`);
+
+    // ── Kalshi & Polymarket Reddit search (community sentiment on specific trades) ──
+    let predMarketRedditTotal = 0;
+    const pmSearchTerms = ['best bet', 'free money', 'arbitrage', 'edge', 'mispriced', 'undervalued', 'high confidence', 'slam dunk'];
+    for (const term of pmSearchTerms) {
+      for (const sub of ['Kalshi', 'Polymarket']) {
+        try {
+          const posts = await scrapeReddit(sub, term, 5);
+          for (const post of posts) {
+            const sentiment = scoreSentiment(post.title);
+            await kenQ(`
+              INSERT INTO ken_sentiment (source, subreddit, keyword, post_title, post_url, score, num_comments, sentiment_score, raw_text)
+              VALUES ('reddit_predmkt', $1, $2, $3, $4, $5, $6, $7, '')
+              ON CONFLICT DO NOTHING
+            `, [sub, term, post.title, post.url, post.score || 0, post.num_comments || 0, sentiment]);
+            predMarketRedditTotal++;
+          }
+        } catch {}
+      }
+      await new Promise(r => setTimeout(r, 2000));
+    }
+    console.log(`[Ken] Prediction market Reddit: ${predMarketRedditTotal} posts from r/Kalshi + r/Polymarket`);
+
     // ── GDELT TV News (CNN, MSNBC, Fox, BBC closed captions) ──
     const tvStations = ['CNN', 'MSNBC', 'FOXNEWS', 'BBCNEWS'];
     const tvQueries = ['trump', 'tariff', 'ukraine', 'election', 'fed rate'];
@@ -2123,7 +2200,8 @@ async function redditIntelligenceLoop() {
     }
 
     totalPosts += tvTotal + lemmyTotal + lobstersTotal + tildesTotal + bskyTotal;
-    console.log(`[Ken] ═══ FULL SWEEP: ${totalPosts} items (Reddit, HN, ${NEWS_FEEDS.length} feeds, TV, YT, Lemmy, Lobsters, Tildes, Bluesky, Mastodon, Metaculus) ═══`);
+    totalPosts += manifoldTotal + predMarketRedditTotal;
+    console.log(`[Ken] ═══ FULL SWEEP: ${totalPosts} items (Reddit, HN, ${NEWS_FEEDS.length} feeds, TV, YT, Manifold, r/Kalshi, r/Polymarket, Lemmy, Lobsters, Tildes, Bluesky, Mastodon, Metaculus) ═══`);
     return totalPosts;
   } catch (e) {
     console.error('[Ken] Intelligence sweep error:', e.message);
@@ -3059,7 +3137,7 @@ server.listen(PORT, '0.0.0.0', () => {
   console.log(`[Ken] Market scan: every 15 minutes`);
   console.log(`[Ken] Reddit/news: every 30 minutes`);
   console.log(`[Ken] Slack alerts: every 4 hours (high-conf bypass)`);
-  console.log(`[Ken] Data sources: Kalshi | Reddit (58) | ${NEWS_FEEDS.length} news feeds | HN | GDELT TV | YouTube | Lemmy | Lobsters | Tildes | Bluesky | Mastodon | Metaculus | Polymarket`);
+  console.log(`[Ken] Data sources: Kalshi | Reddit (70+) | ${NEWS_FEEDS.length} news feeds | HN | GDELT TV | YouTube | Manifold | r/Kalshi | r/Polymarket | Lemmy | Lobsters | Tildes | Bluesky | Mastodon | Metaculus | Polymarket`);
   console.log(`[Ken] ═══════════════════════════════════════`);
 
   // Initial Reddit sweep after 5s

← 4f24548 chore(alshi-dash,kalshi-dash,react-dash): update 31 files (.  ·  back to Bertha  ·  chore(alshi-dash): update 1 file (.js) [+30/-21] e1e8fbe →