decimal vs double
pomeara opened this issue · comments
This library is using doubles vs decimals and in crypto markets there are markets which have a large number of decimal places and using doubles vs decimals can produce incorrect results.
The official TALib uses C++ bindings which in turn decimals vs doubles
https://stackoverflow.com/questions/54725239/financial-calculations-double-or-decimal
decimal is too expensive. Backtesting does not need such precision.
In most cases, float is sufficient.
decimal is too expensive. Backtesting does not need such precision. In most cases, float is sufficient.
Also, it's not like this lib is optimized anyways, it doesn't take advantage of Span<T>
or runtime intrinsics, also float is not enough, it must be double at least. Float only handles 7-8 digits (keep in mind float doesn't work just with decimals, every digit counts towards the "precision", so it won't work for cryptos, and won't work for certain currencies like EURJPY if you are working with 3-5 decimal precision)
The support for Span<T>
is underway and planned to be included in the upcoming release. Also, the library is shifting towards leveraging C# Generic Math which will reduce the amount of boilerplate code to support.
Float only handles 7-8 digits (keep in mind float doesn't work just with decimals, every digit counts towards the "precision", so it won't work for cryptos, and won't work for certain currencies like EURJPY if you are working with 3-5 decimal precision)
Most exchanges have a fixed precision of 5 digits. Ok, somewhere you can have a precision of 6 digits.
But there is no logical reason for this. You shouldn't really care about cents in price when trading for thousands. And your parametric optimization algorithm itself will discard the excess accuracy. But you will need much more resources.