Hi;
The RSI is a number from 0…100 and it's not a price, it's an indicator. So why does it return a decimal in .Net instead of a double or float?
thanks - dave
QUANTCONNECT COMMUNITY
Hi;
The RSI is a number from 0…100 and it's not a price, it's an indicator. So why does it return a decimal in .Net instead of a double or float?
thanks - dave
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
Fred Painchaud
Hi David,
Why not?
Considering the number of operations done on RSI over time, making the value more robust to rounding errors make sense to me.
Fred
David Thielen
Hi Fred;
I think you're confusing precision and representation error (see answer here). Decimal is expressly designed for money where first of all the numbers must add up and second, fractions are decimal. So price info, or anything that is part of a calculation to determine a price, should be decimal. This includes an indicator like moving average because it is calculated as an average price.
But RSI is not a price. It is a value from 0 .. 100 that is a measure of the strength of a stock. For a value like this double does a better job of providing a value that minimizes precision and representation errors. Because the values are not decimal, they're all over the place.
One easy way to split out when to use each I think is, will that number ever be used in a calculation to determine a price value.
And with that said, making everything decimal in QC is not a bad decision. It's sub optimal, but it's a small level of error generally on measures used to make decisions where a difference of 0.0001 should not be significant.
David Thielen
Hi Fred;
Another way of putting it is decimal is built to insure that totals balance. For example, if my paycheck is $12,345,67½ the purpose of decimal is to make sure what I am paid matches what is deducted from the balance in the bank account. Decimal doesn't care if it's $12,345,67 or $12,345.68. It cares greatly that it is the same amount in all activity.
Double of the other hand spreads it's imprecision evenly. It would be fine paying me $12,345.67 and deducting $12,345.68 from the bank account. What's important in double is that imprecision does not have certain values (0.1) that it gravitates toward.
note: It's easy with either system to calculate the rounded number for salary and apply it to both my paycheck and the bank withdrawal. I used calculating it distinctly just as a simple example.
thanks - dave
Fred Painchaud
Hi Dave,
It's totally sane that we do not agree. While Decimal is slower and takes more memory than double, RSI calculates a % from price gains/losses, in a rolling/incremental/iterative (call it what you will 😊) fashion. I did not take part of the decision to use Decimal there but I would most likely make the same decision.
My personal criterion to select Decimal is when I need exact floating point representation in base 10 (hence the name Decimal).
Fred
David Thielen
The material on this website is provided for informational purposes only and does not constitute an offer to sell, a solicitation to buy, or a recommendation or endorsement for any security or strategy, nor does it constitute an offer to provide investment advisory services by QuantConnect. In addition, the material offers no opinion with respect to the suitability of any security or specific investment. QuantConnect makes no guarantees as to the accuracy or completeness of the views expressed in the website. The views are subject to change, and may have become unreliable for various reasons, including changes in market conditions or economic circumstances. All investments involve risk, including loss of principal. You should consult with an investment professional before making any investment decisions.
To unlock posting to the community forums please complete at least 30% of Boot Camp.
You can continue your Boot Camp training progress from the terminal. We hope to see you in the community soon!