by Cuchulainn » Wed Aug 19, 2009 9:29 am
Summary and Rationale
In some cases we have created a C++ program but we wish to use functionality that is not in C++ (for example, WindowsForms in C# or a payoff parser in F#) then it is possible to interface to C# and F# via a small CLI code snippet.
We use the .NET charts and Datasim Excel interface in C++.
Extended Option Example
This example shows the integration of a C++ program with a C# GUI. It asks the parameters for an option and calculates various values (e.g. Value, Gamma, Delta) and displays it in a chart. Optionally, the output is send to Excel (Excel 2007 needed).
The user interface is written as a C# library .dll. It contains a form class for the input and a form class for the result.
The C++ program refers to the C# .dll and consists mainly of native C++ with a little bit of C++/CLI to create the input and output C# form classes and to pass/retrieve the data. Because it uses C++/CLI it must be compiled as a C++/CLI project.
What?s taking place?
- The C++ program creates an instance of the C# input form class.
- It sets the starting option values in the form and displays the form. The form checks the input.
- When the form is closed, the C++ program reads the option parameters from the form and put them in the option object.
- The option object is calculated for various value types (value, gamma, delta) (all native C++)
- The C++ program creates an instance of the C# results form class.
- The result of the calculation is converted to a .NET array and passed to the results form.
- The results form is shown.
Remark: In the output, one value in the Gamma is INF; Excel displays it but Chart sees this and ignores it.
Edited 20 August 2009: New version of the "Exented Option Example". Outputs the numerical data also in a grid.
- Attachments
-
ExtendedOptionSetup.zip
- The "Extended Option Example" setup file.
- (2.3 MiB) Downloaded 825 times