GithubHelp home page GithubHelp logo

open-source-modelling / bisection_alpha_python Goto Github PK

View Code? Open in Web Editor NEW
3.0 3.0 1.0 35 KB

Simple bisection method that finds the optimal parameter α for the Smith & Wilson algorithm.

Home Page: https://www.eiopa.europa.eu/sites/default/files/risk_free_interest_rate/12092019-technical_documentation.pdf

License: MIT License

Python 100.00%
insurance solvency-ii extrapolation risk-management actuarial smith-wilson bisection-method algorithm python

bisection_alpha_python's Introduction

🐍 Bisection for Smith-Wilson parameter 🐍

This repository has an implementation for a simple bisection method that finds the optimal parameter α for the Smith & Wilson algorithm often used in insurance to interpolate/extrapolate rates or yields.

The implementation is based on Technical documentation of the Methodology to derive EIOPA's risk-free interest rate term structure and Wiki on Bisection method.

Problem

Before using the Smith & Wilson algorithm, the user needs to provide the convergence speed parameter α. This parameter needs to be calibrated primarily so that that the extrapolated result matches the desired long-term behaviour.

Solution

By transforming the minimization problem at the point of convergence into a problem of finding a root of the shifted function g(α) - τ, this repository implements a simple bisection algorithm to find the optimal α.

Input

  • The minimum allowed value of the convergence speed parameter α.
  • The maximum allowed value of the convergence speed parameter α.
  • Maturities of bonds, observed on the market and provided as output.
  • Zero-coupon rates, for which the user wishes to calibrate the algorithm. Each rate belongs to an observable zero-coupon bond with a known maturity.
  • The ultimate forward rate towards which the user wishes the resulting curve to converge.
  • Allowed difference between the given ultimate forward rate and the resulting curve.
  • The numeric precision of the calculation. Higher the precision, more accurate the estimation of the root.
  • The maximum number of iterations allowed. This is to prevent an infinite loop in case the method does not converge to a solution.

Output

  • Optimal value of the parameter α (if the bisection method converged).

Note that to be consistent with EIOPA's recommendations, the lower bound of the interval should be set to 0.05.

Getting started

import numpy as np
from SWCalibrate import SWCalibrate as SWCalibrate
from SWExtrapolate import SWExtrapolate as SWExtrapolate
from bisection_alpha import Galfa as Galfa
from bisection_alpha import BisectionAlpha as BisectionAlpha

# Maturities of bonds observed on the market
M_Obs = np.transpose(np.array([1, 2, 4, 5, 6, 7]))

# Yields observed on the market
r_Obs = np.transpose(np.array([0.01, 0.02, 0.03, 0.032, 0.035, 0.04]))

# Ultimate forward rate
ufr = 0.04
# Numeric precision of the optimisation
Precision = 0.0000000001

# Targeted distance between the extrapolated curve and the ultimate forward rate at the convergence point
Tau = 0.0001 # 1 basis point

# Examples of a call to Galfa and BisectionAlpha
print("Example in the documentation for Galfa: "+ str(Galfa(M_Obs, r_Obs, ufr, 0.15, Tau)))
print("Example in the documentation for BisectionAlpha: "+ str(BisectionAlpha(0.05, 0.5, M_Obs, r_Obs, ufr, Tau, Precision, 1000)))

Note that this implementation use functions SWCalibrate and SWExtrapolate from the Smith & Wilson implementation. They are duplicated to this repository for completeness. If there are any inconsistencies or suggestions, raise an issue or contact us directly.

bisection_alpha_python's People

Contributors

gregorfabjan avatar open-source-modelling avatar

Stargazers

 avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar

Forkers

gregorfabjan

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.