Run Code
|
API
|
Code Wall
|
Misc
|
Feedback
|
Login
|
Theme
|
Privacy
|
Patreon
Call option formula for Laplace distributed outcomes
Language:
Ada
Assembly
Bash
C#
C++ (gcc)
C++ (clang)
C++ (vc++)
C (gcc)
C (clang)
C (vc)
Client Side
Clojure
Common Lisp
D
Elixir
Erlang
F#
Fortran
Go
Haskell
Java
Javascript
Kotlin
Lua
MySql
Node.js
Ocaml
Octave
Objective-C
Oracle
Pascal
Perl
Php
PostgreSQL
Prolog
Python
Python 3
R
Rust
Ruby
Scala
Scheme
Sql Server
Swift
Tcl
Visual Basic
Layout:
Vertical
Horizontal
# Call option formula for Laplace distributed outcomes call <- function(r,S0,vol,K) { b<-vol/sqrt(2) d<-(log(S0/K)+r+log(1-b^2))/b if (d>0) { return(S0-K*exp(-r)+(b/(2*(1+b)))*K*exp(-r-d)) } else { return((b/(2*(1-b)))*K*exp(-r+d)) } } range<-0.5+1.5*ppoints(100) range2<-ppoints(10)/4 x<-c() for (vol in range2) { y<-c() for (k in range) { y<-c(y,call(0,1,vol,k))} x<-rbind(x,y) } matplot(range,t(x),type='l',xlab='Strikes',main='Call option prices for Laplace distributed outcomes')
[
+
]
Show input
Absolute running time: 0.8 sec, cpu time: 0.94 sec, memory peak: 32 Mb, absolute service time: 0,83 sec
edit mode
|
history
|
discussion