C# Math Library - Matlab, R project and Python | futures.io
futures.io futures trading

Go Back   futures.io

> Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python

C# Math Library
Started:March 18th, 2010 (09:30 AM) by MXASJ Views / Replies:14,819 / 15
Last Reply:April 14th, 2015 (06:11 AM) Attachments:1

Welcome to futures.io.

Welcome, Guest!

This forum was established to help traders (especially futures traders) by openly sharing indicators, strategies, methods, trading journals and discussing the psychology of trading.

We are fundamentally different than most other trading forums:
  • We work extremely hard to keep things positive on our forums.
  • We do not tolerate rude behavior, trolling, or vendor advertising in posts.
  • We firmly believe in openness and encourage sharing. The holy grail is within you, it is not something tangible you can download.
  • We expect our members to participate and become a part of the community. Help yourself by helping others.

You'll need to register in order to view the content of the threads and start contributing to our community. It's free and simple, and we will never resell your private information.

-- Big Mike

Thread Tools Search this Thread

C# Math Library

Old March 18th, 2010, 09:30 AM   #1 (permalink)
Elite Member
Futures Experience: Beginner
Platform: NinjaTrader, TOS
Posts: 798 since Jun 2009
Thanks: 109 given, 784 received

C# Math Library

Not quite R or Matlab but...

Does anyone use any of the free or commercially available C# math libraries? On the free front DotNumerics came up in searches after hearing repeated references to LAPACK from some C++ guys.

Reply With Quote

Old March 18th, 2010, 09:30 AM   #2 (permalink)
Quick Summary
Quick Summary Post

Quick Summary is created and edited by users like you... Add FAQ's, Links and other Relevant Information by clicking the edit button in the lower right hand corner of this message.


Old March 18th, 2010, 12:28 PM   #3 (permalink)
Elite Member
Neubrandenburg, Germany
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
wh's Avatar
Posts: 539 since Jun 2009
Thanks: 297 given, 474 received

look for dnanalytics ... you can also google:

