QMoney module 8 PortfolioManagerPerformanceTest.calculateExtrapolatedAnnualizedReturn() Test failing

One of the tests is failing “ PortfolioManagerPerformanceTest ” since the time taken for parallel execution is greater than 6 seconds. But when I measure the latency improvements using the command “time python3 dashboard.py --json module8-trades.json”, it returns the result in less than 4 seconds:

The calculateExtrapolatedAnnualizedReturn() is failing, when I check the time taken to execute for this test its more than 10-15 seconds at times. Please help. I’m stuck on this issue from the past few days.

Hi @yaditya20
Looks like you are facing challenges in the current module.

Below is a link to all the FAQ’s for the current module

Below are a few similar topics raised by other users which you might find usefull

Note - This is a BETA Feature,if you find this helpful, kindly let us know.
Feedback link - https://forms.gle/cmxN5pdTXgnwgC986

Kindly mark this as a solution if this has helped you solve your query

Hi Aditya,

So, one way to move forward is to see our code for any performance improvements apart from the concurrency part.

Can you quickly check if you are making any redundant code in any of the methods the calculateAnnualizedReturnParallel() is dependent on? Check if any code used is actually not needed or can be re-written to avoid calling multiple times.

Kindly revert back after giving it a try for like some 15-30mins if it still persists

And regarding the Python utility taking only 4 seconds, we are also including time taken for the assert statements to execute in the tests.

Hello Nabhan,

I don’t find any redundant code or maybe not very clear on where and how I can check if I’m making redundant code usage. My calculateAnnualizedReturnParallel() is calling getAnnualizedAndTotalReturns(trade, endDate) as a callable task to get a result and then loop over the PortFolioTrade to get the results stored in Future object and return the List of AnnualizedReturn object.

Please let me know if something I’m missing or I can still improve on my code.

Can you quickly see if we need two getBuyAndSellingPrices() method calls?
We can handle exceptions differently by chaining multiple catch in a single try-catch statement.

Closing this topic as your issue is resolved by the mentor. If it is still not resolved, Kindly un-mark the accepted solution or create a new topic and post this question as a reference link in the description of the new topic.