當前位置:股票大全官網 - 股票行情 - 請教關於R語言計算隱含波動率的方法

請教關於R語言計算隱含波動率的方法

FMStable這個包裏有

或者

Function ImpliedCallVolatility(UnderlyingPrice, ExercisePrice, Time, Interest, Target, Dividend)

High = 5

Low = 0

Do While (High - Low) > 0.0001

If CallOption(UnderlyingPrice, ExercisePrice, Time, Interest, (High + Low) / 2, Dividend) > Target Then

High = (High + Low) / 2

Else: Low = (High + Low) / 2

End If

Loop

ImpliedCallVolatility = (High + Low) / 2

End Function

Function ImpliedPutVolatility(UnderlyingPrice, ExercisePrice, Time, Interest, Target, Dividend)

High = 5

Low = 0

Do While (High - Low) > 0.0001

If PutOption(UnderlyingPrice, ExercisePrice, Time, Interest, (High + Low) / 2, Dividend) > Target Then

High = (High + Low) / 2

Else: Low = (High + Low) / 2

End If

Loop

ImpliedPutVolatility = (High + Low) / 2

End Function