get_sentiment_state
Analyze crypto market sentiment by retrieving the Fear & Greed Index, 7-day trend, contrarian signals, and extreme opportunity indicators.
Instructions
Get the current crypto sentiment state including Fear & Greed Index, 7-day trend, contrarian signals, and whether extreme fear/greed opportunities are active.
Input Schema
TableJSON Schema
| Name | Required | Description | Default |
|---|---|---|---|
No arguments | |||
Implementation Reference
- src/tools/get-sentiment-state.ts:9-59 (handler)Main handler function for get_sentiment_state, which fetches fear/greed data, processes trends, and generates narrative/guidance.
export async function getSentimentState(cache: CacheService): Promise<SentimentStateOutput | ErrorOutput> { const cached = cache.get<SentimentStateOutput>(CACHE_KEY); if (cached) return cached.data; try { const fgData = await getFearGreed(7); const entries = fgData.data; const current = parseInt(entries[0].value, 10); const sevenDayAgo = entries.length >= 7 ? parseInt(entries[6].value, 10) : parseInt(entries[entries.length - 1].value, 10); const diff = current - sevenDayAgo; const trend: 'improving' | 'stable' | 'deteriorating' = diff > 5 ? 'improving' : diff < -5 ? 'deteriorating' : 'stable'; const extremeFearOpportunity = current < 20; const extremeGreedWarning = current > 80; const contrarianSignal = current < 20 ? 'Historically strong accumulation signal. Extreme fear often precedes recovery. Prior instances (March 2020, June 2022, November 2022) preceded 50-300% rallies within 3-12 months.' : current > 80 ? 'Historically strong distribution signal. Extreme greed often precedes correction. Prior instances (November 2021, March 2024) preceded 20-50% drawdowns within 1-3 months.' : `Sentiment at ${current} is in the neutral-to-${current > 50 ? 'greedy' : 'fearful'} range. No extreme contrarian signal active. Monitor for moves toward extremes.`; const narrative = generateSentimentNarrative(current, sevenDayAgo, trend); const guidance = generateSentimentGuidance(current, trend, extremeFearOpportunity, extremeGreedWarning); const result: SentimentStateOutput = { fear_greed_current: current, fear_greed_7d_ago: sevenDayAgo, fear_greed_trend: trend, fear_greed_label: getFearGreedLabel(current), sentiment_narrative: narrative, extreme_fear_opportunity: extremeFearOpportunity, extreme_greed_warning: extremeGreedWarning, contrarian_signal: contrarianSignal, agent_guidance: guidance, }; cache.set(CACHE_KEY, result, getCacheTtl(BASE_TTL)); return result; } catch (err) { return { error: true, error_source: 'get_sentiment_state', agent_guidance: 'Sentiment data unavailable. Without sentiment context, treat current conditions as uncertain. Reduce position sizes until sentiment data is restored.', last_known_data: cache.get<SentimentStateOutput>(CACHE_KEY)?.data ?? null, data_warnings: ['Sentiment data source temporarily unavailable. Retry shortly.'], }; } }