Problem in

Can someone please explain what is portfolioManager and portfolioTrades in mainCalculateReturnsAfterRefactor. (Red underlined)???

portfolioManager will be a result of the implementation of factory pattern whereas portfolioTrades will consist list of all trades (something which you have already completed in previous modules)

so why there is red line on portfolioTrade?

It is showing red line because there isn’t a variable named portfoliotrade in the function itself.
You first have to complete your logic to fetch portfoliotrades which is already passed in that function

you will solve that in final task of module 4. after you complete all the todos in IMPL file and Factory file.
then you will replace portfolioTrades by the class and/or methods which will return you the object of portfolioTrade so you cal finally call the mentioned function.
If you can’t understand anything i just said then just follow these steps:
1.complete the todos in impl file
2.complete the todos in factory file
3.complete the todos in main file