Skip to main content
8 votes
Accepted

Recommended Setup for QuantLib-Python AmortizingFloatingRateBond

A few things before creating the bond: 1) You can delegate to the library the calculation of the dates. Your code is equivalent to: ...
Luigi Ballabio's user avatar
5 votes
Accepted

To estimate the parameters when only the characteristic function is known to us

General remarks A difficult but very interesting problem. Some thoughts: Use GMM instead of MLE. MLE is a special case of the generalised method of moments. The characteristic function gives you the ...
Kevin's user avatar
  • 16k
4 votes
Accepted

Extending/Subclassing QuantLib Classes in Python?

I think you can use a combination of the ql.DeltaVolQuote and ql.BlackDeltaCalculator classes with the ...
user35980's user avatar
  • 1,426
4 votes
Accepted

Why is the NPV of this FX Forward 0?

This is not an FX Forward but a Forward Rate Agreement (a rates product). I'm not sure if QuantLib has a FX Forward pricer but they do have one for FX swaps (see ...
oronimbus's user avatar
  • 1,896
4 votes
Accepted

QuantLib: Analytical Greeks and Numerical Greeks do not match?

How close the numerical Greeks are to the analytic Greeks depends on how one calculates them. The analytic Greeks correspond to the mathematical derivatives, so in general smaller increments should ...
Luigi Ballabio's user avatar
4 votes

QuantLib calculations for a Canadian corporate fixed rate bond differ from BBG YAS

The tricky thing about Canadian bonds is that they use ACT/365F convenction for accrued interest for settlement, but ACT/ACT(ISMA) for accrued interest in yield calculations. Which means in QuantLib ...
Denys Usynin's user avatar
4 votes

Python QuantLib datecount ActualActual basis vs Matlab daycount basis

I think you will never find 30.0302 using quantlib : ...
TourEiffel's user avatar
4 votes
Accepted

Calculating swap rolldown using the RatesLib Python Library

Your question seems restricted only to the lines: ...
Attack68's user avatar
  • 10.8k
3 votes

PV different from Dirty Price in QuantLib

It's the combination of two things. First: when passed an interest rate y and a series of coupons paying at dates ...
Luigi Ballabio's user avatar
3 votes
Accepted

Clarifying Parkinson Python Code

I don't know why you are multiplying by v.mean() and you are missing the sum of squared differences for the rolling window. I did this quickly, off the top of my ...
amdopt's user avatar
  • 4,348
3 votes
Accepted

GBP OIS Curve - Zero Rate Curve Calculation in Quantlib

If you intend to find the zero rates or the discount factors of the OIS curve for GBP then I would use the following approach where instead of using ...
Xiarpedia's user avatar
  • 319
3 votes
Accepted

QuantLib Python: Calculate ZSpread

You can see the interface of zSpread declared at https://github.com/lballabio/QuantLib-SWIG/blob/v1.33/SWIG/bondfunctions.i#L146. It takes a shared_ptr to term ...
Luigi Ballabio's user avatar
3 votes

Python QuantLib datecount ActualActual basis vs Matlab daycount basis

I'm not sure what convention Matlab means when they say "actual/actual"; there are a few of them, see e.g. https://www.isda.org/a/AIJEE/1998-ISDA-memo-%E2%80%9CEMU-and-Market-Conventions-...
Luigi Ballabio's user avatar
2 votes

Best practice in QuantLib Python to include borrow rate

It depends on your use cases. Something like SpreadedLinearZeroInterpolatedTermStructure, as you suggested, will work but will use both the original curve and the ...
Luigi Ballabio's user avatar
2 votes

how to calculate YTD return including the paid dividends

I've recently created a Python package called pyTAA as a side hobby to analyse low-frequency strategies. This is very much in alpha and can change at any point in time. To answer your question, I've ...
oronimbus's user avatar
  • 1,896
2 votes

Pricing European Call Closed Form Spread Options in Python

