{"id":29669385,"url":"https://github.com/iammohith/var_calculator","last_synced_at":"2025-07-22T18:35:59.310Z","repository":{"id":304789851,"uuid":"1019975530","full_name":"iammohith/VaR_Calculator","owner":"iammohith","description":"A command-line tool for calculating Value at Risk (VaR) of Indian stocks using three different methodologies by fetching the data from the yfinance api. This tool helps investors quantify potential portfolio losses under normal market conditions.","archived":false,"fork":false,"pushed_at":"2025-07-15T12:37:31.000Z","size":80,"stargazers_count":0,"open_issues_count":0,"forks_count":0,"subscribers_count":0,"default_branch":"main","last_synced_at":"2025-07-15T15:23:21.245Z","etag":null,"topics":["bse","cli","historical","india","monte-carlo","nse","parametric","python","stock-market","value-at-risk","yfinance","yfinance-api"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/iammohith.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null}},"created_at":"2025-07-15T06:46:26.000Z","updated_at":"2025-07-15T12:37:35.000Z","dependencies_parsed_at":"2025-07-15T15:51:45.301Z","dependency_job_id":"1f27463b-8f0a-4887-a7fd-2ebcf2a6c080","html_url":"https://github.com/iammohith/VaR_Calculator","commit_stats":null,"previous_names":["iammohith/var_calculator"],"tags_count":null,"template":false,"template_full_name":null,"purl":"pkg:github/iammohith/VaR_Calculator","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammohith%2FVaR_Calculator","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammohith%2FVaR_Calculator/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammohith%2FVaR_Calculator/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammohith%2FVaR_Calculator/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/iammohith","download_url":"https://codeload.github.com/iammohith/VaR_Calculator/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/iammohith%2FVaR_Calculator/sbom","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":266552761,"owners_count":23947184,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","status":"online","status_checked_at":"2025-07-22T02:00:09.085Z","response_time":66,"last_error":null,"robots_txt_status":null,"robots_txt_updated_at":null,"robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bse","cli","historical","india","monte-carlo","nse","parametric","python","stock-market","value-at-risk","yfinance","yfinance-api"],"created_at":"2025-07-22T18:35:58.538Z","updated_at":"2025-07-22T18:35:59.288Z","avatar_url":"https://github.com/iammohith.png","language":"Python","funding_links":[],"categories":[],"sub_categories":[],"readme":"# VaR Calculator for Indian Stocks\n\nA command-line tool that calculates Value at Risk (VaR) for Indian stocks using three different methodologies by fetcheing stock data from Yahoo Finance API. This tool helps investors quantify potential portfolio losses under normal market conditions.\n\n## Features\n\n- **Three Calculation Methods**:\n  - 📊 Parametric (Variance-Covariance)\n  - 📈 Historical Simulation\n  - 🎲 Monte Carlo Simulation\n- **Exchange Support**: Works with both NSE and BSE stocks\n- **Visual Reports**: Generates comparative charts of results\n- **Configurable Parameters**: Adjust confidence level, time horizon, etc.\n- **Automatic Data Management**: Creates necessary directories at runtime\n- **Comprehensive Reporting**: Saves portfolio data and generates comparison charts\n\n## Installation\n\n1. Clone the repository:\n```bash\ngit clone https://github.com/iammohith/VaR_Calculator.git\ncd VaR_Calculator\n```\n\n2. Install dependencies:\n```bash\npip install -r requirements.txt\n```\n\n## Usage\n\n### Basic Command:\n```bash\npython main.py [TICKER] [EXCHANGE] [PORTFOLIO_VALUE] [OPTIONS]\n```\n\n### Arguments:\n| Argument          | Description                         | Example       |\n|-------------------|-------------------------------------|---------------|\n| `TICKER`          | Stock ticker symbol                 | `RELIANCE`    |\n| `EXCHANGE`        | `NSE` or `BSE`                      | `NSE`         |\n| `PORTFOLIO_VALUE` | Portfolio value in INR              | `1000000`     |\n\n### Options:\n| Option              | Description                          | Default |\n|---------------------|--------------------------------------|---------|\n| `--confidence`      | Confidence level (0.90-0.99)         | 0.95    |\n| `--horizon`         | Time horizon in days                 | 1       |\n| `--window`          | Historical data window (days)        | 252     |\n| `--simulations`     | Monte Carlo simulations count        | 10000   |\n\n### Example:\n```bash\npython main.py RELIANCE NSE 1000000 --confidence 0.99 --horizon 5\n```\n\n### Sample Output:\n```\n2025-07-16 10:19:28 - src.cli - INFO - Calculating VaR for RELIANCE on NSE\n2025-07-16 10:19:28 - src.cli - INFO - Portfolio value: ₹1,000,000.00\n2025-07-16 10:19:28 - src.cli - INFO - Confidence: 99.0%, Horizon: 5 days\n2025-07-16 10:19:28 - src.cli - INFO - Data window: 252 days, Simulations: 10000\n\nValue at Risk for RELIANCE (NSE) portfolio of value ₹1,000,000.00:\n• Parametric VaR:   ₹67,788.39\n• Historical VaR:   ₹74,384.95\n• Monte Carlo VaR:  ₹69,182.25\n```\n\n### Sample Report:\n![VaR Comparison Report](data/reports/var_report_iammohith_NSE_RELIANCE_20250716_101928.png)\n\n## Project File Structure\n\n```\nVaR_Calculator/\n├── config/                  # Configuration files\n│   ├── logging.conf         # Logging setup\n│   └── settings.py          # Application settings\n├── data/                    # Auto-generated data\n│   ├── logs/                # Application logs\n│   ├── portfolios/          # Portfolio data\n│   └── reports/             # Generated charts\n├── src/                     # Source code\n│   ├── cli.py               # Command-line interface\n│   ├── data_fetcher.py      # Stock data retrieval\n│   ├── exceptions.py        # Custom errors\n│   ├── historical_var.py    # Historical VaR\n│   ├── monte_carlo_var.py   # Monte Carlo VaR\n│   ├── parametric_var.py    # Parametric VaR\n│   ├── report_generator.py  # Report creation\n│   └── utils.py             # Helper functions\n├── main.py                  # Application entry\n├── .gitignore               # Ignore files\n├── LICENSE                  # MIT License\n├── README.md                # This documentation\n└── requirements.txt         # Dependencies\n```\n\n## Dependencies\n\n- Python 3.8+\n- yfinance - Stock data fetching\n- numpy - Mathematical operations\n- pandas - Data handling\n- scipy - Statistical functions\n- matplotlib - Visualization\n\n## Key Features\n\n1. **Accurate Calculations**:\n   - Industry-standard VaR formulas\n   - Proper handling of time horizon scaling\n   - Robust input validation\n2. **Comprehensive Reporting**:\n   - Portfolio data saved as CSV\n   - Comparative visualization of all three methods\n   - Automatic timestamping of outputs\n3. **Exchange Support**:\n   - Clear identification of exchange in all outputs\n   - Supports both NSE and BSE\n4. **User-Friendly**:\n   - Detailed logging\n   - Clear console output\n   - Easy-to-understand reports\n\n## Limitations\n\n- Single-stock portfolios only\n- Uses daily closing prices\n- Monte Carlo assumes lognormal distribution\n- Requires internet connection for data fetching\n\n## Contributing\n\nContributions welcome! Please fork the repository and submit pull requests.\n\n## License\n\nMIT License - See [LICENSE](LICENSE) for details.\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiammohith%2Fvar_calculator","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fiammohith%2Fvar_calculator","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fiammohith%2Fvar_calculator/lists"}