Skip to content

Instantly share code, notes, and snippets.

@yogiben
Last active October 11, 2018 11:56
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save yogiben/648ba7396e60e9c4345a210ef032986a to your computer and use it in GitHub Desktop.
Save yogiben/648ba7396e60e9c4345a210ef032986a to your computer and use it in GitHub Desktop.
# -*- coding: utf-8 -*-
import numpy as np
from riskMeasurement import readEodPrices, calcEodReturns, calcAggregatedReturn, calcVcVar
eodPrices = readEodPrices('eodTs_BTC_EUR.csv')
eodReturns = calcEodReturns(eodPrices)
aggregatedReturns = calcAggregatedReturn(eodReturns)
currentBtcEur = 5000
btcHeld = 500
def valuationFunction(currentPrices):
return btcHeld * currentPrices
# 1-year VaR 99%
oneYear99 = calcVcVar(eodReturns, np.array([currentBtcEur]), valuationFunction, 365, 0.01)
# VaR limit
# Provided by sB
# VaR limit utilisation
limitUtilisation = oneYear99 / varLimit
# 1 day VaR 99%
oneDay99 = calcVcVar(eodReturns, np.array([currentBtcEur]), valuationFunction, 1, 0.01)
# 1 year VaR 99.5%
oneYear99point5 = calcVcVar(eodReturns, np.array([currentBtcEur]), valuationFunction, 1, 0.005)
# 1 year Var 99.9
oneYear99point9 = oneYear99point5 = calcVcVar(eodReturns, np.array([currentBtcEur]), valuationFunction, 1, 0.001)
# total loss VaR
totalLoss = currentBtcEur * btcHeld
# 1 year max VaR
# max value of eodReturns
# 10 day VaR (assuming 99%)
tenDay = calcVcVar(eodReturns, np.array([currentBtcEur]), valuationFunction, 10, 0.01)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment