Question: Could you do this python question without for loops? You can use any dataset to present the code. What was the worst possible buy&sell operation?
Could you do this python question without for loops? You can use any dataset to present the code.
What was the worst possible "buy&sell" operation? Find the two days x and y so that the % loss resulting from buying in x and selling in y (with y after x) is maximized. Your code should work for any data. Hint: Use method cummax() or method cummin(). Cummax/Cummin returns the maximum/minimum value encountered so far. Make sure to return the trading days x and y, as well as the % loss resulting from buying in x and selling in y
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
