Skip to content
DeepForgeby svx
All problems
EasyTime Seriests-015

Realized Volatility

Problem

Compute realized volatility from a list of returns as sqrt(sum(r^2)), i.e. the square root of the sum of squared returns with no mean subtraction.

Return 0.0 for an empty return list.

Hint

Squaring makes negative returns count the same as positive ones.

Test cases

case 1
in: [[0.01,-0.02,0.03]]
expected: 0.03741657386773942
case 2
in: [[0.1]]
expected: 0.1
case 3
in: [[0,0]]
expected: 0
case 4
in: [[-0.05,0.05]]
expected: 0.07071067811865477
Starter codePython
def realized_volatility(returns):
    # Your code here
    pass

4 test cases · run your code against them in the editor