Skip to main content

Tools to backtest your VaR metric

Project description

To install, just use pip :

pip install varpy

Required Dependencies are listed below , such :

Dependency

Version

arch

5.0.1

numpy

1.20.1

scipy

1.6.2

pandas

0.12.2

numba

0.52.1

joblib

1.0.1

scipy

0.4

tabulate

3.3.4

There is no dependency verification , so please, make sure to have installed every required one before using the package.

Example

To begin, let’s extract default data:

import varpy
from varpy import EVT_VaR,Student_VaR,Normal_VaR
from varpy.Backtester.bktst import Backtest
from varpy.Backtester.time_Significance import Testing
import matplotlib.pyplot as plt

data = d1()* 100
data

Let’s compute our weekly standard VaR and CVaR

VaR,CVaR = Normal_VaR(data.values.reshape(-1,) ,0.05,7)
print(VaR,CVaR)

Let’s backtest our VaR, to evaluate its consistency throughout time

In each iteration, we choose to use a window of 500 data to evaluate our tail statistic. Additionally, our VaR is evaluated on a weekly basis for an alpha of 5%.

VaR , CVaR = Backtest(data,500,7,0.05,model = 'Gaussian')
ts = Testing(data,VaR,CVaR,500,0.05)
print(ts.summary)

Plot your VaR and CVaR

import matplotlib.pyplot as plt

fig = plt.figure(figsize=(15,5))
plt.plot(data[500:])
plt.plot(VaR)
plt.plot(CVaR)
plt.show()
https://raw.githubusercontent.com/EM51641/VaRpy/main/output/output.png

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

VaRpy-0.0.3.tar.gz (2.1 MB view details)

Uploaded Source

Built Distribution

VaRpy-0.0.3-py3-none-any.whl (80.0 kB view details)

Uploaded Python 3

File details

Details for the file VaRpy-0.0.3.tar.gz.

File metadata

  • Download URL: VaRpy-0.0.3.tar.gz
  • Upload date:
  • Size: 2.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for VaRpy-0.0.3.tar.gz
Algorithm Hash digest
SHA256 da61f68258a87107c87d1eec586aaa7f8ae1fd3b078c916290b5a49ccd6d41e8
MD5 ca5a3ca1fc963ef7ccc1cf2c020b79be
BLAKE2b-256 05b94f2a6e69520a96535b7e38806a549a71838861e4c5aaf1bcaedb6f472b1c

See more details on using hashes here.

File details

Details for the file VaRpy-0.0.3-py3-none-any.whl.

File metadata

  • Download URL: VaRpy-0.0.3-py3-none-any.whl
  • Upload date:
  • Size: 80.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.7.1 importlib_metadata/3.10.0 pkginfo/1.8.2 requests/2.25.1 requests-toolbelt/0.9.1 tqdm/4.59.0 CPython/3.8.8

File hashes

Hashes for VaRpy-0.0.3-py3-none-any.whl
Algorithm Hash digest
SHA256 1787b3b61f98340685cd9493cae0e1220306157239797bee565a9416cb887dce
MD5 dacc990ab8b64874b655fcd8995d8149
BLAKE2b-256 7b6bb20c4b043faccc135d25b62112329c630053663182ecceb9be2b980e39bc

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