Any QuantLib experts here?

But as said I need to do it w/ QuantLib. GBM is just a minor part.
Excel is the biggest BS for such a task, b/c slow. I need to generate multi-millions of such GBM generated prices for a Monte Carlo simulation.

Why bother? You'll find the math will come out all wrong and you'll start a new thread about it, whining to anyone who will listen that you have a better way.
 
  • Like
Reactions: rb7
Why bother? You'll find the math will come out all wrong and you'll start a new thread about it, whining to anyone who will listen that you have a better way.
As posted some weeks ago here, I'm doing a research. I now just wanted to include also QuantLib into my research.
It indeed could be that the GBM in QuantLib is as buggy as most of the GBMs I so far have tested.
 
Last edited:
Just an update:
Using the above said QuantLib GBM code I get very very weired results.
IMO the GBM in QuantLib can never ever be correct.
WIll continue my tests tomorrow.
Will also post the code here for verification & reproduction of the results by others.
 
Last edited:
Exactly, he could not even articulate why it must be in QuantLib. Probably some homework, lol. Not worth the effort.

Why bother? You'll find the math will come out all wrong and you'll start a new thread about it, whining to anyone who will listen that you have a better way.
 
Just an update:
Using the above said QuantLib GBM code I get very very weired results.
IMO the GBM in QuantLib can never ever be correct.
WIll continue my tests tomorrow.
Will also post the code here for verification & reproduction of the results by others.
Another example for you to "prove" incorrect.;)
Bing Chat said:
Sure! There are many resources available online that provide examples of how to use QuantLib. For instance, Gouthaman Balaraman has a collection of tutorials on his website that cover various topics, including modeling fixed rate bonds, bootstrapping yield curves, and valuing interest rate swaps using QuantLib and Python². You can also find documentation and examples on the official QuantLib website¹.

Here is an example of how to create a Geometric Brownian Motion (GBM) model using QuantLib and Python:

Code:
```python
from QuantLib import *

# Set up the model parameters
riskFreeRate = 0.05
dividendYield = 0.02
volatility = 0.2
initialValue = 100

# Set up the time grid
maturity = 1.0
dt = 0.01
timeSteps = int(maturity / dt)

# Set up the random number generator
seed = 42
rng = GaussianRandomSequenceGenerator(UniformRandomSequenceGenerator(timeSteps, UniformRandomGenerator(seed)))
seq = GaussianPathGenerator(GBMProcess(QuoteHandle(SimpleQuote(initialValue)), YieldTermStructureHandle(FlatForward(0, TARGET(), riskFreeRate, Actual360())), YieldTermStructureHandle(FlatForward(0, TARGET(), dividendYield, Actual360())), BlackVolTermStructureHandle(BlackConstantVol(0, TARGET(), volatility, Actual360()))), maturity, timeSteps, rng)

# Generate the path
path = seq.next().value()

# Print the path values
for i in range(len(path)):
    print(f"Time: {i * dt:.2f}, Value: {path[i]:.2f}")
```

This code sets up a GBM model with specified parameters for the risk-free rate, dividend yield, volatility, and initial value of the asset. It then uses QuantLib's `GaussianPathGenerator` class to generate a sample path of the asset price over time. The resulting path is printed to the console.

I hope this example helps you get started with using QuantLib to create GBM models! Let me know if you have any further questions or if there's anything else I can help with.

Source: Conversation with Bing, 9/7/2023
(1) QuantLib Python Tutorials With Examples - G B. http://gouthamanbalaraman.com/blog/quantlib-python-tutorials-with-examples.html.
(2) QuantLib Documentation. https://www.quantlib.org/docs.shtml.
(3) Modeling assets with QuantLib | modelx. https://modelx.io/blog/2022/02/13/modeling-assets-with-quantlib/.
(4) Writing Your First QuantLib Program in C++. https://benjaminwhiteside.com/2018/12/07/writing-your-first-quantlib-program-in-c/.
(5) QuantLib Installation in Visual C++. https://www.quantlib.org/install/vc10.shtml.
(6) Introduction to Selected Classes of the QuantLib Library I. https://www.quantlib.org/slides/dima-ql-intro-1.pdf.
 
@ph1l, thx, can you or your BingChat perform the said test here?
The devil is in the detail: timeSteps (in above link it's called N) must be as small as possible to see the error, ie. 1 to about 25 or so.
In QuantLib the practical minimum possible seems to be 2 since the first of the generated values is always the passed initial price.

Ie. the challenge is: Does your GBM algorithm pass the "68–95–99.7 rule test"?
They are 3 tests, but the first (ie. the 68.27% test) just suffices to pass.
 
Last edited:
Back
Top