It's my understanding that in order to calculate the option adjusted spread on a mortgage backed-security, the following steps are required:

  1. Run a Monte Carlo simulation of interest rates
  2. Project mortgage rates along each simulation
  3. Compute cashflows and get NPV
  4. Average NPV and compute spread that solves for the number added to zero curve

I have been looking everywhere online for python or C++ or C# code to implement this form of calculating OAS, but alas I cannot find anything. The closest thing I found was C++ in QuantLib

However the code below does not do any monte carlo interest rate simulation, it appears to be simply solving for a spread, similar to zspread

Would this OAS method not work for an MBS given that there isn't a monte carlo of rates?

Is my understanding of how to calculate OAS correct, or incorrect?

Likewise if you can help point me in the direction of a code base that implements OAS on an MBS it would be much appreciated.

   Spread CallableBond::OAS(Real cleanPrice,
                             const Handle<YieldTermStructure>& engineTS,
                             const DayCounter& dayCounter,
                             Compounding compounding,
                             Frequency frequency,
                             Date settlement,
                             Real accuracy,
                             Size maxIterations,
                             Spread guess)
        if (settlement == Date())
            settlement = settlementDate();

        Real dirtyPrice = cleanPrice + accruedAmount(settlement);

        ext::function<Real(Real)> f = NPVSpreadHelper(*this);
        OASHelper obj(f, dirtyPrice);

        Brent solver;

        Real step = 0.001;
        Spread oas=solver.solve(obj, accuracy, guess, step);

        return continuousToConv(oas, *this, engineTS, dayCounter, compounding, frequency);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.