TLDR: A research paper details the design, implementation, and debugging of a novel, serverless system for real-time stock analysis. Leveraging Google’s Gemini LLM for qualitative assessment and GitHub Actions for automation, the system provides AI-driven insights at near-zero cost. The paper highlights practical challenges encountered during development, including data serialization issues, repository permission errors, and a rare platform-level bug, offering a valuable case study in iterative problem-solving and human-AI collaboration in software development.
In the evolving landscape of financial technology, the integration of Artificial Intelligence, particularly Large Language Models (LLMs), is opening new avenues for individual investors and developers. A recent research paper details the creation of a novel, serverless system designed for real-time stock analysis, making sophisticated AI-powered financial tools accessible and cost-effective.
Traditionally, AI applications in finance have focused on quantitative models for forecasting. However, the emergence of powerful LLMs like Google’s Gemini has introduced a new dimension: qualitative analysis. This allows for the interpretation of news, sentiment, and complex data patterns in a way that mimics human understanding. While large financial institutions have the resources to build proprietary AI systems, the accessibility of APIs for models like Gemini provides an unprecedented opportunity for individual researchers and developers to innovate.
The core question driving this project was whether an individual could build and deploy a cost-effective, real-time, and fully automated stock analysis system using publicly available, serverless tools. The goal was not to create a trading bot, but a framework that could systematically fetch market data, generate AI-driven insights, and present them through a user-friendly interface.
System Architecture and Components
The system’s final architecture is a serverless, event-driven pipeline designed for maximum reliability and minimal cost. Key components include:
- Data Sources: The yfinance library for daily end-of-day stock data and NewsAPI for recent news headlines.
- Backend Logic: A Python script named `generate_predictions.py` forms the core of the backend.
- AI Analysis Engine: Google’s Gemini Pro model, accessed via its REST API, is prompted to return structured JSON objects for analysis.
- Automation & Hosting: GitHub Actions serves as a serverless cron job scheduler. The same GitHub repository hosts the code and stores the output `predictions.json` file.
- Frontend: A static website built with HTML, CSS, and vanilla JavaScript, hosted on a custom domain, dynamically fetches and displays the latest analysis.
Data Flow and Logic
The system operates on a daily cycle, triggered by a cron schedule in a GitHub Actions workflow. The Python script fetches fresh stock and news data, reads the previous day’s predictions for accuracy checks, and then sends a detailed prompt to the Gemini API. The AI’s response is parsed and combined with current price data and accuracy metrics. Finally, the script overwrites the `predictions.json` file in the repository, with a bot user committing and pushing this change. The live website then fetches this updated JSON file to display the latest analysis.
The Debugging Journey: Practical Challenges
The path to a stable deployment was iterative and involved overcoming several critical bugs, offering valuable lessons for developers:
- Data Serialization Failure: An initial challenge was `TypeError: Object of type Series is not JSON serializable`. This occurred because the `yfinance` library returns price data as pandas.Series objects, which the standard Python `json` library cannot directly convert. The resolution involved explicitly casting the pandas object to a standard Python data type (float) before JSON serialization.
- Repository Write Permissions: The workflow failed with a `403 Forbidden` error during the final `git push` command. This was due to the default `GITHUB_TOKEN` provided to a workflow having read-only access. The fix involved modifying the workflow’s `.yml` file to explicitly grant write permissions to the repository’s contents.
- The “Ghost” Action: This was the most challenging bug, a platform-level issue where the workflow failed at the very first step, unable to resolve a standard public action. After exhausting all logical configuration fixes, the unconventional solution was to create a new, blank repository and migrate the exact same code and secrets. The workflow succeeded on the first attempt, highlighting that sometimes the environment itself can be the source of the bug, and recreating it is a valid resolution strategy.
Also Read:
- AI Agents Uncover Hidden Market Risks to Sharpen Trading Decisions
- AI Models Offer New Ways to Optimize Software Performance
Conclusion and Future Outlook
This project successfully demonstrates that a sophisticated, serverless AI analysis system can be built with minimal cost using modern, publicly available tools. Key takeaways include the effectiveness of LLMs as qualitative reasoning engines in finance, the transformative power of serverless architecture like GitHub Actions for individual developers, and the critical importance of understanding the platform and environment in modern software development.
The operational application is publicly accessible, and the complete source code is available for review, ensuring full reproducibility. You can find more details about this research paper here: Research Paper on Serverless Stock Analysis.
Future work could involve expanding data sources to include fundamental analysis, performing more granular sentiment analysis on news content, and back-testing the AI’s advice over a longer period to quantitatively assess its directional accuracy and potential profitability.


