SigmaField

Practice Options

Break-evens and worst case of an options book

Easy+10 pointsAbout 20 minutesOptions

The brief

An options desk runs a small book on one stock, which trades at $64.20. The book holds the stock, two bought puts, a sold put and a sold call. All the options expire on the same day.

The risk manager wants the book's profit at expiry as one function of the stock price. From it come the prices where the book breaks even, and the most it can lose.

Your task

  1. Write book_profit(S, book): the book's profit at expiry when the stock ends at S, a number or a NumPy array. Each leg adds its quantity times its payoff minus its price. Raise ValueError for a negative S, a negative strike, or a kind other than "call", "put" or "stock".
  2. Write break_evens(book): every stock price S≥0S \ge 0 where the profit is zero, smallest first. Assume the profit is not zero along a whole stretch of prices.
  3. Write worst_case(book): the lowest profit over all S≥0S \ge 0. Return -math.inf when the loss has no limit.

The data

BOOK in the code lists the four legs. Each has a kind, a strike (None for the stock), a quantity and a price. A negative quantity is a sale, and the price is the premium per option or the price paid per share.

Hint: Where to start

Each option's payoff is a ramp from case study 1.1.5: max⁡(S−K,0)\max(S - K, 0) for a call and max⁡(K−S,0)\max(K - S, 0) for a put. A share pays SS. Multiplying by a negative quantity flips the leg over the axis, and turns the premium into cash received.

Hint: Finding the break-evens

Between two neighbouring strikes every leg is a straight line. So the profit is a piecewise function (lesson 1.1.2), straight on each piece.

Find the zero of each piece, as in lesson 1.1.1. Do not forget the piece beyond the last strike: it goes on for ever.

Hint: The worst case

A function made of straight pieces is lowest at a corner or at an end. Check S=0S = 0 and every strike. Then check the slope past the last strike: if the profit falls there, it has no floor (case study 1.1.5).