【ImpliedVolatility】
[code]inputs:ExpMonth( numericsimple ),
ExpYear( numericsimple ),
StrikePr( numericsimple ),
Rate100( numericsimple ),
MktVal( numericsimple ),
PutCall( numericsimple ),
AssetPr( numericsimple ) ;
variables:
var0( 0 ),
var1( 0 ),
var2( 0 ),
var3( 0 ),
var4( 0 ) ;
var0 = DaysToExpiration( ExpMonth, ExpYear ) ;
condition1 = var0 > 0 and StrikePr > 0 and AssetPr > 0 ;
if condition1 then
begin
var1 = 100 ;
var2 = BlackScholes( var0, StrikePr, AssetPr, Rate100, var1,
PutCall ) ;
while var2 < MktVal and var1 <= 900
begin
var1 = var1 + 100 ;
var2 = BlackScholes( var0, StrikePr, AssetPr, Rate100, var1,
PutCall ) ;
end ;
if var2 < MktVal then
ImpliedVolatility = 999
else
begin
var3 = 1 ;
var4 = 100 ;
while AbsValue( var2 - MktVal ) >= .005 and var3 < 11
begin
var4 = var4 * .5 ;
if var2 > MktVal then
var1 = var1 - var4
else if var2 < MktVal then
var1 = var1 + var4 ;
var2 = BlackScholes( var0, StrikePr, AssetPr, Rate100, var1,
PutCall ) ;
var3 = var3 + 1 ;
end ;
ImpliedVolatility = var1 ;
end ;
end
else
ImpliedVolatility = 0 ;
[/code]
页:
[1]