TA-Lib.NETCore icon indicating copy to clipboard operation
TA-Lib.NETCore copied to clipboard

decimal vs double

Open pomeara opened this issue 3 years ago • 2 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

pomeara avatar Jul 20 '21 05:07 pomeara

decimal is too expensive. Backtesting does not need such precision. In most cases, float is sufficient.

VassilSanych avatar Feb 23 '22 17:02 VassilSanych

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)

JustNrik avatar Jan 10 '24 22:01 JustNrik

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.

hmG3 avatar May 15 '24 19:05 hmG3

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.

VassilSanych avatar May 17 '24 10:05 VassilSanych