[object Object]

← back to Bertha

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

e1e8fbeb999905e1c4ea1936ebd4982e9bc69489 · 2026-02-14 18:51:14 +0000 · DW Commit Agent

Files touched

Diff

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

    chore(alshi-dash): update 1 file (.js) [+30/-21]
---
 kalshi-dash/server.js | 51 ++++++++++++++++++++++++++++++---------------------
 1 file changed, 30 insertions(+), 21 deletions(-)

diff --git a/kalshi-dash/server.js b/kalshi-dash/server.js
index 9e2327a..9a70901 100644
--- a/kalshi-dash/server.js
+++ b/kalshi-dash/server.js
@@ -1935,12 +1935,7 @@ async function redditIntelligenceLoop() {
 
     // Also scrape hot posts from key subreddits for general intelligence
     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',
+      'Kalshi', 'Polymarket', 'PredictionMarket', 'sportsbook', 'CryptoMarkets',
     ];
     for (const sub of hotSubs) {
       const hotPosts = await scrapeSubredditHot(sub, 10);
@@ -1975,7 +1970,7 @@ async function redditIntelligenceLoop() {
     }
 
     // ── Hacker News (tech/policy sentiment) ──
-    const hnQueries = ['trump policy', 'federal reserve', 'election 2028', 'trade war', 'immigration', 'tariff', 'ukraine russia', 'china taiwan', null]; // null = front page
+    const hnQueries = ['trump policy', 'federal reserve', 'tariff', 'ukraine russia', null]; // null = front page
     for (const hq of hnQueries) {
       try {
         const stories = await scrapeHackerNews(hq, 10);
@@ -1996,22 +1991,34 @@ async function redditIntelligenceLoop() {
 
     // ── All News Channels (BBC, NYT, WaPo, Politico, CNBC, Bloomberg, etc.) ──
     try {
-      const newsArticles = await scrapeAllNewsFeeds();
       let newsStored = 0;
-      for (const article of newsArticles) {
-        const sentiment = scoreSentiment(article.title);
-        await kenQ(`
-          INSERT INTO ken_sentiment (source, subreddit, keyword, post_title, post_url, score, sentiment_score, raw_text)
-          VALUES ($1, $2, 'news', $3, $4, 0, $5, '')
-          ON CONFLICT DO NOTHING
-        `, [article.source.toLowerCase().replace(/\s+/g, '_'), article.source, article.title, article.url, sentiment]);
-        newsStored++;
+      // Process feeds in small batches to limit memory — don't hold all articles at once
+      const batchSize = 5;
+      for (let i = 0; i < NEWS_FEEDS.length; i += batchSize) {
+        const batch = NEWS_FEEDS.slice(i, i + batchSize);
+        const results = await Promise.allSettled(
+          batch.map(feed => scrapeRSSFeed(feed.url, feed.source, 6))
+        );
+        for (const result of results) {
+          if (result.status !== 'fulfilled') continue;
+          for (const article of result.value) {
+            const sentiment = scoreSentiment(article.title);
+            await kenQ(`
+              INSERT INTO ken_sentiment (source, subreddit, keyword, post_title, post_url, score, sentiment_score, raw_text)
+              VALUES ($1, $2, 'news', $3, $4, 0, $5, '')
+              ON CONFLICT DO NOTHING
+            `, [article.source.toLowerCase().replace(/\s+/g, '_'), article.source, article.title, article.url, sentiment]);
+            newsStored++;
+          }
+        }
+        await new Promise(r => setTimeout(r, 300));
       }
       totalPosts += newsStored;
       console.log(`[Ken] News channels: ${newsStored} articles from ${NEWS_FEEDS.length} feeds`);
     } catch (e) {
       console.log(`[Ken] News channels failed: ${e.message}`);
     }
+    if (global.gc) global.gc();
 
     // ── Metaculus (prediction market community consensus) ──
     try {
@@ -2034,7 +2041,7 @@ async function redditIntelligenceLoop() {
     // ── 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 manifoldQueries = ['trump', 'fed rate', 'election 2028', 'ukraine', 'tariff'];
       const manifoldMkts = await scrapeManifold(manifoldQueries);
       for (const m of manifoldMkts) {
         const sentiment = scoreSentiment(m.title);
@@ -2050,7 +2057,7 @@ async function redditIntelligenceLoop() {
 
     // ── 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'];
+    const pmSearchTerms = ['arbitrage', 'free money', 'mispriced', 'edge'];
     for (const term of pmSearchTerms) {
       for (const sub of ['Kalshi', 'Polymarket']) {
         try {
@@ -2069,10 +2076,11 @@ async function redditIntelligenceLoop() {
       await new Promise(r => setTimeout(r, 2000));
     }
     console.log(`[Ken] Prediction market Reddit: ${predMarketRedditTotal} posts from r/Kalshi + r/Polymarket`);
+    if (global.gc) global.gc();
 
-    // ── GDELT TV News (CNN, MSNBC, Fox, BBC closed captions) ──
-    const tvStations = ['CNN', 'MSNBC', 'FOXNEWS', 'BBCNEWS'];
-    const tvQueries = ['trump', 'tariff', 'ukraine', 'election', 'fed rate'];
+    // ── GDELT TV News (CNN, Fox closed captions) ──
+    const tvStations = ['CNN', 'FOXNEWS'];
+    const tvQueries = ['trump', 'tariff', 'ukraine', 'election'];
     let tvTotal = 0;
     for (const station of tvStations) {
       for (const tq of tvQueries) {
@@ -2113,6 +2121,7 @@ async function redditIntelligenceLoop() {
     } catch (e) {
       console.log(`[Ken] YouTube News failed: ${e.message}`);
     }
+    if (global.gc) global.gc();
 
     // ── Lemmy (federated Reddit — public API, no auth) ──
     let lemmyTotal = 0;

← a6976ba chore(alshi-dash): update 1 file (.js) [+81/-3]  ·  back to Bertha  ·  chore(alshi-dash): update 1 file (.js) [+19/-16] ee69ff3 →