This is the only test case that is getting failed and it’s failing only because of the precision. The expected ans is the above value with more decimal digits and my answer is the below one. What to do?

try reformulating your year calculation formula

read this thread for more info

Check the year calculation and total return formula.

The annualized return that you see is the same one that is expected by the test case still it’s getting failed because of i think it’s precision.

the buying price is the closing price at the purchase date right?

There might be issues with data type of the variable in which you store the data. Think which data type is suitable for this kind of result.

Open price on purchase date

I am storing it in double which is the expected data type and all other test cases are working fine except this one.

It was a logical mistake. Sorry for trouble and thankyou for replying !

There might be the issue with the way you are calculating years. Checkout various ways by which you can calculate no. of days, months and years between a given time period, checkout the values and data type which they return. You will surely get the solution.

I also faced this issue and it took some time to get through it .

Yeah i did some mistake in my logic. And my logic is still not correct because i failed 2 unit tests. Although got a build success !