ape-risk


Nameape-risk JSON
Version 0.1.0a4 PyPI version JSON
download
home_pagehttps://github.com/smolquants/ape-risk
Summaryape-risk: DeFi risk analysis as an ApeWorX plugin
upload_time2023-08-22 18:08:37
maintainer
docs_urlNone
authorsmolquants
requires_python>=3.8,<4
licenseApache-2.0
keywords ethereum
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # Quick Start

Tools for analyzing risk in DeFi.

## Dependencies

* [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev

## Installation

### via `pip`

You can install the latest release via [`pip`](https://pypi.org/project/pip/):

```bash
pip install ape-risk
```

### via `setuptools`

You can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:

```bash
git clone https://github.com/ApeWorX/ape-risk.git
cd ape-risk
python3 setup.py install
```

## Quick Usage

Provides [hypothesis](https://github.com/HypothesisWorks/hypothesis) strategies to use in fuzz tests.

e.g. Mock prices generated by [Geometric Brownian motion](https://en.wikipedia.org/wiki/Geometric_Brownian_motion):

```python
import numpy as np
from ape_risk import strategies


@given(strategies.gbms(initial_value=1.0, num_points=100000, params=[0, 0.005]))
def test_gbms_param_fuzz(p):
    # strat gives a numpy.ndarray of simulated prices for each hypothesis run
    assert p.shape == (100000, 1)
    assert isinstance(p, np.ndarray)


C = np.asarray([[1, 0.5, 0.8], [0.5, 1, 0.4], [0.8, 0.4, 1]])
scale = np.linalg.cholesky(C).tolist()


@given(strategies.multi_gbms(initial_values=[1.0, 0.9, 0.8], num_points=100000, num_rvs=3, params=[0, 0.005], scale=scale, shift=[0, 0, 0]))
def test_multi_gbms_param_fuzz(p):
    # strat gives a numpy.ndarray of multiple simulated prices for each hypothesis run
    assert p.shape == (100000, 1, 3)
    assert isinstance(p, np.ndarray)
```

![](notebook/multi_example.png)

## Development

This project is in development and should be considered an alpha.
Things might not be in their final state and breaking changes may occur.
Comments, questions, criticisms and pull requests are welcomed.



            

Raw data

            {
    "_id": null,
    "home_page": "https://github.com/smolquants/ape-risk",
    "name": "ape-risk",
    "maintainer": "",
    "docs_url": null,
    "requires_python": ">=3.8,<4",
    "maintainer_email": "",
    "keywords": "ethereum",
    "author": "smolquants",
    "author_email": "dev@smolquants.xyz",
    "download_url": "https://files.pythonhosted.org/packages/2a/f9/1ea80e0c3fc0bab282e8721047d6836649da957c94e3f3c670225e757f41/ape-risk-0.1.0a4.tar.gz",
    "platform": null,
    "description": "# Quick Start\n\nTools for analyzing risk in DeFi.\n\n## Dependencies\n\n* [python3](https://www.python.org/downloads) version 3.8 or greater, python3-dev\n\n## Installation\n\n### via `pip`\n\nYou can install the latest release via [`pip`](https://pypi.org/project/pip/):\n\n```bash\npip install ape-risk\n```\n\n### via `setuptools`\n\nYou can clone the repository and use [`setuptools`](https://github.com/pypa/setuptools) for the most up-to-date version:\n\n```bash\ngit clone https://github.com/ApeWorX/ape-risk.git\ncd ape-risk\npython3 setup.py install\n```\n\n## Quick Usage\n\nProvides [hypothesis](https://github.com/HypothesisWorks/hypothesis) strategies to use in fuzz tests.\n\ne.g. Mock prices generated by [Geometric Brownian motion](https://en.wikipedia.org/wiki/Geometric_Brownian_motion):\n\n```python\nimport numpy as np\nfrom ape_risk import strategies\n\n\n@given(strategies.gbms(initial_value=1.0, num_points=100000, params=[0, 0.005]))\ndef test_gbms_param_fuzz(p):\n    # strat gives a numpy.ndarray of simulated prices for each hypothesis run\n    assert p.shape == (100000, 1)\n    assert isinstance(p, np.ndarray)\n\n\nC = np.asarray([[1, 0.5, 0.8], [0.5, 1, 0.4], [0.8, 0.4, 1]])\nscale = np.linalg.cholesky(C).tolist()\n\n\n@given(strategies.multi_gbms(initial_values=[1.0, 0.9, 0.8], num_points=100000, num_rvs=3, params=[0, 0.005], scale=scale, shift=[0, 0, 0]))\ndef test_multi_gbms_param_fuzz(p):\n    # strat gives a numpy.ndarray of multiple simulated prices for each hypothesis run\n    assert p.shape == (100000, 1, 3)\n    assert isinstance(p, np.ndarray)\n```\n\n![](notebook/multi_example.png)\n\n## Development\n\nThis project is in development and should be considered an alpha.\nThings might not be in their final state and breaking changes may occur.\nComments, questions, criticisms and pull requests are welcomed.\n\n\n",
    "bugtrack_url": null,
    "license": "Apache-2.0",
    "summary": "ape-risk: DeFi risk analysis as an ApeWorX plugin",
    "version": "0.1.0a4",
    "project_urls": {
        "Homepage": "https://github.com/smolquants/ape-risk"
    },
    "split_keywords": [
        "ethereum"
    ],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "46c217490715bee07a0689a53d1369adb3fc5e1069971029551ce7d589b08daa",
                "md5": "587f2e19f405027fdb21435342b69cc3",
                "sha256": "8934af2fd5691402c30a047e03ee41d927771121d44735bd77216d148f2cb9f0"
            },
            "downloads": -1,
            "filename": "ape_risk-0.1.0a4-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "587f2e19f405027fdb21435342b69cc3",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": ">=3.8,<4",
            "size": 12255,
            "upload_time": "2023-08-22T18:08:35",
            "upload_time_iso_8601": "2023-08-22T18:08:35.791285Z",
            "url": "https://files.pythonhosted.org/packages/46/c2/17490715bee07a0689a53d1369adb3fc5e1069971029551ce7d589b08daa/ape_risk-0.1.0a4-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "2af91ea80e0c3fc0bab282e8721047d6836649da957c94e3f3c670225e757f41",
                "md5": "51a280aea993040d3b35827f347a6f3d",
                "sha256": "983d5125c4c9db153c598e6a879e3c58b33c0b1a6b33d6665703155179184f3b"
            },
            "downloads": -1,
            "filename": "ape-risk-0.1.0a4.tar.gz",
            "has_sig": false,
            "md5_digest": "51a280aea993040d3b35827f347a6f3d",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": ">=3.8,<4",
            "size": 524205,
            "upload_time": "2023-08-22T18:08:37",
            "upload_time_iso_8601": "2023-08-22T18:08:37.059471Z",
            "url": "https://files.pythonhosted.org/packages/2a/f9/1ea80e0c3fc0bab282e8721047d6836649da957c94e3f3c670225e757f41/ape-risk-0.1.0a4.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2023-08-22 18:08:37",
    "github": true,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "github_user": "smolquants",
    "github_project": "ape-risk",
    "travis_ci": false,
    "coveralls": false,
    "github_actions": true,
    "lcname": "ape-risk"
}
        
Elapsed time: 0.12121s