Answered step by step
Verified Expert Solution
Question
1 Approved Answer
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.
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
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started