2009.8 Features
* Linear algebra classes with support for sparse matrices and vectors (with a F# friendly interface).
* Dense and sparse solvers.
* Probability distributions.
* Random number generation (including Mersenne Twister MT19937).
* QR, LU, SVD, and Cholesky decomposition classes.
* Matrix IO classes that read and write matrices form/to Matlab, Matrix Market, and delimited files.
* Complex and “special” math routines.
* Markov Chain Monte Carlo (MCMC) sampler classes.
* Bayesian estimators.
* Descriptive Statistics, Histogram, and Pearson Correlation Coefficient.
* Overload mathematical operators to simplify complex expressions.
* Visual Studio visual debuggers for matrices and vectors
* Runs under Microsoft® Windows and platforms that support Mono.
* Optional support for Intel®Math Kernel Library (Microsoft® Windows and Linux)

NET Framework Languages C#, F# and VB.NET

  • dnAnalytics is an open-source numerical library for .NET written in C# and F#.
  • DotNumerics is a Numerical Library for .NET written in C#. It provides routines for: Linear Algebra (CSLapack, CSBlas, CSEispack), Differential Equations and Optimization.
  • ILNumerics.Net typesafe numerical array classes and functions for general math and linear algebra, aims .NET/mono, script-like syntax in C#, 2D & 3D plot controls
  • Math.NET is a mathematical open source (MIT/X11, LGPL & GPL) library written in C#/.Net, aiming to provide a self contained clean framework for symbolic algebraic and numerical / scientific computations.
  • Meta.Numerics is a library for advanced scientific computations using the .NET Framework. The Meta.Numerics library is fully object-oriented and optimized for speed of implementation and execution.
  • NMath by CenterSpace Software are numerical component libraries for the .NET platform. The libraries include high performance signal processing (FFT) classes, an extensive linear algebra (LAPACK & BLAS) framework, and a statistics package including descriptive statistics, distributions, ANOVA, and multivariate analysis (NMF, k-means, PCA). Most classes scale with the number of processor cores.[1]
  • SCINET is an object-based high performance Scientific Software Framework for the Microsoft .NET platform. It is purely written in C# programming language and fully compliant with the Microsoft's CLI specification.
  • TA-Lib is widely used by trading software developers requiring to perform technical analysis of financial market data.[2]

Causality is the relationship between an event (the cause) and a second event (the effect), where the second event is a consequence of the first.
Reply With Quote
The following 4 users say Thank You to wh for this post:

Old March 18th, 2010, 12:32 PM   #4 (permalink)
Elite Member
Neubrandenburg, Germany
Futures Experience: Advanced
Platform: R
Favorite Futures: Stocks
wh's Avatar
Posts: 539 since Jun 2009
Thanks: 297 given, 474 received

i know nothing, but like as henry ford

you need to know anything, just know where it stands

Causality is the relationship between an event (the cause) and a second event (the effect), where the second event is a consequence of the first.
Reply With Quote

Old February 9th, 2011, 10:41 PM   #5 (permalink)
Elite Member
Futures Experience: Beginner
Platform: MultiCharts
Posts: 213 since Nov 2010
Thanks: 8 given, 18 received

Futures Edge on FIO

How much money do you need to trade futures successfully?

I use also open project of neural networks, they work well

Reply With Quote

Old February 10th, 2011, 08:33 AM   #6 (permalink)
Trading for Fun
Here, GA
Futures Experience: Intermediate
Platform: Ninja
Posts: 146 since Jun 2009
Thanks: 1 given, 72 received

Thanks wh. Good stuff I never knew existed. Just something else to learn.

Reply With Quote

Old March 1st, 2011, 07:18 PM   #7 (permalink)
Just starting out...
sacramento, ca
Futures Experience: Beginner
Platform: TWS
Favorite Futures: equity
Posts: 2 since Mar 2011
Thanks: 0 given, 0 received

Try using GSL in C#

If you are interested in robust implementation, I would suggest using GSL - it is one of the best open source numeric library that I know of in terms of functions and stability.
PS : it is pretty easy to use GSL dlls in C# with Pinvoke, ample tutorials in the internet

Reply With Quote

Old May 13th, 2011, 06:56 PM   #8 (permalink)
Elite Member
Seattle, WA
Futures Experience: Intermediate
Platform: NinjaTrader
Broker/Data: Interactive Brokers/IQFeed
Favorite Futures: Stocks
Posts: 27 since Nov 2009
Thanks: 10 given, 66 received

I've had very good results recently using ALGLIB (ALGLIB). I took their C# files, and merged them into a single file in its own namespace in a dummy NinjaTrader indicator file (in its own namespace so it can be called from strategies also). Easy to do (I didn't modify any alglib code) but I can post my file if anyone is interested, it's licensed under GPL.

The reason I started using it was to speed up things I had been doing in Matlab. I've gone through a lot of work to get NinjaTrader to call compiled Matlab functions, so that I could use Matlab functionality under the NinjaTrader backtesting/datafeed/execution framework. I wanted to avoid porting Matlab code to C#. It worked, but the process was painful on 2 fronts. First problem was getting a particular Matlab routine to work; every routine seems to have different calling conventions, and correctly building the data structures that the Matlab routines want is a painful process.

Even after they work, they are kind of slow for several reasons. Plenty fast for indicators, but I wanted faster for strategy development. I don't know what "compiled matlab" compiles into (I think it's some kind of intermediate code with a C++ wrapper around it and some dotnet interface dlls) but it's not as fast as native code. The Matlab language encourages inefficient programming practices, which is understandable, because their goal is efficient development of algorithms more than efficient execution. And another problem was that I could never make it run multi-threaded (I didn't try really hard but it appears that the Matlab engine isn't thread-safe), so I couldn't use the NT7 optimizer with multiple threads.

