In a message of Thu, 01 Oct 2015 10:48:57 +0300, Michel Guirguis writes:
>Good morning,
>
>I have a problem with the cumulative distribution function in calculating 
>derivatives. I am getting a call option figure of 2.5961 while it should be 
>2.9081. Could you please help.
>
> >>>S=50
>>>> K=50
>>>> r=0.03
>>>> q=0.02
>>>> sig=0.20
>>>> T=0.5
>
>>>> from math import*
>>>> d1=(log(S/K)+(r-q+(sig*sig)*0.5)*T)/(sig*sqrt(T))
>>>> d1
>0.10606601717798211
>>>> d2 =d1-sig*sqrt(T)
>>>> d2
>-0.03535533905932742
>>>>  def cumdist():
>call = 50*exp(-0.02*0.5)*cumdist*(d1)-50*exp(-0.03*0.5)*cumdist*(d2)
>
>       
>>>> call
>2.596102990952506
>
>Thanks,
>
>Michel

I do not know if this is your problem, but you can get significant errors
if you try to use binary floating point to represent money.  You
should use decimal floating point instead.
see: https://docs.python.org/3.4/library/decimal.html

Laura
_______________________________________________
Tutor maillist  -  Tutor@python.org
To unsubscribe or change subscription options:
https://mail.python.org/mailman/listinfo/tutor

Reply via email to