Question

I'm modeling some financial products and each product has his own pricing formula. In the application I would like to allow the end-user create his own product with the formula. And this formula can be used by my application to price the product.

Something like :

Formula as string = "f(x) = x * 2"
Dim Result as double = call(Formula, 1)

I know this is possible in Matlab :

f="@(x)(x*2)"; 
Result = feval(f,1);

I wrote a class in Matlab that implements this feature and integrated it in VB.Net project, but every function takes 4700 times the execution of the same function directly written in VB.Net which is not affordable regarding the business need.

Is that possible in .Net ?

Was it helpful?

Solution

You can look into MEF, so your end users would provide DLL modules in a certain format (see the link I mentioned), which would later be discovered in your program and executed at any given time.

Or use a math parser:

But I feel that approach #1 would be more flexible.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top