Edge test case and old trades test cases are failing

#whether i sort or not , both test cases are failing .
how can i debug for these ?

Check your app in local build using command

./gradlew build

check whether all the test cases are passing or not.

1 Like

Hi @ravi,

are you checking for cases like when the end date is before the purchase date, end date argument not provided etc?

1 Like

Have you checked the app for all possible corner cases? Like possibly when the dates don’t line up?

1 Like

Use total no. Of days/ 365 to calculate number of years in Double data type. It will help you.

1 Like

Yup, all were passing

1 Like

Are you throwing valid exception and are you providing required output for some special cases such as when end date < start date or there is no data available for end date?

1 Like

@nabhanpv , 1. if end date is before the puchase date , raise exception
2. end date argument is not provided ,use current date .
right ?

i directly did 365/no of days .i guess its not the problem

Hey I got your error. If you are using 365/no. Of days it will restrict your precision value. If both are interger or long. If you are doing double/floating point calculation to achieve precision one must be in double/floating point. E.g.
If you do 365/64 it will give you 5.0 but is it really what we need, No.

Google your query how to do floating point arithmetic in java.

If you already did this reply will find help you to find other possibilities.

You’re right in this.

Mark as solution broo


  1. I am throwing runtime exception when end <start
    2.passing current day when no day end day is provided
  2. changed 365 and no_of_days both into double ,in order to maintain precision .
  3. also taking close price of last available end date in api call .
    #still old trades is failing .
    @Crio-Admin @Sakshat-Crio.Do @Saurabh_Crio_TA can u suggest something?


  • Firstly make sure you’ve not hard coded anything.
  • Secondly, when you make a call to tiingo api and there is no response of end date. Then are you calculating close value of the latest date ?

when there is no response of end date , I am taking the enddate as we did in module 2
n not hardcoding anything

@Sakshat-Crio.Do can u look into my code ? :upside_down_face:

I’m looking into it. Just give me some time :slight_smile:

Hey, when end date is not there in the response are you sure that you are taking the latest date closing price. I don’t think so.

Do verify your calculation logic also.

Good Luck :slight_smile:

result from the api call ,i deserialized and collected into the collection list
and i am passing enddate into calculateAnnualizedReturns as getdate of last element of collection…which is lastest date .right ?

Did you verify your calculation logic?