varport


Namevarport JSON
Version 0.1.1 PyPI version JSON
download
home_pagehttps://github.com/your-github-account/varport
SummaryA library to calculate derivatives VAR portfolio and generate a report
upload_time2024-09-20 12:47:55
maintainerNone
docs_urlNone
authorYour Name
requires_python>=3.8
licenseNone
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # VARPORT

VARPORT is a Python library to calculate Value at Risk (VaR) of a derivatives portfolio and generate reports .

## Features

- Compute VaR using Monte Carlo simulations
- Generate PDF reports with portfolio summaries and charts
- Supports options and futures portfolios

## Installation

```bash


#usage

pip install varport
from varport import ReportGenerator, MainVaRProcessor
import numpy as np

# Load your portfolio from a CSV file
portfolio_file = 'C:/xxx/portfolio.csv'

# Example user input for mu and Sigma
mu = np.array([0.05, 0.03, 0.07, 0.04, 0.06])  # Example mu vector (expected returns)
Sigma = np.array([[0.1, 0.02, 0.03, 0.01, 0.04],  # Example covariance matrix
                  [0.02, 0.08, 0.01, 0.03, 0.02],
                  [0.03, 0.01, 0.09, 0.02, 0.01],
                  [0.01, 0.03, 0.02, 0.07, 0.02],
                  [0.04, 0.02, 0.01, 0.02, 0.08]])

# Initialize MainVaRProcessor with the portfolio file path
var_processor = MainVaRProcessor(filepath=portfolio_file)

# Process the portfolio with user-provided mu and Sigma to calculate VaR and differences
portfolio, VaR, differences = var_processor.process(mu=mu, Sigma=Sigma)

# Generate the report with the calculated differences and VaR
report = ReportGenerator(differences=differences, VaR=VaR, portfolio=portfolio)

# Generate and save the PDF report
report.display_table_and_chart(pdf_filename="VaR_Report_Test.pdf")

print("Report generated successfully!")


# Portfolio Management Tool

## Overview

This tool allows users to manage their portfolio of financial instruments such as options and futures. You can upload your portfolio in a CSV file format that follows the required structure outlined below.

---

## Portfolio File Format

The portfolio file should be in `.csv` format and must include the following columns:

### Required Columns:

1. **date** (string, in `dd/mm/yyyy` format):  
   The date the trade was made.
   
2. **instrument_type** (string):  
   Specifies the type of financial instrument. Supported values:
   - `option`
   - `future`
   
3. **underlying_asset** (string):  
   The underlying asset for the trade (e.g., "sugar", "cocoa", "coffee").
   
4. **quantity** (integer):  
   The quantity of the asset in the trade. Positive values for long positions, negative values for short positions.
   
5. **lot_size** (integer):  
   Lot size for the contract. Typically `1`, but may vary.
   
6. **option_type** (string, optional for non-option instruments):  
   Type of option for option instruments. Supported values:
   - `put`
   - `call`
   
7. **strike_price** (numeric, optional for non-option instruments):  
   The strike price of the option contract.

8. **implied_volatility** (numeric):  
   The implied volatility of the option, typically represented as a decimal.

9. **expiry** (string, in `dd/mm/yyyy` format):  
   The expiration date of the option or future contract.
   
10. **underlying_future_expiry** (string, in `dd/mm/yyyy` format, optional for non-futures):  
    The expiry date of the underlying future, if applicable.

11. **risk_free_rate** (numeric):  
    The risk-free interest rate assumed in the valuation model, typically expressed as a decimal.

12. **volatility** (numeric):  
    The actual volatility of the underlying asset, represented as a decimal.

13. **underlying_price** (numeric):  
    The price of the underlying asset at the time of trade.

---

## Example CSV File

```csv
date,instrument_type,underlying_asset,quantity,lot_size,option_type,strike_price,implied_volatility,expiry,underlying_future_expiry,risk_free_rate,volatility,underlying_price
13/04/2023,option,sugar,27,1,put,200,0.478477817,31/10/2025,30/04/2025,0.031413423,0.215497254,429.494494
15/12/2023,option,cocoa,-83,1,call,300,0.41251842,30/04/2025,31/01/2025,0.019328656,0.17107249,478.6526844
28/09/2023,future,sugar,-76,1,,,0.472371642,31/08/2025,30/04/2025,0.028958798,0.206371496,467.5348595
...

            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/your-github-account/varport",
    "name": "varport",
    "maintainer": null,
    "docs_url": null,
    "requires_python": ">=3.8",
    "maintainer_email": null,
    "keywords": null,
    "author": "Your Name",
    "author_email": "raghuramanvarp@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/04/37/6307b961deb65eb01bea111479ee0362c642c1ce6d1abf2507a13d5c5ec4/varport-0.1.1.tar.gz",
    "platform": null,
    "description": "# VARPORT\r\n\r\nVARPORT is a Python library to calculate Value at Risk (VaR) of a derivatives portfolio and generate reports .\r\n\r\n## Features\r\n\r\n- Compute VaR using Monte Carlo simulations\r\n- Generate PDF reports with portfolio summaries and charts\r\n- Supports options and futures portfolios\r\n\r\n## Installation\r\n\r\n```bash\r\n\r\n\r\n#usage\r\n\r\npip install varport\r\nfrom varport import ReportGenerator, MainVaRProcessor\r\nimport numpy as np\r\n\r\n# Load your portfolio from a CSV file\r\nportfolio_file = 'C:/xxx/portfolio.csv'\r\n\r\n# Example user input for mu and Sigma\r\nmu = np.array([0.05, 0.03, 0.07, 0.04, 0.06])  # Example mu vector (expected returns)\r\nSigma = np.array([[0.1, 0.02, 0.03, 0.01, 0.04],  # Example covariance matrix\r\n                  [0.02, 0.08, 0.01, 0.03, 0.02],\r\n                  [0.03, 0.01, 0.09, 0.02, 0.01],\r\n                  [0.01, 0.03, 0.02, 0.07, 0.02],\r\n                  [0.04, 0.02, 0.01, 0.02, 0.08]])\r\n\r\n# Initialize MainVaRProcessor with the portfolio file path\r\nvar_processor = MainVaRProcessor(filepath=portfolio_file)\r\n\r\n# Process the portfolio with user-provided mu and Sigma to calculate VaR and differences\r\nportfolio, VaR, differences = var_processor.process(mu=mu, Sigma=Sigma)\r\n\r\n# Generate the report with the calculated differences and VaR\r\nreport = ReportGenerator(differences=differences, VaR=VaR, portfolio=portfolio)\r\n\r\n# Generate and save the PDF report\r\nreport.display_table_and_chart(pdf_filename=\"VaR_Report_Test.pdf\")\r\n\r\nprint(\"Report generated successfully!\")\r\n\r\n\r\n# Portfolio Management Tool\r\n\r\n## Overview\r\n\r\nThis tool allows users to manage their portfolio of financial instruments such as options and futures. You can upload your portfolio in a CSV file format that follows the required structure outlined below.\r\n\r\n---\r\n\r\n## Portfolio File Format\r\n\r\nThe portfolio file should be in `.csv` format and must include the following columns:\r\n\r\n### Required Columns:\r\n\r\n1. **date** (string, in `dd/mm/yyyy` format):  \r\n   The date the trade was made.\r\n   \r\n2. **instrument_type** (string):  \r\n   Specifies the type of financial instrument. Supported values:\r\n   - `option`\r\n   - `future`\r\n   \r\n3. **underlying_asset** (string):  \r\n   The underlying asset for the trade (e.g., \"sugar\", \"cocoa\", \"coffee\").\r\n   \r\n4. **quantity** (integer):  \r\n   The quantity of the asset in the trade. Positive values for long positions, negative values for short positions.\r\n   \r\n5. **lot_size** (integer):  \r\n   Lot size for the contract. Typically `1`, but may vary.\r\n   \r\n6. **option_type** (string, optional for non-option instruments):  \r\n   Type of option for option instruments. Supported values:\r\n   - `put`\r\n   - `call`\r\n   \r\n7. **strike_price** (numeric, optional for non-option instruments):  \r\n   The strike price of the option contract.\r\n\r\n8. **implied_volatility** (numeric):  \r\n   The implied volatility of the option, typically represented as a decimal.\r\n\r\n9. **expiry** (string, in `dd/mm/yyyy` format):  \r\n   The expiration date of the option or future contract.\r\n   \r\n10. **underlying_future_expiry** (string, in `dd/mm/yyyy` format, optional for non-futures):  \r\n    The expiry date of the underlying future, if applicable.\r\n\r\n11. **risk_free_rate** (numeric):  \r\n    The risk-free interest rate assumed in the valuation model, typically expressed as a decimal.\r\n\r\n12. **volatility** (numeric):  \r\n    The actual volatility of the underlying asset, represented as a decimal.\r\n\r\n13. **underlying_price** (numeric):  \r\n    The price of the underlying asset at the time of trade.\r\n\r\n---\r\n\r\n## Example CSV File\r\n\r\n```csv\r\ndate,instrument_type,underlying_asset,quantity,lot_size,option_type,strike_price,implied_volatility,expiry,underlying_future_expiry,risk_free_rate,volatility,underlying_price\r\n13/04/2023,option,sugar,27,1,put,200,0.478477817,31/10/2025,30/04/2025,0.031413423,0.215497254,429.494494\r\n15/12/2023,option,cocoa,-83,1,call,300,0.41251842,30/04/2025,31/01/2025,0.019328656,0.17107249,478.6526844\r\n28/09/2023,future,sugar,-76,1,,,0.472371642,31/08/2025,30/04/2025,0.028958798,0.206371496,467.5348595\r\n...\r\n",
    "bugtrack_url": null,
    "license": null,
    "summary": "A library to calculate derivatives VAR portfolio and generate a report",
    "version": "0.1.1",
    "project_urls": {
        "Homepage": "https://github.com/your-github-account/varport"
    },
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "56698031f3089f802ce28f80c7d74fd2795117ea798655b0b174dfc3056b41d0",
                "md5": "e360dcc87f4642577b8395465e6b9eb6",
                "sha256": "643c05f8973a5724c5ea60ca8a99abb639d6319805254e48855bbc68256cfe5f"
            },
            "downloads": -1,
            "filename": "varport-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "e360dcc87f4642577b8395465e6b9eb6",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8",
            "size": 10991,
            "upload_time": "2024-09-20T12:47:53",
            "upload_time_iso_8601": "2024-09-20T12:47:53.418781Z",
            "url": "https://files.pythonhosted.org/packages/56/69/8031f3089f802ce28f80c7d74fd2795117ea798655b0b174dfc3056b41d0/varport-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "04376307b961deb65eb01bea111479ee0362c642c1ce6d1abf2507a13d5c5ec4",
                "md5": "3dd0287b033ec1f7957314e5315fe17f",
                "sha256": "73c2f51bbb3fb9145b054281dd9bfe55311afc8d18baddf9feadb6b529acf4b4"
            },
            "downloads": -1,
            "filename": "varport-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "3dd0287b033ec1f7957314e5315fe17f",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8",
            "size": 11605,
            "upload_time": "2024-09-20T12:47:55",
            "upload_time_iso_8601": "2024-09-20T12:47:55.018820Z",
            "url": "https://files.pythonhosted.org/packages/04/37/6307b961deb65eb01bea111479ee0362c642c1ce6d1abf2507a13d5c5ec4/varport-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-09-20 12:47:55",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "your-github-account",
    "github_project": "varport",
    "github_not_found": true,
    "lcname": "varport"
}
        
Elapsed time: 0.45372s