Precisions v. Performance of decimal
vs double
#649
Replies: 2 comments 15 replies
-
The reason I bring this up now is that the idea of using For example, the internal calculation for |
Beta Was this translation helpful? Give feedback.
-
My current view on our convention can boil down to:
|
Beta Was this translation helpful? Give feedback.
-
I was on an online forum recently and saw someone mention that the use of
decimal
data precision is bad to use for financial indicators. I'd saydecimal
precision is necessary for financial data; and yes, it's observably slower thandouble
in this kind of application.Our decision to use
decimal
(m
) is based on several key problems with using less precise data types, likedouble
(d
) andfloat
(f
):The rounding errors, especially when compounding calculations, are observable, potentially problematic, and disturbing to rational financial analysts. For example:
It's necessary for supporting cryptocurrency prices that currently allow up to 8 decimal point precision:
With that said, I'm fairly content with the current v1.9.2 library performance with a typical indicator execution time of
0.3ms
, but am always considering these tradeoffs.float
is definitely not an option; but if we were to switch todouble
, which has better precision, it would typically be0.1ms
, but then you'd have some rounding errors that could propagate poorly. My gut says it's not a good-enough tradeoff in many cases.Note
SEP 2024 UPDATE: My views on this have changed slightly now that I know more about where this does and does not have important accuracy impact. Now, our goal is to maximize use of
double
, but with some accurate money exceptions.Beta Was this translation helpful? Give feedback.
All reactions