The brief
An options desk gets its prices from a vendor library that rounds every price to 6 decimal places. Its risk system finds each call's delta and gamma by bumping the stock price by 1% and repricing.
For an at-the-money call a week from expiry, that bump gets gamma about 1.1% wrong. A 1-cent bump is no cure: rounding alone makes the gamma of the 6-month at-the-money call 8.0% wrong. The desk wants each option's bumps chosen to balance the two errors, and checked against the exact values.
Your task
- Write
bumped_greeks(price, S, h): the pair(delta, gamma)from central differences ofprice, a function of the stock price alone, with a bump ofhdollars. RaiseValueErrorunless . - Write
truncation_coefficients(price, S, pilot): the pair(b, a). The bumped delta is about and the bumped gamma about . Measure and from the two bumpspilotandpilot / 2. - Write
best_bumps(price, S, noise, pilot): the pair(h_delta, h_gamma), each chosen where its truncation error equals its rounding error. Each price is off by up tonoise, so rounding moves the bumped delta by up to . It moves the bumped gamma by up to . - Write
greek_report(book): one dict per option, with the keysh_delta,h_gamma,delta,gamma,delta_errorandgamma_error. Price withvendor_calland takeNOISEas its noise. Each error is the bumped Greek minus the exact one frombs_delta_gamma.
In best_bumps, never bump by more than the pilot, and use the pilot when a coefficient is 0. Raise ValueError if noise is not positive. In greek_report, use the pilot : a fifth of the stock's typical move over the option's life.
The data
BOOK holds five European calls, each a dict of S, K, T, r and sigma. The code provides bs_call, the exact bs_delta_gamma and the rounded vendor_call. NOISE is half a unit in the sixth decimal place.
Hint: Where to start
Case study 2.8.4 bumps the stock both ways and reprices; use its central differences for delta and gamma. Lesson 2.8.1 gives their truncation errors, and . Both grow like , which is why one coefficient describes each.
Hint: Measuring the coefficients
With the pilot , the bumped delta is about , and with about . Subtract the two: the unknown cancels and leaves . Gamma works the same way.
Hint: Balancing the errors
Lesson 2.8.1 picks the step where the truncation error equals the rounding ceiling. Here that is for delta and for gamma. Case study 2.8.4 explains why a noisier pricer needs a larger bump.