Test Case mainCalculateReturnOldTrades logic not understanding

When a user enters an end date older than purchase date, the tiingo api resonse is empty. In that case what should we consider as ending date? I am not getting this even after thinking a lot. @AmoghaKS @Kiran @shoryajain @akashchhetri Can you guys help a bit?

No test cases deals with that, and also think logically it doesn’t make sense right? You don’t have to deal with any such case, so chill :slight_smile:

@jyotirmoy-paul In the previous thread of similar problems, I read I was supposed to take care of this corner case. My mainCalculateReturnOldTrades test and mainCalculateReturnVaryingDateRanges test case is failing.

I have taken care of case where the no. of year is less than 1 and have done correct sorting.

I didn’t know there was no test cases dealing with that and did spend a lot of time on it :sweat_smile:

Anyway I handled such cases by using simple “if” … was handling empty result by API. (I think you need not worry if they aren’t considering such cases)

And Even I had many build failure for the same testcase, I was making mistake in calculating the value of annualizedReturn,(you need to be very careful in calculating that…it looks simple, but we tend to make silly mistake in that…am telling cz I did :smile:)

@AmoghaKS I have used the approach mentioned in that post and even get correct results while debugging. I have dealt with the case where numbers of year is less than 1 but still test case are failing! :frowning:

how did calculate annualized returns?

Go through it again…you have dealt with it when it was less than year…but how did you calculate when it was more than a year. follow similar pattern when finding number of years.
if you have used 365.0/days in first case. You really need to keep that in mind when you calculate the number of years

I don’t think that’s logically coherent. Relax and try to start from basics only. Where could the calculations fail. There is a long discussion thread between @AmoghaKS and me. Go over it. We went over a lot of things and that’s how he solved it too.

@AmoghaKS Yes bro. I have done that. I have taken if else case like:
if(year<1) then use 365.0/days formula and take care of float values and if the year is greater than 1 then use orginal formula taking care of float values i.e 1.0/no.ofYears . I am doing similariily in both cases.

@shoryajain I went through your thread. I made sure to implement the points you mentioned but even then I am getting those two test cases failed. Infact, while debugging it shows right answer

you used 1.0/noOfYears ,well
I was making mistake in finding the noOfYears…well how are you finding that value, if you are doing a simple subtraction for getting that its an error

I think you need to delete it…I only asked you to express it in words.

@AmoghaKS Sorry about that!

No probz
Just have some break. Go through all the above answers carefully. You’ll definitely find the right way (itz simple but tricky :nerd_face:)

Was I doing any mistake there? :sweat_smile:

there was 1/years…but I have no idea how you are calculating that :smile: (check itz not there in your SS :sweat_smile:)
So I can only tell you to reconsider the way you are calculating that. cz I strongly feel you are making the same mistake as I did.

Actually, it was 1.0/years but I will see once again though! Thanks for helping!

am not telling you 1.0/ years is wrong… Did I ever say that?
am only stressing on the way you calculated noOfYears

1 Like

Okay, I will see once again! :sweat_smile:

:metal: :joy: post must be atleast 20 characters it seems.
have some rest and do it tomorrow man :sweat_smile:

Seems like one! Sure will do!