Whats the best to call QuantLib methods from C#

一笑奈何 提交于 2019-12-06 10:21:55

问题


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

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!