当给定输入为当前价格= 1且投资为12时,我遇到了问题
当预期输出为“买入2股”时,代码将返回“持股”。
def trade_action(current_stock, purchase_price, current_price, investment,):
# Write your code here.
if current_price<purchase_price:
investment-=10
number_shares = investment/current_price
profits= (number_shares*current_price-purchase_price)-10
if profits >= 0:
return "Buy", int (number_shares)
else:
return "Hold Shares"
elif current_price> purchase_price:
if current_price-purchase_price*current_stock-10>0:
return "Sell Shares", int (number_shares)
else:
return "Hold Shares"
else:
return "Hold Shares"