Stock profit
Python
stock_prices = [10,5,20,32,25,12]
dts = [
'2019-01-01',
'2019-01-02',
'2019-01-03',
'2019-01-04',
'2019-01-05',
'2019-01-06',
]
def get_profit_dates(stock_prices, dts):
profit = max(stock_prices) - min(stock_prices)
for index, price in enumerate(stock_prices):
if min(stock_prices) == price:
buy_date = dts[index]
elif max(stock_prices) == price:
sell_date = dts[index]
return (profit, buy_date, sell_date)
print(get_profit_dates(stock_prices, dts))
Output
Embed on website
To embed this program on your website, copy the following code and paste it into your website's HTML:
Comments
This comment belongs to a banned user and is only visible to admins.
This comment belongs to a deleted user and is only visible to admins.