A comprehensive toolkit for stock market analysis and reporting
Project description
Stock Analysis Toolkit
A comprehensive Python toolkit for analyzing stocks using technical and fundamental analysis. This package provides tools to fetch stock data, perform in-depth analysis, generate visualizations, and create detailed reports.
✨ Features
-
Multi-source Data Collection
- BSE stocks (e.g.,
500325.BOfor RELIANCE) - NSE stocks (e.g.,
RELIANCE.NSorNSE:RELIANCE) - Market indices (e.g.,
^NSEIfor NIFTY 50) - Mutual funds (by name or code)
- BSE stocks (e.g.,
-
Technical Analysis
- RSI, MACD, Bollinger Bands
- Moving Averages (SMA, EMA)
- Volume indicators
- Custom technical indicators
-
Fundamental Analysis
- P/E, P/B, P/S ratios
- ROE, ROA, and other profitability metrics
- Debt/Equity and other leverage ratios
- Dividend yield and history
-
Reporting & Visualization
- Interactive charts with Plotly
- Detailed HTML reports
- Email notifications with reports
- Custom report templates
🚀 Installation
Basic Installation
pip install stock-analysis-toolkit
With Optional Dependencies
pip install "stock-analysis-toolkit[full]"
For Development
git clone https://github.com/pranav87/stock_analysis.git
cd stock_analysis
pip install -e ".[dev]"
TA-Lib Installation (Required for Technical Analysis)
- macOS:
brew install ta-lib - Linux:
sudo apt-get install -y python3-ta-lib - Windows: Download the appropriate wheel from here
📝 Configuration
Create a .env file in your project root with the following variables:
# Required for Alpha Vantage API
ALPHA_VANTAGE_API_KEY=your_api_key_here
# Optional: Email settings
SMTP_SERVER=smtp.gmail.com
SMTP_PORT=587
SENDER_EMAIL=your_email@gmail.com
SENDER_PASSWORD=your_app_specific_password
SENDER_EMAIL=your_email@gmail.com SENDER_PASSWORD=your_app_specific_password
## Usage
Once installed, you can use the `stock-analyzer` command from your terminal.
### Command-Line Interface
```bash
stock-analyzer --help
usage: stock-analyzer [-h] [-s STOCKS] [-mf MUTUAL_FUNDS [MUTUAL_FUNDS ...]] [--mf-codes MF_CODES [MF_CODES ...]] [-d DAYS] [-e EMAIL] [--no-cache] [-v] [--send-email]
Stock and Mutual Fund Analysis Tool
options:
-h, --help show this help message and exit
-s STOCKS, --stocks STOCKS
Stock symbol to analyze. Can be specified multiple times (e.g., -s RELIANCE.NS -s TCS.NS)
-mf MUTUAL_FUNDS [MUTUAL_FUNDS ...], --mutual_funds MUTUAL_FUNDS [MUTUAL_FUNDS ...]
Mutual fund name to analyze. Can be specified multiple times. For multi-word names, wrap in quotes.
--mf-codes MF_CODES [MF_CODES ...]
Mutual fund scheme codes to analyze. Can be specified multiple times (e.g., --mf-codes 108467 120757).
-d DAYS, --days DAYS Number of days for historical data analysis (default: 90)
-e EMAIL, --email EMAIL
Email address to send the report to.
--no-cache Disable caching of analysis results
-v, --verbose Enable verbose logging for debugging
--send-email Flag to send the report via email. Requires --email to be set.
Sample Run Command
Here is an example command to analyze two stocks and two mutual funds, and then email the report:
stock-analyzer -s RELIANCE.NS -s TCS.NS --mf-codes 107578 120465 -e your-email@example.com --send-email
This command analyzes Reliance and TCS, along with the mutual funds for "Mirae Asset Large Cap Fund" (107578) and "Axis Bluechip Fund" (120465).
Project Structure
stock-analysis/
├── config/ # Configuration files
│ └── config.py # Application configuration
├── data/ # Data storage
│ └── cache/ # Cached stock data
├── logs/ # Log files
├── reports/ # Generated reports
│ └── charts/ # Chart visualizations
├── src/ # Source code
│ ├── data_fetcher.py # Data collection from APIs
│ ├── technical_analysis.py # Technical indicators and analysis
│ ├── visualization.py # Data visualization
│ └── main.py # Main application and CLI
├── .env.example # Example environment variables
├── requirements.txt # Python dependencies
└── README.md # This file
Supported Stock Exchanges
- BSE (Bombay Stock Exchange): Use
.BOsuffix (e.g.,RELIANCE.BO) - NSE (National Stock Exchange): Use
.NSsuffix (e.g.,RELIANCE.NS)
Data Sources
- Primary: Google Finance
- Fallback: Yahoo Finance
- Additional: Alpha Vantage (for fundamental data, requires API key)
Email Configuration
To enable email notifications:
- Enable "Less secure app access" in your Gmail account settings or generate an App Password
- Set the following environment variables in your
.envfile:SENDER_EMAIL=your_email@gmail.com SENDER_PASSWORD=your_app_specific_password
Limitations
- Free API tiers may have rate limits
- Some fundamental data may not be available for all stocks
- Analysis should be used for informational purposes only
License
This project is licensed under the MIT License - see the LICENSE file for details.
Disclaimer
This tool is for educational and informational purposes only. It does not constitute financial advice. Always do your own research and consult with a licensed financial advisor before making investment decisions.
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file stock_analysis_toolkit-1.0.6.tar.gz.
File metadata
- Download URL: stock_analysis_toolkit-1.0.6.tar.gz
- Upload date:
- Size: 89.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
0f23cb80adb9dc84bfca7a0b00f00ae624cf245e197751557b45b388d42b439e
|
|
| MD5 |
a82bea6e44401720ec18db023bbdd709
|
|
| BLAKE2b-256 |
a03fe8a7cd678e45557f56b1b278aeb17fa164eb283562ee85d28afd1fe466dd
|
File details
Details for the file stock_analysis_toolkit-1.0.6-py3-none-any.whl.
File metadata
- Download URL: stock_analysis_toolkit-1.0.6-py3-none-any.whl
- Upload date:
- Size: 101.1 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.10.14
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dff060f11f6edc3dd5844d4716f3991a5c93f15dc6dc167937dec69084233aeb
|
|
| MD5 |
193f1ef8238b18bbff0c67b1f62c3909
|
|
| BLAKE2b-256 |
04824896d22a3e0a32d6af84524368d0df773da00d7c63ff7bad22b3274854ac
|