Frage

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

War es hilfreich?

Lösung

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.
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top