Firstly, you can really use Margrabe's formula (as @Rylan said). It's exact solution, so there is good first test. You can use numerical integration (scipy methods for example) for test your Monte-...
K. Roman's user avatar
2 votes
Accepted

Understanding SOFR Fixing Rate Retrieval for Future Dates in QuantLib

If you ask the SOFR index for a fixing at the start date of the coupon, it will return it, but that's not what the coupon pays. A coupon paying SOFR over a period pays the compounded SOFR fixings ...
Luigi Ballabio's user avatar
2 votes

R resources for GMM estimation and testing of multifactor asset pricing models

In this answer, I provide Matlab code for implementing a two-step GMM test of a multi-factor asset pricing model. I closely follow Cochrane (2005) which is an amazig book. See also this short video. ...
Kevin's user avatar
  • 16k
2 votes

Reliability of R Package on Covariance Matrix Shrinkage

You can use the code provided from the authors directly. Michael Wolf has a whole library of examples here in different programming languages. For the "Honey, I Shrunk the Covariance Matrix" ...
oronimbus's user avatar
  • 1,896
2 votes

Extending/Subclassing QuantLib Classes in Python?

Just to confirm: subclassing the Python wrappers doesn't work.
Luigi Ballabio's user avatar
2 votes
Accepted

Curve construction with Python's RATESLIB package

That is a curve parametrised by discount factors. The initial node date must be 1.0. Including the defaults that curve is actually the same as ...
Attack68's user avatar
  • 10.8k
2 votes

For a university project I need the historical number of outstanding shares for all companies currently in the S&P 500

If you are at a University you likely have access to CRSP. CRSP is very fast to access and has the information you need. See a list of variables below. You have bid, ask and if you multiply the ...
phdstudent's user avatar
  • 8,431
2 votes
Accepted

QuantLib: How to price or construct a zero coupon swap using Quantlib

I am running QuantLib version 1.30 and it works for me. Here is the code I compiled to investigate as unfortunately yours did not work for me ...
Xiarpedia's user avatar
  • 319
2 votes
Accepted

Why do the Greeks not converge to the strike as the volatility tends to zero?

If you shrink the volatility (let's say more extreme it goes to zero), then the spot price at maturity is simply $S_t e^{r(T-t)}$. There are no uncertainty; the at-maturity spot price becomes somehow ...
JamesWuuuu's user avatar
2 votes

Getting ETF components (underlying stocks)

To answer the "where", you can scrape the info you need from SEC forms NPORT-P. they are monthly and contain the underlying positions of each ETF in Part C of the form. (see example here ...
mountshoutcap's user avatar
2 votes
Accepted

QuantLib FittedBondDiscountCurve does not produce expected rates

I now understand the Nelson-Siegel algorithm, and realize that since the fittedBondCurveMethods.get('NelsonSiegelFitting') line is fitting a model, and not interpolating data, it need not ...
Trevor J Richards's user avatar
2 votes
Accepted

Approximation of an Itô integral with python

it seems that your coding is not calculating the expected value of the Ito integral but instead, it is only calculating the Ito integral for one trajectory. You need to add a loop to your coding for ...
pierrot's user avatar
  • 96
2 votes

How to bootstrap the zero coupon curve for US treasuries

By executing the following code: ...
Xiarpedia's user avatar
  • 319
2 votes

My Montecarlo Simulation is not working?

Your sigma seems to be incorrect, the sigma used should be annualized. Therefore, if you use your mean of standard deviation, you need to multiply it with $\sqrt{252}$. I do not think there is ...
KaiSqDist's user avatar
  • 1,474
2 votes

My Montecarlo Simulation is not working?

Even with 2000 simulations, you may not get the expected return and volatility as your estimated parameters. Try running your monte carlo with more simulation paths and this should close the ...
AlRacoon's user avatar
  • 6,632

Only top scored, non community-wiki answers of a minimum length are eligible