Git Product home page Git Product logo

overlay-risk's Introduction

overlay-risk

Simple on-chain risk metrics to inform our choices for per-market funding constants.

Assumptions

We sample data from on-chain oracles and assume the underlying feed exhibits Geometric Brownian motion of the form

P_j = P_0 * e**(mu * j * T + sig * W(j*T))

where W(j*T) is a Wiener process, j is an int for the number of update intervals that occur after the initial feed value of P_0, and T is the update interval of the respective feed (e.g. sliding window oracles currently maintained by Keep3r Network have T = periodSize = 30 min).

Why?

We need some way to assess the risk to the system. A good approach is to model the underlying feed value as being driven by a stochastic process, which allows us to estimate expected values to be paid out by the protocol for an imbalance in positions on a market in addition to the "VaR" for passive OVL holders, who act as the counterparty to all unbalanced trades.

Calculation of our per-market risk metrics requires estimating distributional parameters for the underlying stochastic model. This repo aims to provide easy to access views on-chain for those parameters (i.e. maximum likelihood estimates for mu and sig above).

Requirements

To run the project you need:

  • Python >=3.7.2 local development environment
  • Brownie local environment setup
  • Set env variables for Etherscan API and Infura: ETHERSCAN_TOKEN and WEB3_INFURA_PROJECT_ID
  • Local Ganache environment installed
  • InfluxDB set up with local environment variables: INFLUXDB_TOKEN, INFLUXDB_ORG, INFLUXDB_URL

Installation

Using Poetry for dependencies. Install with pipx

pipx install poetry

Clone the repo, then

poetry install

within the local dir.

Scripts

To run, for example, the script to ingest stat parameters for historical risk analysis, do

poetry shell
brownie run influx_kv1o --network mainnet

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.