Any QuantLib experts here?

GPT is an expert


import QuantLib as ql

# Setting the evaluation date
calculation_date = ql.Date(1, 1, 2022)
ql.Settings.instance().evaluationDate = calculation_date

# Bond parameters
face_value = 100
coupon_rate = 0.05
coupon_type = ql.Annual
bond_maturity = 10

# Create a flat yield term structure
interest_rate = ql.SimpleQuote(0.03)
rate_handle = ql.QuoteHandle(interest_rate)
day_count = ql.ActualActual()
term_structure = ql.FlatForward(calculation_date, rate_handle, day_count)
ts_handle = ql.YieldTermStructureHandle(term_structure)

# Construct the bond schedule
issue_date = calculation_date
maturity_date = issue_date + ql.Period(bond_maturity, ql.Years)
schedule = ql.Schedule(issue_date, maturity_date, ql.Period(coupon_type),
ql.TARGET(), ql.Unadjusted, ql.Unadjusted,
ql.DateGeneration.Backward, False)

# Construct the bond
bond = ql.FixedRateBond(0, face_value, schedule, [coupon_rate], day_count)

# Get the bond's present value
bond_engine = ql.DiscountingBondEngine(ts_handle)
bond.setPricingEngine(bond_engine)
print("Bond's present value:", bond.NPV())
 
Been using it a while ago for some fixed income implementations (C++). What you wanna know?
I'm looking for a QuantLib code that simulates stock prices by using GBM (Geometric Brownian Motion),
for example daily prices for a year.
I found the following old code from 2013, but I am not sure whether it's correct:
https://mhittesdorf.wordpress.com/2...-asset-prices-with-geometric-brownian-motion/
I'm not sure whether this Box-Muller method for getting normal distribution is correct.
Why is it not simply using the built-in (in C++11 and higher) std::normal_distribution instead?
What do you folks think about this?
Do you have got a better GBM code in QuantLib?
 
Last edited:
so you're looking for a gbm generator? what does this have to do with quantlib?
Yes, a GBM generator in QuantLib. GBM usually is part of any such financial library.
As said, I need a GBM example code in QuantLib. I'm not sure wthether the above linked GBM code is correct as it's very old, therefore asking some QuantLib experts here for their expertise.
 
Last edited:
Back
Top