'Accumulating prices for a time period?
I have this function and what I want is the if-statement to be run over and over, accumulating a a price until the conditions are no longer met. Once met, do some other calculations in the else, reset the values (I tried with = 0) and return a value. But for some reason it doesn't do the right calculation and gives out nonsense.
cur_time = dt.datetime.now()
future_time = cur_time + 100
def A(cur_time, price):
if int(future_time) > int(cur_time):
price_acum += (float(price))
else:
avg_price = price_acum/100
print(avg_price )
future_time = cur_time + 100
return (avg_price )
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|
