Jace4fc 1.0.1

Install-Package Jace4fc -Version 1.0.1
dotnet add package Jace4fc --version 1.0.1
<PackageReference Include="Jace4fc" Version="1.0.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add Jace4fc --version 1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Jace4fc, 1.0.1"
#r directive can be used in F# Interactive, C# scripting and .NET Interactive. Copy this into the interactive tool or source code of the script to reference the package.
// Install Jace4fc as a Cake Addin
#addin nuget:?package=Jace4fc&version=1.0.1

// Install Jace4fc as a Cake Tool
#tool nuget:?package=Jace4fc&version=1.0.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

Jace4fc

Jace4fc is hard-fork of Jace.NET. Jace is a high performance calculation engine for the .NET platform.

It stands for "Just Another Calculation Engine For Financial Calculations"

What does it do?

Jace4fc can interprete and execute strings containing mathematical formulas. These formulas can rely on variables. If variables are used, values can be provided for these variables at execution time of the mathematical formula.

Jace can execute formulas in two modes: in interpreted mode and in a dynamic compilation mode. If dynamic compilation mode is used, Jace will create a dynamic method at runtime and will generate the necessary MSIL opcodes for native execution of the formula. If a formula is re-executed with other variables, Jace will take the dynamically generated method from its cache. It is recommended to use Jace in dynamic compilation mode.

Examples

Jace4fc can be used in a couple of ways:

To directly execute a given mathematical formula using the provided variables:

Dictionary<string, decimal> variables = new Dictionary<string, decimal>();
variables.Add("var1", 2.5m);
variables.Add("var2", 3.4m);

var engine = CalculationEngine.New<decimal>();
double result = engine.Calculate("var1*var2", variables);

To build a .NET Func accepting a dictionary as input containing the values for each variable:

var engine = CalculationEngine.New<double>()
Func<Dictionary<string, double>, double> formula = engine.Build("var1+2/(3*otherVariable)");

Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2);
variables.Add("otherVariable", 4.2);
	
double result = formula(variables);

To build a typed .NET Func:

var engine = CalculationEngine.New<double>()
Func<int, double, double> formula = (Func<int, double, double>)engine.Formula("var1+2/(3*otherVariable)")
	.Parameter("var1", DataType.Integer)
    .Parameter("otherVariable", DataType.FloatingPoint)
    .Result(DataType.FloatingPoint)
    .Build();
	
double result = formula(2, 4.2);

Functions can be used inside the mathemical formulas. Jace.NET currently offers four functions accepting one argument (sin, cos, loge and log10) and one function accepting two arguments (logn).

Dictionary<string, double> variables = new Dictionary<string, double>();
variables.Add("var1", 2.5);
variables.Add("var2", 3.4);

var engine = CalculationEngine.New<double>()
double result = engine.Calculate("logn(var1,var2)+4", variables);

More Information

For more information, you can read the following articles:

Disclaimer:

This is my fork of Jace. It is basically the same as the original project but here we have decimal support and I've applied some bug fixes there are not in jace's main branch.

Original Project: Jace

  • .NETStandard 1.6

    • No dependencies.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last updated
1.0.1 114 8/26/2021
1.0.0 79 8/22/2021