All test cases except mainCalculateReturnsOldTrades test case are passing

I have done the following things:

  • throw error if end date is before start date
  • do not pass end date, if it is not provided in the arguments, to the API and use the latest date as the end date.
  • sort the annualizedReturns in decreasing order.
  • buy price is the open price on the purchaseDate and sell price is the close price on the endDate.

Still the mainCalculateReturnsOldTrades test case in assessment is failing. It would be helpful if someone can point out where I might have made the mistake. Or otherwise I will just have to rewrite it again.

Suppose google have a started in 2004 but i am passing 1980 as a starting date do your code handle that situation think about that.

I throw an Exception. Do I have to do something else?

Yes you have to use the api to get the startdate of an organization and then use it.

1 Like

I fixed this and once again the same result came. All test cases passed except mainCalculateReturnsOldTrades.

Hold on I didn’t check if the endDate is later than the new startDate.

1 Like

Check for all the cases you will definitely be closure to the solution

Finally all the test cases passed. Thanks to Aman (Crio dev) who found the issue. In the compareTo function I was taking only 3 digits after the decimal and comparing them as integers. Using fixed the issue.

1 Like