So even though it worked, I wasn't terribly satisfied, and I started thinking: I've gone to a heck of a lot of work to avoid porting Matlab code to C#, maybe it would be better to just bite the bullet and port some Matlab code to C# and see how that goes. So I did that this week. I used Alglib mainly for its least squares fit and matrix inverse and multiply routines, but it includes a lot more. I had to write a lot of simple "helper" routines to mimic some matlab functionality (matrix transpose, concatenate, etc). I already had the Matlab routines callable from C#, so it was easy to verify that my transcoded routines worked the same.

I'm quite happy with the results so far. I haven't done a lot of benchmarking but one of my backtests runs almost 3x faster, and there's a lot more going on the just the numerics, so the speedup of the numeric routines must be a lot more than that. That gain is multiplied because I can now run multiple threads in the optimizer, which I couldn't do at all before. So running strategies that use numerics under the NT7 optimizer is now practical for me, where it wasn't before, and that's a big win for me.

I didn't look at the DotNumerics package before I started. DotNumerics includes a lot of the helper routines that I had to write. But you have to work under their class structure. Alglib works with standard C# arrays (although the calling conventions are strange and have a learning curve, you have to pass the array sizes as parameters). Also, Alglib is an active project, whereas DotNumerics hadn't had an update since 2009.


Reply With Quote
The following 6 users say Thank You to kevind for this post:

Old January 8th, 2012, 04:52 PM   #9 (permalink)
Elite Member
Futures Experience: Intermediate
Platform: Ninja Trader Tradestation
Broker/Data: Zenfire
Favorite Futures: EMINI
Posts: 34 since Feb 2010
Thanks: 0 given, 3 received

Can you post your Algib file, I would be keen to learn how you did it.

Reply With Quote

Old January 9th, 2012, 04:56 AM   #10 (permalink)
Elite Member
Leesburg, VA
Futures Experience: Advanced
Platform: NinjaTrader
Posts: 78 since Aug 2010
Thanks: 74 given, 29 received

I too would be interested to learn the approach. Please post so that we can all learn something new & you would benefit from the questions or suggestions.

Reply With Quote


futures.io > Futures Trading, News, Charts and Platforms > Platforms and Indicators > Matlab, R project and Python > C# Math Library

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Upcoming Webinars and Events (4:30PM ET unless noted)

An Afternoon with FIO trader bobwest

Elite only

NinjaTrader 8: Programming Profitable Trading Edges w/Scott Hodson

Elite only

Anthony Drager: Executing on Intermarket Correlations & Order Flow, Part 2

Elite only

Adam Grimes: Five critically important keys to professional trading

Elite only

Machine Learning Concepts w/FIO member NJAMC

Elite only

MarketDelta Cloud Platform: Announcing new mobile features

Dec 1

NinjaTrader 8: Features and Enhancements

Dec 6

Similar Threads
Thread Thread Starter Forum Replies Last Post
Murrey Math Big Mike Traders Hideout 222 June 10th, 2016 05:15 AM
C# Charting Class/Library Dusty909 Platforms and Indicators 7 December 1st, 2011 06:08 PM
Technical Analysis Library with 200 indicators sigjanu Platforms and Indicators 1 March 17th, 2011 11:53 AM
C# Math.net and compiling tinkerz NinjaTrader Programming 1 April 6th, 2010 05:33 PM
School tosses out all books in library, goes high tech Big Mike Off-Topic 4 September 5th, 2009 10:24 PM

All times are GMT -4. The time now is 05:03 PM.

Copyright © 2016 by futures.io. All information is for educational use only and is not investment advice.
There is a substantial risk of loss in trading commodity futures, stocks, options and foreign exchange products. Past performance is not indicative of future results.
no new posts

Page generated 2016-10-25 in 0.13 seconds with 20 queries on phoenix via your IP