« Google Group for ExcelDna | Main | ExcelDna version 0.14 »

Comments

H

I am using the latest ExcelDNA version 0.11 and I am noticing in C# that the order of the arguments makes a difference.

The following two functions do exactly the same thing. In the second function i have moved the string argument to the end. The first function causes ExcelDNA to crash, whereas the second function works fine.

Is this a bug or does the order of the arguments really matter? i.e can't start with a string as a declaration argument.


public static double GBlackScholes1(string CallPutFlag, double S, double X, double T, double r, double b, double v)
{

double d1;
double d2;

d1 = (Math.Log(S / X) + (b + v * v / 2) * T) / (v * Math.Sqrt(T));
d2 = d1 - v * Math.Sqrt(T);

if (CallPutFlag == "C")
{

return S * Math.Exp((b - r) * T) * N_Csharp(d1) - X * Math.Exp(-r * T) * N_Csharp(d2);
}
else if (CallPutFlag == "P")
{

return X * Math.Exp(-r * T) * N_Csharp(-d2) - S * Math.Exp((b - r) * T) * N_Csharp(-d1);
}

return 0;


} //end of GBlackScholes1

public static double GBlackScholes2(double S, double X, double T, double r, double b, double v,string CallPutFlag)
{

double d1;
double d2;

d1 = (Math.Log(S / X) + (b + v * v / 2) * T) / (v * Math.Sqrt(T));
d2 = d1 - v * Math.Sqrt(T);

if (CallPutFlag == "C")
{

return S * Math.Exp((b - r) * T) * N_Csharp(d1) - X * Math.Exp(-r * T) * N_Csharp(d2);
}
else if (CallPutFlag == "P")
{

return X * Math.Exp(-r * T) * N_Csharp(-d2) - S * Math.Exp((b - r) * T) * N_Csharp(-d1);
}

return 0;


} //end of GBlackScholes2


public static double N_Csharp(double z) //Cumulative Density
{
if (z > 6.0) { return 1.0; } //to prevent overflow
if (z = 0.0)
{
return 1.0 - n1_Csharp(z) * (a1 * k + (a2 * k * k) + (a3 * k * k * k));
}
else
{
return 1.0 - N_Csharp(-z);
}

} // end of N_Csharp(z)


Juan

Hi,
I have a problem, I donĀ“t know to use this product when i use functions which return arrays.
For example :
public static double[] SortVector(double[] vector)
{
Array.Sort(vector);
return vector;
}
Can somebody tell me how i have to mark the cells in the excel sheet.

S

Hi!
could you please give an update on the development status? In particular, what is the progress with reusing in Excel C#/VB objects defined in .net?
tnx

Registry Remedies

Any updates?

govert

Version 0.11 is still the latest version. The Google group (http://groups.google.com/group/exceldna) is now the best place to keep track of the project. Anything in particular you'd like?

Ahmad Moghadasi

Hi
I wrote a method that return Unicode String and its not work correctly.
It is return question mark (????? ??? ???? ).
How can I solve this problem?
This function is work correctly in other application.
Thanks

The comments to this entry are closed.