A research project using LLMs to analyze and forecast NSE-listed stocks, with a focus on portfolio optimization.
This project uses Google's Gemini AI to:
- Analyze NSE-listed stocks and generate price forecasts
- Optimize stock portfolios based on these forecasts
- Track portfolio performance
- Stock Analysis: Deep research on individual stocks using Google Search integration
- Portfolio Optimization: Selection of optimal stock combinations based on forecasts
- Performance Tracking: Historical tracking of portfolio performance
- Output Generation: Detailed reports in both JSON and Markdown formats
- Python 3.9+
- MongoDB
- Google Cloud API key for Gemini AI
- Google Search API key
- Clone the repository:
git clone https://github.com/yourusername/nifty-llm-research.git
cd nifty-llm-research
- Install dependencies:
pip install -r requirements.txt
- Set up environment variables:
cp env.template .env
# Edit .env with your API keys and configuration
- Seed the database with default prompts:
python scripts/seed_prompts.py
- Generate stock forecasts:
python scripts/analyze_stocks.py --index "NIFTY 50" --force-nse
- Generate portfolio recommendations:
python scripts/generate_portfolio.py --index "NIFTY 50" --filter-top-n 20 --basket-size-k 5
This project was developed using Cursor IDE's AI pair programming capabilities. To see how the code was written:
- Check the
prompts/
directory to see the actual Cursor prompts used during development - Each prompt file shows the exact conversation that led to the implementation
- This serves as a proof of authenticity and helps understand the development process
The core of this project lies in its carefully crafted prompts. To understand how the code works:
- Check the
scripts/seed_prompts.py
file to see the default prompts - Review the prompt configurations in the database
- Understand how each prompt is used in the respective agents
All portfolio recommendations are saved in the docs/baskets
directory:
- JSON files containing the full analysis
- Markdown files with formatted tables and explanations
- Files are named as:
{index}-{timestamp}-{n}-{k}.{json/md}
nifty-llm-research/
├── config/ # Configuration files
├── docs/ # Documentation and outputs
│ └── baskets/ # Portfolio recommendations
├── prompts/ # Development history and Cursor prompts
├── scripts/ # Command-line scripts
├── src/ # Source code
│ ├── agents/ # LLM agents
│ ├── db/ # Database models and utilities
│ ├── utils/ # Utility functions
│ └── visualization/# Plotting and visualization
└── tests/ # Test files
- Fork the repository
- Create a feature branch
- Commit your changes
- Push to the branch
- Create a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
- Google Gemini AI for the LLM capabilities
- NSE for stock data
- Contributors and maintainers