Answer:
import csv
def stock_prof():
csvfile = input("Enter absolute path to file name")
while csvfile:
file = open(csvfile, 'r')
data = csv.DictReader(file)
profit_list = [row['High'] - row['Low'] for row in data]
print(f"The maximum profit is: {max(profit_list)}")
for row in data:
print(f"Buy on {row['Data']} at the price of {row['Low']}")
print(f"Sell on {row['Data']} at the price of {row['High']}")
print(f"Change in value ratio: {row['High']/row['Low']}")
csvfile = input("Enter filename: ")
stock_prof()
Step-by-step explanation:
Assuming the CSV file is in the same directory as the python script, the user inputs the file name and uses the CSV DictReader method to read the file as an ordered dictionary, then the maximum profit is printed as well as the date to buy and sell and the change in value ratio.