Black & Scoles - Juiste formule

Vragen en suggesties over Vesticode

Moderator: Perry

Black & Scoles - Juiste formule

Berichtdoor Mrb » wo 15 sep 2004, 21:10

Ik wil in een koersvenster een kolom weergeven met de optieprijs vlgs Black & Scoles.

Uit een eerder posting heb ik deze formule.

BlackScholes(Next3rdFriday,xStrike,Close,3,40,1)

Ik krijg hier echter altijd een syntaxfout dat hij een naam van een variable verwacht.

Wat is hier nog fout?
Mrb
 
Berichten: 1
Geregistreerd op: wo 15 sep 2004, 21:06

Black & Scoles

Berichtdoor GMe » do 16 sep 2004, 11:58

{*******************************************************************
Description: This Indicator plots Black Scholes
Provided By: Omega Research, Inc. (c) Copyright 1999
********************************************************************}

Inputs: Type(0), ExpMonth(0), ExpYear(0), Strike(0), IntRate(0), Vola(0);
?
If ExpMonth > 0 AND ExpMonth < 13 AND Strike > 0 AND IntRate >= 0 AND Vola >= 0 Then
Plot1(BlackScholes(DaysToExpiration(ExpMonth, ExpYear), Strike, Close of Data1, IntRate, Vola, Type), "BlackScholes" )
Else
Plot1(0, "BlackScholes");
GMe
 
Berichten: 145
Geregistreerd op: zo 07 okt 2001, 16:16

Black & Scoles

Berichtdoor GMe » do 16 sep 2004, 11:59

{***********************************************************************
Description:This Function returns Black option valuation model
Provided By: Omega Research, Inc. (c) Copyright 1999
************************************************************************}

Inputs: DaysLeft(Numeric), Strike(Numeric), AssetPrice(Numeric), InterestRate(Numeric), Volty(Numeric), OptionType(Numeric);
Variables: Answer(0), D1(0), D2(0), Nd1(0), ND2(0), e(2.71828183), ERT(0), NprimeX(0), pi(3.14159), Price(0), StrikePrice(0), r(0), Vty(0), TInDays(0), TAnnual(0), SQRootTime(0), skip(0), OT(0);

StrikePrice = Strike;
Price = AssetPrice;
Vty = volty * .01;

If OptionType = 1 OR OptionType = Call Then
OT = Call;
If OptionType = 0 OR OptionType = Put Then
OT = Put;

If Price > 0 Then Begin
If StrikePrice > 0 Then Begin
If Vty > 0 Then Begin

TInDays = DaysLeft;

If TInDays > 0 Then Begin
TAnnual = TInDays * 0.002739;
? ? SQRootTime = SquareRoot(TAnnual);

If InterestRate > 0 Then Begin
?r = InterestRate * .01;
skip = 1;
D1 = (Log(Price / StrikePrice) + ((r + ((Vty * Vty) * .5)) * TAnnual)) / (Vty * SQRootTime);
NprimeX = (1 / SquareRoot(2 * pi)) * Power(e, -(D1 * D1) * .5);
ERT = Power(e, -1 * r * TAnnual);

If OT = Put Then Begin
?Nd1 = NormalSCDensity(-D1);
?D2 = (Vty * SQRootTime) - D1;
ND2 = NormalSCDensity(D2); ? ?
Answer = (-Price * Nd1) + StrikePrice * ERT * ND2;
If Answer > StrikePrice Then
Answer = StrikePrice;
If Answer < StrikePrice - Price Then
Answer = StrikePrice - Price;
? BlackScholes = Answer;
End
Else
If OT = Call Then Begin
Nd1 = NormalSCdensity(D1);
D2 = D1 - (Vty * SQRootTime);
ND2 = NormalSCDensity(D2); ?
Answer = Price * Nd1 - StrikePrice * ERT * ND2;
If Answer < Price - StrikePrice Then
Answer = Price - StrikePrice;
BlackScholes = Answer;
End;
End;
End;
End;
End;
End;

If skip = 0 Then Begin
Answer = 0;
If OT = Put Then Begin
If 0 < StrikePrice - Price Then
Answer = StrikePrice - Price;
BlackScholes = Answer;
End
Else
If OT = Call Then Begin
If 0 < Price - StrikePrice Then
Answer = Price - StrikePrice;
BlackScholes = Answer;
End;
End;
GMe
 
Berichten: 145
Geregistreerd op: zo 07 okt 2001, 16:16


Keer terug naar Vesticode

Wie is er online

Gebruikers op dit forum: Geen geregistreerde gebruikers en 6 gasten

cron