Some error in getstockQuotes module4

Actually I am unable to calculate any of the returns properly as I received assertionErrors as my build fail error for those lines where it compares annualisedReturn. I used debugger and got to know that I made two calls to getStockQuotes, one to get data for the endDate asked by user(to get sellprice) nd another for purchase date (o get buyprice). But I dont know why the two returned list are having same values and of the end date. Parameters are all set properly but I am unable to rectify the error. Dont know where the dates are getting switched or something.

I am using
getStockQuote(portfolioTrades.get(i).getSymbol(), endDate, endDate); for buyprice evaluation call and
getStockQuote(portfolioTrades.get(i).getSymbol(), portfolioTrades.get(i).getPurchaseDate(),
for purchaseprice call.
I have set the parameters correctly but still there is some error as the returned values are exactly same for both which are dates for endDate and not purchasedDate

You’re calling functions in wrong way getStockQuote () return type is List<Some candles>. Now, the significance of this method is fetch all the records between purchaseDate and endDate. Where end date is supplied externally by user and startDate will be read from PortfolioTrade.


getStockQuote (symbol, purchaseDate, endDate);

When you call this function it will return you all the records in between these dates. And from it you need to find purchase price which fill be open price of first date and sell price will be close price of last date.
Try this!

Thanks for the reply sir but the thing was I am calling builduri from getstockquotes with same purchase and enddate so it will eventually give me the stock details for that particular date. I verified this using postman and designed my code accordingly. I can do as you are stating but I wish to know what is the error in my way of calling.

See error will occur when you use

getStockQuote(portfolioTrades.get(i).getSymbol(), endDate, endDate);

Suppose, I need to fetch the data between startDate = 2020-01-01 to endDate = 2020-11-01?
What do you think will you get any output?
YES you will, there is output when you run CURL command for these dates but check for these methods

1. getStockQuote(portfolioTrades.get(i).getSymbol(), endDate, endDate); //NO
2. getStockQuote(portfolioTrades.get(i).getSymbol(), portfolioTrades.get(i).getPurchaseDate(), portfolioTrades.get(i).getPurchaseDate());//YES
3. getStockQuote (symbol, purchaseDate, endDate); // YES

you will see the difference in all the three methods and specially in 1 and 3.

@abhinavk2804 As your issue seem to be resolved and you have moved onto the next module, I am closing this topic.

For further queries, you can create a new topic and continue there.

1 Like