AI-Based Stock Sentiment & Investment Scoring Workflow
π AI-Powered Stock Sentiment & Investment Score Generator
This project leverages Buildship's no-code automation platform and OpenAI's language models to create a smart financial analysis tool. By processing real-time news headlines for any public company, the workflow evaluates media sentiment, flags risk signals, and generates an investment recommendation β all within a structured API workflow.
π Overview
This workflow:
- Accepts a company name (e.g., "Google", "Tesla")
- Fetches the latest news headlines using the NewsAPI
- Sends those headlines to an LLM (OpenAI) for analysis
- Returns a structured JSON response with:
- Sentiment analysis
- Investment recommendation
- Risk factors
- Confidence score
- Final investment score for ranking
π§ Key Features
π° News IntegrationUses NewsAPI to fetch real-time headlines
π§ AI Sentiment AnalysisOpenAI interprets tone, trends, risks, and investor sentiment
π Investment ScoringCalculates a 0β100 score to rank companies based on outlook
β οΈ Caution DetectionFlags layoffs, lawsuits, or product issues from headlines
π REST API InterfaceTriggered via POST
with a company name as input
π§± No frontend includedDesigned solely as a self-contained, API-based backend workflow
ποΈ Workflow Structure
Input Node:
Accepts JSON: { "company": "CompanyName"
}
NewsAPI Node:
- Endpoint: /v2/everything
- Params: q={{inputs.company}}, from=2025-06-01, sortBy=popularity, language=en
OpenAI Node (Text Generation):
- Prompt: Analyzes sentiment, risk, and price direction
- Produces JSON fields:
- sentiment_score
- sentiment_classification
- recommendation
- confidence
- caution_notes
- final_score
- etc.
Code Node (Scoring Logic):
- Parses OpenAI response
- Applies formula:
final_score = (sentiment_score * 0.5) + (recommendation_weight * 25) + (confidence * 0.2) - penalty
π₯ API Usage
π Endpoint (example)
POST https://api.buildship.com/flow/<your-flow-id>
π¨ Request Body
jsonCopy code{
"company": "Tesla"
}
π€ Response
{
"company": "Tesla",
"sentiment_score": 78,
"recommendation": "Hold",
"confidence": 85,
"caution_notes": "Layoffs in key teams.",
"final_score": 82,
"price_direction": "β",
"top_headlines": [
{ "title": "...", "sentiment": "Positive" },
{ "title": "...", "sentiment": "Negative" },
...
]
}
π Scoring Formula
The investment scoring logic works as follows:
final_score =
(sentiment_score * 0.5) +
(recommendation_weight * 25) +
(confidence * 0.2) -
caution_penalty
MetricWeight/ImpactSentiment Score0β100 β 50% of total scoreRecommendationBuy=3, Hold=2, Sell=1ConfidenceWeighted at 20%Caution Penalty-15 if risk factors present
π API Keys Used
- NewsAPI Key β securely stored in Buildship secrets
- OpenAI API β managed by Buildship under LLM tools
π Assumptions & Notes
- No backend/frontend system required β submission is only the Buildship workflow
- Works best when major news stories are available for the target company
- Handles one company per request; multiple can be handled with looping extensions
β
Submission Summary
- π‘ Project: AI-Powered Stock Investment Analysis API
- π¦ Platform: Buildship
- π§ AI Engine: OpenAI GPT-4
- π Output: JSON structure containing investment insights and final score
- π€ Delivery: Hosted API endpoint ready for external use