liveBook · Manning

Option-price

As explained in Build a Robo-Advisor with Python (From Scratch)

A Python package that computes option prices using supported analytical and numerical pricing methods.

option-price automates option valuation when a tax-loss-harvesting decision must weigh a tax benefit against the cost of losing exposure to future price declines. Create an Option with contract, market, and rate inputs, then request a pricing method. section 14.3.2

An Option requires:

  • Style and payoff type: european is True or False; kind is put or call. section 14.3.2
  • Market inputs: current asset price (s0), strike (k), life in days (t), annualized volatility (sigma), risk-free rate (r), and dividend yield (dv). section 14.3.2
  • A method and, for trees or simulations, an iteration count: BT for binomial trees, BSM for Black–Scholes, or MC for Monte Carlo. section 14.3.2

Pricing an American put

Instantiate an American put with s0=150, k=140, 30 days remaining, sigma=.45, r=.03, and dv=.01; getPrice('BT', iteration=1000) returns about $3.4284. An invalid method such as BSM for an American put returns None rather than raising an error. section 14.3.2

from optionprice import Option

x = Option(european=False, kind='put', s0=150, k=140, t=30,
           sigma=.45, r=.03, dv=.01)
p = x.getPrice('BT', iteration=1000)

This listing shows the minimal import, Option construction, and binomial-tree pricing call. section 14.3.2

How Build a Robo-Advisor with Python (From Scratch) covers it

How deep it goes
Explains required inputs and method selection but defers option-pricing theory and model derivations.
Examples
Demonstrates a 30-day American put priced near $3.4284 with a 1,000-iteration binomial tree.
What it assumes
Introduces package installation and pricing inputs while deliberately deferring option-pricing theory.
What you can do after
Apply it via option-price to price supported options and detect incompatible method choices returning None.
How it connects
Connects option pricing to tax-loss harvesting, opportunity cost, Black–Scholes, binomial trees, and Monte Carlo simulation.

Related concepts

This explainer was generated by Manning's knowledge graph from the text of Build a Robo-Advisor with Python (From Scratch). The section links point to the parts of the book it draws on.