2

I am gonna use QuantLib in C# app (http://quantlib.org/docs.shtml) but I don't trust their .NET conversion project (too immature).

I need only options valuation part.

anyone used it in managed app? whats the best approach?

Boppity Bop
  • 9,613
  • 13
  • 72
  • 151

2 Answers2

2

What I have done in a similar situation is implementing a C++ native dll as an adapter between the C# and C++ projects. From C# you can access your dll interface with DllImport. In the dll you can reach the full C++ interface, but it is worth simplifying it to your exact needs on the managed site.

Example:

// in the C++ dll:
extern "C" MY_API void SetInput(double* Values, int Count);

// in C#:
[DllImport("MyStuff.dll")]
public extern static void SetInput(double[] Values, int Count);
jmihalicza
  • 2,083
  • 12
  • 20
  • "a C++ native dll as an adapter" you mean C++/CLI project as a wrapper to the C++ native QuantLib dll... right? ... any chance to see the code ^_^ ? – Boppity Bop May 05 '13 at 00:32
  • Yes, it can be a managed C++ wrapper, but I think it complicates things. I created a plain C interface. – jmihalicza May 05 '13 at 01:39
  • You're going to have to write quite a bit of code to adapt QuantLib code to a plain C interface, though. – Luigi Ballabio May 05 '13 at 11:58
  • I needed few methods really. would take an hour top... if I could compile ql though (why don't you guys distribute built dlls?) – Boppity Bop May 06 '13 at 10:40
0

C# wrappers for the C++ library are already available and are distributed at the QuantLib download page (these are wrappers as suggested by jmihalicza, not the ongoing C# port you're referring to in your question). The distribution also contains an example of option valuation (look under the CSharp/examples folder).

Luigi Ballabio
  • 4,128
  • 21
  • 29
  • yeah. I spent 2 hrs trying to compile QL with Boost cos boost installer couldn't download few zips. even if I succeed I will need to install swig and then tinker with it for days.. I took qlnet after all.. I simply don't have that time Luigi. – Boppity Bop May 06 '13 at 10:38