Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 10 additions & 3 deletions api/cron/collect-tweets.ts
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ export default async function handler(

totalCollected += result.tweets.length;

const tweetsToStore: AnalyzedTweet[] = [];

for (const rawTweet of result.tweets) {
totalAnalyzed++;

Expand Down Expand Up @@ -168,12 +170,17 @@ export default async function handler(
collected_at: new Date().toISOString(),
};

// Store tweet in KV
await storeTweet(analyzedTweet);
totalStored++;
tweetsToStore.push(analyzedTweet);
}
await Promise.allSettled(
tweetsToStore.map(tweet => storeTweet(tweet))
);

totalStored += tweetsToStore.length;
}



// Step 6: Update feed indices
await updateFeedIndices();

Expand Down
4 changes: 2 additions & 2 deletions src/analysis/keyword-matcher.ts
Original file line number Diff line number Diff line change
Expand Up @@ -853,8 +853,8 @@ function isPromotionalContent(text: string): boolean {
}

// Excessive emoji usage (often in spam)
const emojiCount = (text.match(/[\uD800-\uDFFF]/g) || []).length;
if (emojiCount > 15 && text.length < 200) {
const emojiCount = [...text].filter(c => (c.codePointAt(0) ?? 0) > 0xFFFF).length;
if (emojiCount > 8 && text.length < 200) {
return true; // More than 15 emoji chars in a short tweet is suspicious
}

Expand Down
14 changes: 6 additions & 8 deletions src/analysis/sentiment-analyzer.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ const BULLISH_KEYWORDS = [
'bullish', 'moon', 'rally', 'pump', 'surge', 'soar', 'skyrocket',
'buy', 'long', 'calls', 'green', 'win', 'winning', 'yes', 'definitely',
'confirmed', 'happening', 'inevitable', 'obvious', 'clearly', 'certain',
'guarantee', 'lock', 'easy', 'confident', 'predict', 'will happen',
'guarantee', 'lock', 'easy', 'confident', 'predict', 'happen',
'going to', 'up', 'rise', 'increase', 'gain', 'profit', 'success',
'boom', 'growth', 'explosive', 'parabolic', 'breakout'
];
Expand Down Expand Up @@ -53,13 +53,11 @@ export function analyzeSentiment(tweetText: string): SentimentResult {

for (let i = 0; i < words.length; i++) {
const word = words[i].replace(/[^a-z]/g, '');
const prevWord = i > 0 ? words[i - 1].replace(/[^a-z]/g, '') : '';

// Check for negation
const isNegated = NEGATIONS.includes(prevWord);

// Check for strong modifier
const isStrong = STRONG_MODIFIERS.includes(prevWord);
// Look back 2 words so negation passes through a modifier
const prev1 = i > 0 ? words[i-1].replace(/[^a-z]/g,'') : '';
const prev2 = i > 1 ? words[i-2].replace(/[^a-z]/g,'') : '';
const isNegated = NEGATIONS.includes(prev1) || (STRONG_MODIFIERS.includes(prev1) && NEGATIONS.includes(prev2));
const isStrong = STRONG_MODIFIERS.includes(prev1) && !NEGATIONS.includes(prev2);
const weight = isStrong ? 2 : 1;

// Check bullish
Expand Down
2 changes: 1 addition & 1 deletion src/analysis/signal-generator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -173,7 +173,7 @@ function generateSuggestedAction(
urgency: UrgencyLevel
): SuggestedAction {
// Don't suggest action if edge is too low
if (edge < 0.10) {
if (edge < 0.05) {
return {
direction: 'HOLD',
confidence: 0,
Expand Down
2 changes: 1 addition & 1 deletion src/api/kalshi-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -163,7 +163,7 @@ function toMarket(km: KalshiMarket): Market {
keywords: generateKeywords(km.title),
yesPrice: +safeYes.toFixed(2),
noPrice: safeNo,
volume24h: km.volume_24h ?? km.volume ?? 0,
volume24h: km.volume_24h ?? 0,
url: marketUrl,
category: inferCategory(km.series_ticker || km.event_ticker || km.ticker),
lastUpdated: new Date().toISOString(),
Expand Down
4 changes: 0 additions & 4 deletions vercel.json
Original file line number Diff line number Diff line change
Expand Up @@ -44,10 +44,6 @@
{
"source": "/api/(.*)",
"headers": [
{
"key": "Access-Control-Allow-Credentials",
"value": "true"
},
{
"key": "Access-Control-Allow-Origin",
"value": "*"
Expand Down