Skip to content

Computational cost in Monte Carlo simulation using vectorization

License

Notifications You must be signed in to change notification settings

ymh1989/Vectorization

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

17 Commits
 
 
 
 
 
 

Repository files navigation

Computational cost in Monte Carlo simulation using vectorization

Introduction

This repo contains an implementation of pricing financial derivatives using Monte Calo simulation with vectorization calculation. Generally speaking, computer program spend most of the time in loop process. Especially, Monte Carlo simulation(MCS) in finance is mainly composed of for-loop or while-loop.

The main purpose of this repo is to introduce the method for increasing performance of MCS using vectorization calculation. The program is performed by Python.

Methods

As I mentioned in Introduction, loop is the main reason for increasing cpu time. It means that the more the number of loop and nested-loop, the more programs spend more time. In most programs with numerical methods, one of role of loop is to handle vector or matrix type data. To improve the performance of vector and matrix operation, several libraries has been developed such as Eigen-C++, Boost-C++, and Numpy-Python.

Environment

Parameters

  • Test case : European vanilla call option
Stock Strike Maturity Riskless

interest rate

Volatility Number

of simulations

Parameters 100.0 100.0 1.0 0.03 0.3 105, 106, 107

Result

  • In this repo, I compare the cpu time(seconds) of three version for MCS using Numpy-Python. The parameters can be modified freely.
  • version 0 : Call random number function every time
  • version 1 : Call random number function at a time such as (# of simulations × # of time steps)
  • version 2 : Vectorized path generation and call random number function at a time such as (# of simulations × # of time steps)
cpu time(sec) 105simuls 106simuls 107simuls
version 0 0.1176 1.2223 11.6426
version 1 0.1354 1.3635 13.1086
version 2 0.0059 0.0726 0.7396

** Exact value of European call option: 13.28331

Note

  • If you're interested in my works, please email me.

About

Computational cost in Monte Carlo simulation using vectorization

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages