Deze functie doet het nu in Vestics. Het stukje code om de ModelOptionPrice te bereken voor Catagory = 1 is eruit gehaald. ?Category is een 'Reserved Word' in TS om te kijken of je met een aandeel, future, optie, ...... van doen hebt.
Of het ding nu nog precies doet wat het moet doen weet ik niet

{ *******************************************************************
Description: This Function returns ImpliedVolatility
Provided By: Omega Research, Inc. (c) Copyright 1999
*********************************************************************}
Inputs: ExMonth(Numeric), ExYear(Numeric), Strike(Numeric), Rate(Numeric), OptPrice(Numeric), Type(Numeric), Asset(Numeric);
Variables: ModelOptionPrice(0), TestVolatility(0), MaxIts(0), Guess(0), ExitFlag(True);
If ExMonth > 0 AND ExMonth <13 AND Strike <> 0 AND Rate <> 0 AND OptPrice <> 0 AND Asset <> 0 Then Begin
MaxIts = 0;
ExitFlag = True;
ModelOptionPrice = 0;
TestVolatility = 0;
While ModelOptionPrice < OptPrice AND ExitFlag Begin
TestVolatility = TestVolatility + 1;
ModelOptionPrice = BlackScholes(DaysToExpiration(ExMonth, ExYear), Strike, Asset, Rate, TestVolatility, Type);
MaxIts = MaxIts + 1;
If MaxIts > 100 Then Begin
ImpliedVolatility = 0;
ExitFlag = False;
End;
End;
MaxIts = 0;
ExitFlag = True;
While ModelOptionPrice > OptPrice AND ExitFlag Begin
TestVolatility = TestVolatility - .1;
ModelOptionPrice = BlackScholes(DaysToExpiration(ExMonth, ExYear), Strike, Asset, Rate, TestVolatility, Type);
MaxIts = MaxIts + 1;
If MaxIts > 100 Then Begin
ImpliedVolatility = 0;
ExitFlag = False;
End;
End;
ImpliedVolatility = TestVolatility;
End
Else
ImpliedVolatility = 0;