问题
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?
回答1:
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);
回答2:
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).
来源:https://stackoverflow.com/questions/16380167/whats-the-best-to-call-quantlib-methods-from-c-sharp