This is a basic stock recommendation system built using FastAPI, FAISS, and Gemini.
It takes user input like risk level, investment duration, and budget.
It returns a suggested portfolio with allocation.
This project is for:
- The Stock Recommendation System is for people who want to understand a stock before investing, especially beginners and students who may find financial information difficult to analyze.
- Takes user input (risk, duration, budget)
- Retrieves relevant stocks using FAISS
- Sends context + input to Gemini
- Returns a portfolio with allocation
Stock data is fetched using yfinance.
Ticker names are currently hardcoded.
Data includes:
- Market cap
- PE ratio
- Growth
- Risk indicators
Each stock is converted into a text summary.
Example:
- large cap
- low risk
- high growth
This summary is important.
FAISS works on text similarity, not numbers.
- Text summaries are converted into embeddings using
sentence-transformers - Stored in a FAISS index
This step happens once during startup.
When user sends a query:
- Query is converted into embedding
- FAISS finds similar stocks
This gives context.
- User input + retrieved stocks → sent to Gemini
- Gemini generates portfolio suggestions
A simple Streamlit UI is used.
User selects:
- Risk
- Duration (years)
- Budget
Then sees recommended portfolio.
- FastAPI → backend APIs
- Streamlit → UI
- FAISS → vector search
- Sentence Transformers → embeddings
- Gemini API → LLM reasoning
- yfinance → stock data
- Tickers are hardcoded
- Data is not real-time
- No proper financial modeling
- No risk calculation engine
- LLM output may not always be structured
- How RAG systems work
- Difference between retrieval and generation
- Importance of good summaries
- Why caching matters
- Handling LLM output safely
- Dynamic stock list (NIFTY 500)
- Better risk scoring
- Portfolio optimization logic
- Real-time data updates
- Better UI
uvicorn main:app --port 9000