Skip to main content

ape-risk: DeFi risk analysis as an ApeWorX plugin

Project description

Quick Start

Tools for analyzing risk in DeFi.

Dependencies

  • python3 version 3.8 or greater, python3-dev

Installation

via pip

You can install the latest release via pip:

pip install ape-risk

via setuptools

You can clone the repository and use setuptools for the most up-to-date version:

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

Quick Usage

Provides hypothesis strategies to use in fuzz tests.

e.g. Mock prices generated by Geometric Brownian motion:

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)

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.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ape-risk-0.1.0a3.tar.gz (524.2 kB view details)

Uploaded Source

Built Distribution

ape_risk-0.1.0a3-py3-none-any.whl (12.3 kB view details)

Uploaded Python 3

File details

Details for the file ape-risk-0.1.0a3.tar.gz.

File metadata

  • Download URL: ape-risk-0.1.0a3.tar.gz
  • Upload date:
  • Size: 524.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for ape-risk-0.1.0a3.tar.gz
Algorithm Hash digest
SHA256 9be302516e2cf88d5892114ad5d1f96f2bf582ed49f9429389966d85edd002d6
MD5 cfbecd16923cd45c882f3ee7abe69360
BLAKE2b-256 c78982e2fbfa2e7f277e53551ad04743cb2d1812b21a593d11f709c4c730e29e

See more details on using hashes here.

File details

Details for the file ape_risk-0.1.0a3-py3-none-any.whl.

File metadata

  • Download URL: ape_risk-0.1.0a3-py3-none-any.whl
  • Upload date:
  • Size: 12.3 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.8.16

File hashes

Hashes for ape_risk-0.1.0a3-py3-none-any.whl
Algorithm Hash digest
SHA256 707ae02eef2376d59258c1b38e9abcd79d6aebc97fefbd71cc2ed539bb903d3f
MD5 66b7e753a8c396bc77f32908a196b1ec
BLAKE2b-256 1df86da65155629f6df401dd5a91e8e55fa6502a8d4e02e41ef3f9245158dbf2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page