# want to get the trend in 20 10 5 day historical volatility using Logs but getting negative number

Ok so I am not a math whizz so need some SERIOUS help here. I have historical volatilities:

20 day historical volatility = 49.07% 10 day historical volatility = 47.43% 5 day historical volatility = 41.77%

My goal is to show the relative change between the following:

the change between the 20 day HV and the 10 day hv = diff2010

the change between the 10 day HV and the 5 day hv = diff105

the overall change of 20 10 5 day = diffabs

I got helpful advice that I should use the log function to get the difference in a mathematically accurate manner using the equation below

log_diff2010 = math.log(10 day hv ) - math.log(20 day hv )

log_diff105 = math.log(5 day hv) - math.log(10 day hv )

log_diffabs = math.log(log_diff105) - math.log(log_diff2010)

BUT the log_diffabs results in a -ve log num which causes an error. SO I have two questions:

1 are my calculations for log_diff2010 and log_diff105 correct?

2 how can I find the overall change for the period 20 10 5 day

here is the python 3.5 run where it all goes wrong for me :-(

import math

math.log(47.43)

 3.85925493988949


log_diff2010 = math.log(47.43) - math.log(49.07)

log_diff105 = math.log(41.77) - math.log(47.43)

log_diffabs = math.log(log_diff105) - math.log(log_diff2010)

Traceback (most recent call last):
File "<pyshell#6>", line 1, in <module>
log_diffabs = math.log(log_diff105) - math.log(log_diff2010)

ValueError: math domain error

>>> log_diff105

-0.12707656138040635

>>> log_diff2010

-0.03399291021232198
>>> r2010 = round(log_diff2010,4)

>>> r105 = round(log_diff105,4)

>>> r2010

-0.034

>>> r105

-0.1271

>>> rrabs = math.log(r105) - math.log(r2010)

Traceback (most recent call last):

File "<pyshell#14>", line 1, in <module>

rrabs = math.log(r105) - math.log(r2010)

ValueError: math domain error

>>>

• Hmmm, it wasn't exactly helpful advice. If the volatilitys are given as percentages, you would take log(1+vol). If there are given as changes in log price, you can just add and subtract.
– user59
Oct 22, 2016 at 17:31
• Hi @barrycarter thanks fot taking an interest in this. Yep the volatilities are given as a percentage ( sorry for not making that clear). how would you achieve the comparisons using my example please? Oct 22, 2016 at 20:34

import math