Skip to content
Python for Quantitative Finance / Model and software design

Object-Oriented Model Design

Many bonds can share the same discount curve. Keeping that curve separate from the instruments makes a rate update easier to trace and test. This lesson separates market-data snapshots, model parameters and fixed contract terms. It uses composition to build a curve, a zero-coupon bond and a European call.

Learning objectives. By the end of this note you should be able to:
  • separate market observables from model parameters in attribute design;
  • implement a small curve object with a clear interpolation contract;
  • compose an instrument that depends on a curve rather than subclassing the curve;
  • explain when inheritance helps (shared interface) and when it obscures the model.

In this lesson

  1. Encapsulation for market data versus parameters
  2. A discount curve by composition
  3. Instruments that use the curve
  4. Inheritance — use sparingly
  5. Design checklist for a quant class
  6. Many instruments share one curve

Before you start

The full lesson, with worked examples and exercise solutions, is for members.

Read the full lesson

New to SelfMadeQuant.com? See membership options or browse the Python for Quantitative Finance syllabus.