C# Libraries for Quantitative Finance, Optimization, and Visualization
Summary
The document surveys C# and .NET tools for building a LIBOR Market Model workflow involving statistical estimation, numerical methods, calibration, Monte Carlo, pricing, risk management, and Excel access. It names libraries for numerical computation, statistics, optimization, charting, and R interoperability, including Math.NET, Meta.Numerics, Accord.NET, OxyPlot, and R.NET. It also discusses using Excel charts and the Excel Solver, and mentions alternatives such as Microsoft Solver Foundation and finance-oriented frameworks.
The recommendations reflect the software landscape and licensing concerns described by the contributors, rather than a benchmark or systematic package review. The original question seeks documented tools, derivative-free optimization, visualization, and options suitable for public or noncommercial distribution. The answers offer candidates but do not verify current maintenance, compatibility, or license terms. One contributor argues that native compiled libraries may offer performance and maturity advantages, while the accepted response favors the convenience of .NET integration; this is a tradeoff to assess for a particular implementation.
Key ideas
- The proposed pricing and risk workflow needs statistics, matrix methods, optimization, Monte Carlo, and visualization.
- Math.NET and Meta.Numerics are listed as numerical and statistical .NET options.
- Accord.NET, Excel Solver, and Solver Foundation are suggested for optimization tasks.
- OxyPlot, Excel charts, and ILNumerics are mentioned for visualization.
- Library capabilities, performance, maintenance, and licensing should be checked for the intended deployment.
Tags
Full text
# Free and tested optimization, statistical and visualization packages for C# # Free and tested optimization, statistical and visualization packages for C# I am about to implement a variation of the LIBOR-Market-Model (complete with Least-Square-Montecarlo, calibration, pricing etc.) and decided to implement it in C#. The implementation will involve working with statistical data, numerical optimisation and monte carlo. Being fluent in R, C++, C# and Mathematica I usually distribute the workload among the platforms according to their strengths. Thus: Mathematica for optimization, R for statisical analysis and C#/C++ for brutforce montecarlo etc. Last week I was given the task to create a distributable pricing-/risk-management-environment for the Libor-Market-Model that can be accessed via MS-Excel. I opted for C# because it is very easy to interface with Excel via Excel-DNA (I did the interface with C++ once but it is no where as convenient as C#) Thus I am looking for well documented solutions for: - statistics (for the estimation of a convariance matrix) - perhaps linking to R ? - numerics (rank reduction, matrix decomposition) - ALGLIB - is there an alternative ? - optimization ( for calibration - above all I need non-gradient methods) - visualisation (people from risk management usually like pretty graphs :) - C# has a charting environment. I have never used it before and do not know whether it is any good. Also note: I am allowed to make a somewhat altered version of the code avaliable to the public. Thus it would be nice for the packages/add-ins to be avaliable for free for non commercial usage. ## Answer by Govert (score 12, accepted) https://quant.stackexchange.com/a/10435 A popular open-source option for the numerics in .NET is Math.NET (https://github.com/mathnet/mathnet-numerics). It has both managed implementations and allows you to use the optimized MKL native libraries. This use of .NET as a front-end to an optimized native library is quite common. Meta.Numerics (http://www.meta-numerics.net) is an alternative open-source library which is quite strong on various statistical distributions. ILNumerics (http://ilnumerics.net/) is free or paid for, and gives a highly optimized managed numerics library - with performance that is comparable with C or Fortran, though not as fast as MKL. It also has rich visualization tools. Extreme Optimization (http://www.extremeoptimization.com/) is a rich commercial library. For linking to R, you'd use R.NET (https://rdotnet.codeplex.com/). For charting (WinForms or WPF), OxyPlot (https://oxyplot.codeplex.com/) is a great open-source project. If you already use Excel as your substrate, you might rather use Excel's charting - you'll probably have a more coherent solution. For optimization (and stuff like machine learning) you might consider Accord.NET (http://accord-framework.net/) (LGPL license). However, the built-in GRG solver in Excel is excellent if your problem fits. Constrained, non-linear, derivative-free optimization codes (some merged into Accord.NET) are discussed here: http://cureos.blogspot.com/2012/05/derivative-free-nonlinear-optimization.html . Another optimization library is from Microsoft - the Microsoft Solver Foundation 3.1 now has a Nelder-Mead solver for nonlinear programming problems. While there is a matching Excel add-in for driving the Solver Foundation, you might also integrate it as worksheet functions using Excel-DNA. The licensing is a bit confusing though, and I'm not sure it's being actively developed any more. As a final link, I'll add Dodoni.net (https://dodoni.codeplex.com/): "Dodoni.net is a free/open-source library with the aim to provide a framework for quantitative finance (pricing and risk management) as well as for general numerical methods (i.e. numerical integration, FFT, optimization etc.). The main idea is to construct a flexible and easy to use toolbox which is easy extendable by 3th party libraries." It includes native back-end bindings, and integration into Excel via Excel-DNA. ## Answer by Aksakal almost surely binary (score 1) https://quant.stackexchange.com/a/10431 the usual suspects have .NET/C# bindings or implementations: IMSL, NAG Another interesting alternative is the developers of Excel Solver add-in. They have an advanced package way beyond Excel's add-in. Do I recommend it? Of course, not, but it's an option nevertheless. I would forget C#, and use a proper binary libraray, tried and tested, anything from BLAS to GSL. In the end you're using Excel, it's a binary code, so there's no point in using VM-based solutions. UPDATE: The reasons why I recommend binary library: - it's always better to use the library which is popular, because that way it has a lesser chance of containing an error. imagine the matrix inversion code written in Fortran, which was in use since '60s. what is a chance of a serious error in it? everyone knows how they behave. so you take the binary code of this library, and pretty much guarantee that it has no bugs. who writes numerical code in C#?! very few people. basically, nobody. what's the point? it'll work only on Windows, and scientists use all sorts of hardware, most of it on Unix flavors. - if you were writing pure .NET app, then it makes a sense to at least consider a library written in C#, because that would be native to its host platform. you're developing Excel app, which is a binary application. connecting to VM-executed code brings no advantages, and potentially introduces problems, e.g. with performance
Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)
This summary was written by Stratmill's research agent from the original; it is not a copy of the source.