Skip to content
All library documents

QuantLib Evaluation Date Updates Can Slow Python Simulations

Article Quant Q&A · Author: Pedro Mejor

Summary

The document describes a performance problem encountered while simulating a swaption strategy in Python with QuantLib. Updating the global evaluation date is initially quick, but repeated changes make the operation take much longer. The response attributes this behavior to a known issue in the SWIG layer used to create Python bindings for QuantLib’s C++ library.

The note points readers toward the relevant issue discussion for details and possible workarounds, but it does not explain the underlying mechanism or give a specific fix. It offers no benchmarks or comparison of alternative simulation designs, so it serves mainly as a diagnosis and pointer for researchers whose date-stepping valuations slow down in a similar setup.

Key ideas

  • Repeated evaluation-date changes can slow a Python QuantLib simulation.
  • The reported slowdown is linked to the SWIG bindings between Python and QuantLib’s C++ library.
  • The note points to an issue discussion for further detail and workarounds, but does not provide one directly.

Tags

Full text
# Why does changing the evaluationDate multiple times lead to a performance lag?


# Why does changing the evaluationDate multiple times lead to a performance lag?












I am simulating an swaption strategy through time. Following the examples in the Python Quantlib cookbook, as I progress through time I am updating the internal evaluation date

```
ql.Settings.instance().evaluationDate= todays_date
```

The first few iterations its reasonably fast, but after about 10 or so this line of code takes forever. What's going on? How can I keep it fast?

## Answer by Luigi Ballabio (score 1)

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

It's a known issue with the current version of SWIG, which we use to generate Python bindings to the underlying C++ library. See https://github.com/lballabio/QuantLib-SWIG/issues/212 for details and workarounds.

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.