alphaear-sentiment
npx machina-cli add skill RKiding/Awesome-finance-skills/alphaear-sentiment --openclawAlphaEar Sentiment Skill
Overview
This skill provides sentiment analysis capabilities tailored for financial texts, supporting both FinBERT (local model) and LLM-based analysis modes.
Capabilities
Capabilities
1. Analyze Sentiment (FinBERT / Local)
Use scripts/sentiment_tools.py for high-speed, local sentiment analysis using FinBERT.
Key Methods:
analyze_sentiment(text): Get sentiment score and label using localized FinBERT model.- Returns:
{'score': float, 'label': str, 'reason': str}. - Score Range: -1.0 (Negative) to 1.0 (Positive).
- Returns:
batch_update_news_sentiment(source, limit): Batch process unanalyzed news in the database (FinBERT only).
2. Analyze Sentiment (LLM / Agentic)
For higher accuracy or reasoning capabilities, YOU (the Agent) should perform the analysis using the Prompt below, calling the LLM directly, and then update the database if necessary.
Sentiment Analysis Prompt
Use this prompt to analyze financial texts if the local tool is insufficient or if reasoning is required.
请分析以下金融/新闻文本的情绪极性。
返回严格的 JSON 格式:
{"score": <float: -1.0到1.0>, "label": "<positive/negative/neutral>", "reason": "<简短理由>"}
文本: {text}
Scoring Guide:
- Positive (0.1 to 1.0): Optimistic news, profit growth, policy support, etc.
- Negative (-1.0 to -0.1): Losses, sanctions, price drops, pessimism.
- Neutral (-0.1 to 0.1): Factual reporting, sideways movement, ambiguous impact.
Helper Methods
update_single_news_sentiment(id, score, reason): Use this to save your manual analysis to the database.
Dependencies
torch(for FinBERT)transformers(for FinBERT)sqlite3(built-in)
Ensure DatabaseManager is initialized correctly.
Source
git clone https://github.com/RKiding/Awesome-finance-skills/blob/main/skills/alphaear-sentiment/SKILL.mdView on GitHub Overview
AlphaEar Sentiment analyzes financial texts to assign a sentiment score and polarity. It supports fast, local FinBERT analysis and deeper LLM-based reasoning, returning a numeric score (-1.0 to 1.0), a label (positive/negative/neutral), and a concise reason.
How This Skill Works
For fast analysis, use the FinBERT path via scripts/sentiment_tools.py and call analyze_sentiment(text) to obtain {'score','label','reason'}. For higher accuracy or reasoning, perform LLM-based sentiment analysis using the provided Sentiment Analysis Prompt and parse the strict JSON output {'score': float, 'label': 'positive'|'negative'|'neutral', 'reason': '...'}, then persist with update_single_news_sentiment(id, score, reason). FinBERT can also batch process unanalyzed news using batch_update_news_sentiment(source, limit).
When to Use It
- Bulk sentiment scoring of daily financial news with FinBERT for speed.
- When you need deeper reasoning or higher accuracy via an LLM.
- Analyzing earnings reports, press releases, or regulatory updates for sentiment.
- Batch-processing unanalyzed news in your database (FinBERT path).
- Persisting analyzed results back to your database with score, label, and reason.
Quick Start
- Step 1: For fast results, run analyze_sentiment(text) using FinBERT via scripts/sentiment_tools.py.
- Step 2: If needed, switch to LLM analysis by using the Sentiment Analysis Prompt and parse the returned JSON {score, label, reason}.
- Step 3: Save results with update_single_news_sentiment(id, score, reason) or batch_update_news_sentiment(source, limit); ensure DatabaseManager is initialized.
Best Practices
- Use FinBERT for high-volume, fast sentiment scoring.
- Switch to the LLM path when texts are ambiguous or require reasoning.
- Ensure the LLM output is parsed from strict JSON as defined in the prompt.
- Verify score ranges (-1.0 to 1.0) and map to the correct label (positive/negative/neutral).
- Initialize DatabaseManager correctly and decide between update_single_news_sentiment and batch_update_news_sentiment for persistence.
Example Use Cases
- Analyze daily stock news headlines to produce a quick sentiment index.
- Evaluate sentiment of quarterly earnings releases to track market mood shifts.
- Assess sentiment impact of policy changes on specific sectors.
- Batch update sentiment labels for articles stored in a financial database.
- Display sentiment scores in a market dashboard to compare sources.