Code Monkey home page Code Monkey logo

vasicek_one_factor_python's Introduction

๐Ÿ Vasicek One-Factor model ๐Ÿ

Vasicek one factor model for simulating the evolution of a credit instruments such as a government bonds. The Vasicek model assumes that the process evolves as an Ornstein-Uhlenbeck process. Ornstein-Uhlenbeck is a stochastic process where over time, the process tends to drift towards a long-term mean (mean reverting).

Problem

When trying to simulate for example credit spreads, there is a variety of models. The choice of the model and its limitations are a key factor in deciding which model to implement. There are compelling economic arguments in favour of mean reversion.

Solution

One of the simplest models, the Vasicek one factor model assumes that the credit market can be described by a simple mean reverting stochastic process with one source of uncertainty coming from a Brownian motion. One limitation is that due to normal distribution of the noise, the process allows negative spreads which might be undesirable in certain circumstances.

The stochastic differential equation (SDE) of the Vasicek model is shown on the Wiki page https://en.wikipedia.org/wiki/Vasicek_model

Input

  • r0 (float): starting interest rate of the Vasicek process.
  • a (float): speed of reversion" parameter that characterizes the velocity at which such trajectories will regroup around b in time.
  • lam (float): long term mean level. All future trajectories of r will evolve around this mean level in the long run.
  • sigma (float): instantaneous volatility measures instant by instant the amplitude of randomness entering the system.
  • T (integer): end modelling time. From 0 to T the time series runs.
  • dt (float): increment of time that the proces runs on. Ex. dt = 0.1 then the time series is 0, 0.1, 0.2,...

Output

  • N x 2 Pandas DataFrame with a sample path as values and modelling time as index.

Getting started

import numpy as np
import pandas as pd
from Vasicek_one_factor import simulate_Vasicek_One_Factor

r0 = 0.1    # The starting interest rate
a = 1.0     # Speed of reversion parameter
lam = 0.1   # Long-term mean interest rate level correction
sigma = 0.2 # Instantaneous volatility
T = 52      # End modelling time
dt = 0.1    # Increments of time

print(simulate_Vasicek_One_Factor(r0, a, lam, sigma, T, dt))

vasicek_one_factor_python's People

Contributors

gregorfabjan avatar open-source-modelling avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar

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.