Finalizing Analysis
Now I just commit the finished points & criticisms to the database and then save the current date & time to the last_analyzed
column so I can log when the ticker was last analyzed. Now all relevant data is either in the database or can be fetched using the get_stock_profile
function. Now I just need to provide an endpoint to in turn provide the frontend with said data. The script structures the data as follows and returns it through the /retrieve-analysis
endpoint:
{ "company": {
"ticker": "aapl",
"title": "Apple Inc.",
"description": "Apple Inc. is a leading company in the technology sector...",
"sentimentScore": 48,
"logo": "https://images.financialmodelingprep.com/symbol/AAPL.png",
"website": "https://www.apple.com",
"price": 188.38,
"exchangeShortName": "NASDAQ",
"mktCap": 2829863198000,
"industry": "Consumer Electronics",
"earningsCallDate": "2025-04-29 22:00 CEST",
"analystRating": "buy",
"forwardPE": 22.669073,
"dcf": 163.99684034053524,
"beta": 1.259
},
"points": [
{
"content": "Shares have increased by about 5% this year.",
"sentimentScore": 55,
"postUrl": "https://www.reddit.com/r/investing/comments/1d8zcp3/nvidia_briefly_passes_apple_as_second_most/",
"postTitle": "Nvidia briefly passes Apple as second most valuable public U.S. company",
"postAuthor": "StatQuants",
"postSource": "reddit",
"postDate": "2024-06-05T00:00:00",
"criticismExists": false,
"criticisms": [
{
"content": "Large firms likely use lobbying...",
"validityScore": 70,
"commentUrl": "https://www.reddit.com/r/investing/comments/...
}
]
}, ...
Note that the /retrieve-analysis
endpoint takes a second parameter aside from the ticker, that being timezone. Since I’m returning the earnings call date and time I take the timezone as an argument and localize the time returned by thy yahoo finance API before returning it.