# In module 3..1 test case is failing out of 19 test cases! Help

In module 3…1 test case is failing out of 19 test cases! Help.

@vipulkrishna, may I know how you are calculating the annualized returns? I mean what formula are you using.

• I am using period
• calculating diff of years, months, days
• converting them into float and
• converting all of them in year individually
• adding all of them in float var.
I am passing all cases from workspace but not in assessment.

Use this formula mentioned in the link might be a chances of conversion

If this works fine then what this test case checks is. It will call or API between two old dates suppose endDate : 2016-12-12 and startDate : 2015-01-12 and calculate annualized return for these dates.

Go through these 2 links, you’ll get an idea on what has to be done.

and as suggested in the link provided by @akashchhetri ,use those formulas accordingly.

1 Like

try using the formula including days instead of years

go through this post and see if any of these helps u

bro it solved yesterday only, thanks

lol i was refering that post to ur post

ohhh sorry

@amanagar

I do not think that my calculation is wrong for 0 years but thing that I know is I am not able hadle this test case:
If the closing price of a stock is not available for the given end date, use the latest available data prior to the closing date.

How to check that getClose() vaule is null in any case?
I do not think that getClose() value will be null in any case I mean API will return result
of that date included before
or only before if data is not available on that date.
Am I right?

Hey @vipulkrishna as you thinking that getClose() cannot be null in any case so technically that is correct but there is only one scenario in which you cannot get getClose() that is when startDate > endDate but i don’t think that is the problem here if you are getting failure in mainCalculatereturnoldTrades() then there can be two reasons probably

1. you are not sorting your list of Annualizedreturn objects according to annualizedreturn.
2. if endDate is not provided then you have to use latest_date or current_date as your endDate.

Thanks