Pregunta

I am trying to build a BlackVarianceSurface so that I can compare interpolation result with mine. What i did is

todaydate = Date(1, January, 2010) 
maturity=[]
for i in range(24):
  maturity.append(Date(1, January, 2010)+Period(i, Months))

k = range(10, 90, 10)
vol = abs(random.randn(24, 8)).transpose().tolist()

volsurf = BlackVarianceSurface(todaydate, TARGET(), maturity, k, vol, Actual365Fixed())

i am using numpy matrix. is it wrapped into quantlib Matrix? Is there anything I am doing wrong

Thanks a lot

¿Fue útil?

Solución

Unfortunately, the QuantLib wrappers don't take numpy matrices. You'll have to convert them to simple lists of lists before passing them to the class constructor.

Another couple of issues I came across while trying your code:

  • you'll have to transpose the matrix. The len() of the outer list must equal the number of strikes and that of the inner lists must equal the number of maturities.
  • you're using a today's date which is later than most maturities (maybe a typo above, or a copy/paste gone awry?). Anyway, the constructor will raise an exception, so you'll have to fix your dates one way or the other. Also, you might want to set Settings.instance().evaluationDate to your today's date.
Licenciado bajo: CC-BY-SA con atribución
No afiliado a StackOverflow
scroll top