Problem Statement
Given an unordered list of future stock prices, what is the maximum amount of profit that you could generate from a starting amount of 400.00 you could buy/sell 2.5 of them for $1000.00)
All trades occur instantaneously and do not incur any transactions costs.
Share may only be bought/sold on the date that you have a known price
Short selling is not allowed
You do not need to have a position at all times(if you cannot identify a profitable trade, you do not have to trade)
Round the final answer to the nearest dollar
Future prices will be given as a list in following format : [Stock,date,Price]
Example 1:
"CSCO, 10/18/2024, 41.89",
"AMZN, 10/10/2024, 113.67",
"AMZN, 10/18/2024, 120.5",
"CSCO, 10/10/2024, 43.12"
Solution
Buy 8.797 AMZN @ 60
Example 2:
"IBM, 12/01/2023, 132.05",
"IBM, 12/03/2023, 135.19",
"IBM, 12/18/2023, 134.07",
"AAPL, 12/01/2023, 187.19",
"AAPL, 12/04/2023, 164.33",
"AAPL, 12/20/2023, 180.94",
"AAPL, 12/21/2023, 179.65",
"GOOG, 12/01/2023, 116.41",
"GOOG, 12/07/2023, 111.36",
"GOOG, 12/19/2023, 112.19"
Expected output: 127
Example 3:
"INTC, 12/01/2023, 30.00",
"INTC, 12/05/2023, 35.00",
"INTC, 12/10/2023, 33.00",
"AAPL, 12/02/2023, 150.00",
"AAPL, 12/06/2023, 155.00",
"AAPL, 12/11/2023, 160.00",
"INTC, 12/15/2023, 36.00"
"INTC, 09/10/2024, 36.26",
"INTC, 12/04/2023, 33.39",
"AAPL, 12/22/2023, 197.61",
"AAPL, 07/20/2025, 181.71",
"INTC, 10/27/2024, 35.66",
"AAPL, 01/30/2025, 178.68",
"AAPL, 12/21/2024, 176.22",
"AAPL, 05/14/2024, 182.66",
"INTC, 08/15/2024, 35.23",
"AAPL, 02/20/2025, 196.47",
"INTC, 03/29/2025, 32.13",
"INTC, 06/28/2025, 32.96",
"INTC, 07/11/2025, 35.63"
Expected Output : 343