Skip to content
All library documents

Polynomial Basis Order in QuantLib’s American Basket Option Engine

Article Quant Q&A · Author: Bananach

Summary

The document asks how to change the polynomial basis order used by QuantLib’s Monte Carlo engine for American basket options priced with the Longstaff–Schwartz least squares method. The questioner finds an order parameter in an internal path pricer but cannot pass it through the public engine interface. They also ask whether the engine chooses the basis order automatically based on the requested pricing tolerance.

The answer reports that the polynomial order is not exposed as an engine argument in the version discussed, and that an issue was opened to track the limitation. It does not provide a workaround, explain the engine’s regression basis in detail, or establish that pricing tolerance controls basis selection. The practical takeaway is an implementation constraint: users of that interface cannot tune this parameter directly, so they should not assume that tightening the requested tolerance changes the regression polynomial order. The exchange does not assess pricing accuracy or compare alternative basis choices.

Key ideas

  • The question concerns Longstaff–Schwartz Monte Carlo pricing for American basket options.
  • The polynomial order exists in an internal path pricer but is not exposed through the engine interface described.
  • The answer does not say that pricing tolerance determines polynomial order.
  • The exchange identifies an interface limitation but gives no workaround or accuracy study.

Tags

Full text
# QuantLib: How to change polynomial order in MCAmericanBasketEngine?


# QuantLib: How to change polynomial order in MCAmericanBasketEngine?












My goal is to price American basket put options using the Least squares Monte Carlo, or Longstaff-Schwartz algorithm.

I currently have the one-dimensional case working with the Python file below (I am using the SWIG package), but I would like to change the number of basis functions used by the AmericanBasketEngine to make sure the price is accurate. How do I do this?

Looking at the C++ source, I found the `polynomOrder` keyword argument with default value `2` of the class `AmericanBasketPathPricer`. However, I do not know how this class is connected to the `MCAmericanBasketEngine`, which does not have such a keyword argument. (I never programmed in either `C` or `C++`, so I am quite lost in the source.)

Maybe is the polynomial order determined automatically, based on the `requiredTolerance`? That would be ideal, but I couldn't find a description of what the `MCAmericanBasketEngine` does exactly anywhere.

```
from QuantLib import *

d=1 #To be increased...
todaysDate = Date(15,May,1998)
Settings.instance().evaluationDate = todaysDate
settlementDate = Date(17,May,1998)
riskFreeRate = FlatForward(settlementDate, 0.05, Actual365Fixed())

payoff = PlainVanillaPayoff(Option.Put, 100.0)

underlying1 = SimpleQuote(100.0)
volatility1 = BlackConstantVol(todaysDate, TARGET(), 0.30, Actual365Fixed())
dividendYield1 = FlatForward(settlementDate, 0.00, Actual365Fixed())
process1 = BlackScholesMertonProcess(QuoteHandle(underlying1),
                                    YieldTermStructureHandle(dividendYield1),
                                    YieldTermStructureHandle(riskFreeRate),
                                    BlackVolTermStructureHandle(volatility1))
procs = StochasticProcessVector()
procs.push_back(process1)

matrix = Matrix(1,1)
matrix[0][0] = 1.0
process = StochasticProcessArray(procs, matrix)
american_exercise = AmericanExercise(Date(17,May,1998),Date(17,May,1999))
basketoption = BasketOption(AverageBasketPayoff(payoff,d),american_exercise)
basketoption.setPricingEngine(
    MCAmericanBasketEngine(
        process,
        'pseudorandom',
        polynomOrder = 2,#keyword does not exist
        timeStepsPerYear = 100,
        requiredTolerance = 0.01,
        #seed = 42))
    )
)
print(basketoption.NPV())
```

## Answer by Bananach (score 1)

https://quant.stackexchange.com/a/39702

As per QuantLib's lead developer, `polynomOrder` is indeed not currently exposed. There is now a GitHub issue about this.

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.