Metadata-Version: 2.1
Name: ape-risk
Version: 0.1.0a3
Summary: ape-risk: DeFi risk analysis as an ApeWorX plugin
Home-page: https://github.com/smolquants/ape-risk
Author: smolquants
Author-email: dev@smolquants.xyz
License: Apache-2.0
Keywords: ethereum
Platform: UNKNOWN
Classifier: Development Status :: 5 - Production/Stable
Classifier: Intended Audience :: Developers
Classifier: License :: OSI Approved :: Apache Software License
Classifier: Natural Language :: English
Classifier: Operating System :: MacOS
Classifier: Operating System :: POSIX
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.8
Classifier: Programming Language :: Python :: 3.9
Classifier: Programming Language :: Python :: 3.10
Requires-Python: >=3.8,<4
Description-Content-Type: text/markdown
Requires-Dist: eth-ape (<0.6.0,>=0.5.2)
Requires-Dist: pandas
Requires-Dist: scipy
Requires-Dist: numpy (<2.0,>=1.21)
Requires-Dist: hypothesis (<7.0,>=6.2.0)
Provides-Extra: dev
Requires-Dist: pytest (>=6.0) ; extra == 'dev'
Requires-Dist: pytest-xdist ; extra == 'dev'
Requires-Dist: pytest-cov ; extra == 'dev'
Requires-Dist: black (>=22.6.0) ; extra == 'dev'
Requires-Dist: mypy (>=0.971) ; extra == 'dev'
Requires-Dist: flake8 (>=4.0.1) ; extra == 'dev'
Requires-Dist: isort (>=5.10.1) ; extra == 'dev'
Requires-Dist: setuptools (<60.0) ; extra == 'dev'
Requires-Dist: wheel ; extra == 'dev'
Requires-Dist: twine ; extra == 'dev'
Requires-Dist: commitizen ; extra == 'dev'
Requires-Dist: pre-commit ; extra == 'dev'
Requires-Dist: pytest-watch ; extra == 'dev'
Requires-Dist: IPython ; extra == 'dev'
Requires-Dist: ipdb ; extra == 'dev'
Requires-Dist: matplotlib ; extra == 'dev'
Provides-Extra: lint
Requires-Dist: black (>=22.6.0) ; extra == 'lint'
Requires-Dist: mypy (>=0.971) ; extra == 'lint'
Requires-Dist: flake8 (>=4.0.1) ; extra == 'lint'
Requires-Dist: isort (>=5.10.1) ; extra == 'lint'
Provides-Extra: release
Requires-Dist: setuptools (<60.0) ; extra == 'release'
Requires-Dist: wheel ; extra == 'release'
Requires-Dist: twine ; extra == 'release'
Provides-Extra: test
Requires-Dist: pytest (>=6.0) ; extra == 'test'
Requires-Dist: pytest-xdist ; extra == 'test'
Requires-Dist: pytest-cov ; extra == 'test'

# 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.


