All problems
Greeks Numeric
Problem
Estimate option Greeks with finite differences.
Given the base value f0, bumped values f_up and f_down, a later-time value f_t, spot bump ds, and time bump dt, return [delta, gamma, theta] with delta = (f_up - f_down) / (2 * ds), gamma = (f_up - 2 * f0 + f_down) / ds ** 2, and theta = (f_t - f0) / dt.
Hint
Delta is a central first difference and gamma a second difference.
Test cases
case 1
in: [10,11,9,9.8,1,0.1]
expected: [1,0,-1.999999999999993]
case 2
in: [5,5.2,4.7,4.9,0.5,0.25]
expected: [0.5,-0.3999999999999986,-0.3999999999999986]
case 3
in: [2,2,2,2,1,1]
expected: [0,0,0]
Starter codePython
def numeric_greeks(f0, f_up, f_down, f_t, ds, dt):
# Returns [delta, gamma, theta]
# Your code here
pass3 test cases · run your code against them in the editor