Inspiration
Inspired by Benjamin Graham's classical investment book The Intelligent Investor, and his idea of value investment, driven (and also inspired) by modern quantitative finance technology, Smart Investor is a web-based portfolio analysis tool designed to help users evaluate their investment strategies through historical backtesting and Monte Carlo simulations. Incorporating Google Gemini AI models, it provides intelligent summaries and insights into the analysis results, helping users better understand the potential risks and returns of their portfolios.
What it does
Portfolio Backtesting:
- Conduct historical performance backtesting based on user-inputted Stock Tickers and Weights.
- Calculate and display key performance indicators (KPIs), including Compound Annual Growth Rate (CAGR), Sharpe Ratio, and Maximum Drawdown.
Monte Carlo Simulation:
- Run thousands of random simulations of the portfolio's future performance to evaluate the potential outcome distribution.
- Visually present the probability distribution histogram of the final investment value.
- Provide key statistical metrics, including Expected Mean, Median, Standard Deviation, 5th and 95th Percentiles, and Probability of Loss.
AI Smart Analysis:
- Integrate Google Gemini AI to provide in-depth analysis of backtesting and simulation results.
- Automatically generate a text summary covering the portfolio's strengths, risks, and potential improvement suggestions.
- Supports simple Markdown formatting like bolding to make the analysis results more readable.
Modern User Interface:
- Clean, intuitive, and responsive design, adapting to both desktop and mobile devices.
- Supports one-click switching between Dark Mode and Light Mode, with automatic saving of user preferences.
- Provides loading animations and clear error messages to optimize the user experience.
How we (*I) built it
Backend:
- Framework: Python 3, FastAPI
- Data Processing: Pandas, NumPy
- AI Integration: Google Generative AI (Gemini)
- Financial Database Library: Yahoo Finance API
Frontend:
- Language: HTML, CSS, JavaScript
- Library: ECharts, ecStat.js
- Styling: Native CSS
Deployment:
- Cloud Platform: Render
- Domain: NameCheap
Challenges we (*I) ran into
Choosing Tech Stacks: I first chose Python Streamlit to show the front-end, but soon swapped to JavaScript as it gives more flexibility to customize my front-end and looks more elegant (and I know more about JS).
Integrating Gemini for Structured Insight: Moving beyond a basic text generation call, I had challenges with an unstable Gemini API Key, which is stored in our own environmental variables.
Deployment: Several errors and bugs occurred when deploying both ends to Render, and I met some difficulties communicating with the DNS of my domain, such as an SSL Certificate Issuance error. But ultimately, I solved the problems.
Unfamiliar Tech Stacks: This is my first time using a Gemini API (I used GPT before), and my first time deploying both front-end and back-end on Render and connecting it to my domain. I also don't have a lot of experience writing a project that involves backtesting. I spent some time reading the docs, referring to open-source repos, and asking AI for help with these stacks.
Not Enough Time: To calculate other teams' average working time, the average should be about 14 hours * 4 = ~60 hours. I only had about 10-12 hours in total, and I used Gemini AI to assist me in finishing parts of the code.
Accomplishments that we're (*I am) proud of
Complete Full-Stack Development and Deployment: Though I have finished some full-stack development projects (some of them in other hackathons), I feel pleased when I finish another full-stack project this time. It's always a challenge to build an environment that runs perfectly, especially when connecting different frameworks together. I was not that good at developing back-end, but with the experience this time, I feel more confident (for real).
Financial Modeling: A small step, a big step. Implementing a Monte Carlo simulation and historical backtesting is an important starting point if I want to further grow in the financial engineering field in the future. I am proud of this small step.
What we (*I) learned
All the tech stacks and the valuable experience of making a project in a limited time.
What's next for Smart Investor
A better dashboard to configure the portfolio. For example, cards that can be adjusted with their tickers and weights with interactive animations, making the portfolio more visual and clear.
Advanced Portfolio Optimization and Benchmarking. Allow users to select external indices (e.g., S&P 500, NASDAQ) to compare the performance metrics (CAGR, Sharpe) of their custom portfolio directly against a market standard.
Enhancing AI Insight with Real-Time Data and Custom Tools. Feed the AI analysis with recent, relevant news headlines (via a third-party API) related to the portfolio's tickers, allowing it to provide a more comprehensive risk assessment based on current market sentiment.
Fun Facts
I'm soloing :) I gave the team of myself a name, MeiDuiYao, meaning no team wants me.
I went to an ICPC North American Qualifier competition during the hackathon (unfortunately, they were the same time).
Python is my least favorite language, but I use it here because I don't want to use C++ (my favorite language), which will make the project more complicated.
I love front-end development, but I don't have time to develop more.
Built With
- css
- echart
- fastapi
- gemini
- html
- javascript
- python
- render

Log in or sign up for Devpost to join the conversation.