Inspiration

As a quantitative finance and machine learning researcher, I have always been fascinated by the sheer volume of data circulating through global markets. However, a glaring bottleneck remains: the massive gap between raw market numbers and actionable, structured investment intelligence. Financial analysts and quantitative researchers spend hours manually downloading PDFs, parsing earnings releases, pulling broker data, and compiling reports.

The inspiration behind Automatic Financial Advisor (AFA) was to eliminate this friction entirely. We set out to build an autonomous, serverless engine capable of acting as a 24/7 quantitative research analyst—ingesting institutional data, running advanced analysis, generating institutional-grade PDF reports, and delivering them directly to collaboration spaces without a single click of manual effort.

What it does

Automatic Financial Advisor is a fully automated, event-driven financial intelligence pipeline. It continuously monitors and analyzes market trends, portfolio performance, and company fundamentals by:

  • Data Ingestion: Automatically fetching institutional-grade market data from premium financial APIs and broker platforms.
  • Quantitative Engine: Parsing raw financial statements, executing quantitative risk metrics, and calculating portfolio performance attributes.
  • Automated Reporting: Formatting and rendering the analytical findings into clean, professional research reports (PDF and Markdown formats).
  • Seamless Distribution: Instantly uploading completed reports to a centralized corporate repository for immediate collaboration and decision-making.

How we built it

To build a highly scalable, lightweight, and cost-efficient system, we designed a serverless architecture:

  • Backend & Serverless Infrastructure: The backbone of AFA is built on Azure Function Apps (such as our core processing engine, func-financial-reports-uploader). This allows the system to run on scheduled CRON triggers and execute on-demand without managing dedicated servers.
  • Data Providers & APIs: We integrated the Financial Modeling Prep (FMP) API to retrieve deep fundamental data, historical financial statements, and real-time stock metrics. To track execution and portfolio metrics, we hooked into broker APIs, specifically leveraging Swissquote API integration.
  • Development & Debugging: We utilized Cursor as our primary AI-powered development environment. This enabled rapid prototyping, automated code refactoring, and accelerated our debugging processes.
  • Storage & Collaboration Hub: We integrated Microsoft SharePoint via Microsoft Graph APIs, creating a destination where generated research reports are automatically organized, stored, and shared with stakeholders.

Challenges we ran into

Building a fully decoupled, serverless pipeline brought several unique technical hurdles:

  1. The "50ms Silent Crash" (Environment Configuration in Serverless): During our initial deployment to Azure, we encountered an incredibly elusive bug. The function app would spin up and instantly terminate within roughly 50ms, leaving the destination SharePoint folders completely blank. No logs were generated from the actual execution code.

    Using Cursor's deep contextual search and local terminal emulation, we traced the root cause: the local environment configuration had not mapped correctly to the Azure App Settings. The function app was missing the critical SWISSQUOTE_API_TOKEN and FMP_API_KEY. Because our initialization logic strictly required these keys to authenticate, the app raised a fatal exception at the absolute entry point before the logging or execution loop could even boot up. Solving this required establishing strict fallback configuration patterns and implementing graceful error boundaries during initialization.

  2. Timezone Gatekeeping: Handling schedules and historical data ranges across international markets led to several "timezone gatekeeping" issues. Serverless environments running on UTC would occasionally calculate incorrect start/end dates for target data windows, causing API requests to return empty datasets or skip reporting intervals entirely. We corrected this by standardizing all internal date objects to UTC with explicit localized market conversion layers.

Accomplishments that we're proud of

  • True Automation: We created a zero-maintenance, serverless pipeline that operates flawlessly for pennies a day, executing complex API aggregations, data transformations, and report builds automatically.
  • Robust Error Resiliency: We built a highly defensive application architecture. The system now performs automated environment and API handshake checks at startup, failing loudly and clearly if configuration mismatches or API limits are hit, rather than failing silently.
  • Professional Output Delivery: Achieving a beautiful, automated transition from raw API JSON payloads to professional, publication-ready PDF reports uploaded directly to SharePoint in real-time.

What we learned

  • The Parity of Local and Production Environments: We learned the hard way that serverless local development tools are excellent, but cloud-hosted environments require explicit, rigorous secret and environment variable parity checks.
  • AI-Assisted Debugging is a Game-Changer: Leveraging Cursor to isolate microsecond-level startup crashes saved us hours of digging through fragmented cloud logs. It proved that understanding the runtime execution stack is just as important as writing the core business logic.
  • API Boundary Defense: Always validate your API keys, network availability, and basic dependencies before executing business logic. Robust logging at the very entry point of a serverless function is essential for maintaining complex distributed pipelines.

What's next for Automatic Financial Advisor

  • Advanced Quantitative Modeling: Integrating stochastic analysis and volatility forecasting models (such as geometric Brownian motion paths or GARCH models) to provide forward-looking risk metrics alongside historical fundamental analysis.
  • Interactive Web Dashboard: Transitioning from static PDF generation to an interactive, real-time analytics dashboard where users can slice data and customize reports on the fly.
  • Natural Language Research Synthesis: Utilizing large language models to append natural language summaries and sentiment analysis to quantitative metrics, transforming raw metrics into narrative-driven investment ideas.

Built With

Share this project:

Updates