Python
- 1 ответ
- 0 вопросов
0
Вклад в тег
# test data preparation
close_prices = []
for i in range(1, 30):
close_prices.append(random.randint(52000, 57000))
# setting the number of periods in a year
interval_count_in_year = 365
# volatility calculation
sum_squares = sum(math.log(close_prices[i] / close_prices[i - 1]) ** 2
for i in range(1, len(close_prices)))
st_dev = math.sqrt(sum_squares / (len(close_prices) - 1))
volatility = round(st_dev * math.sqrt(interval_count_in_year) * 100, 2)