QuantLib Python - Solving a Swap rate for a particular NPV

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|  
Report Content as Inappropriate

QuantLib Python - Solving a Swap rate for a particular NPV

TSchulz85
Hi, is it possible to solve the swap rate for a particular NPV?
So lets say I would like to know where the swap rate would be for NPV of $100k. Of course I could use the par swap and estimate with the DV01, but is there a direct way?
Also I tried to solve via SLSQP minimisation (would anyhow not be the most elegant way I assume..), but I got the following error:


  File "<ipython-input-42-ff4834398b56>", line 1, in <module>
    minimize(solve_swap, 0.01, method='SLSQP', options={'disp': False, 'maxiter': 300, 'ftol': 1e-08})

  File "C:\ProgramData\Anaconda2_64bit\lib\site-packages\scipy\optimize\_minimize.py", line 458, in minimize
    constraints, callback=callback, **options)

  File "C:\ProgramData\Anaconda2_64bit\lib\site-packages\scipy\optimize\slsqp.py", line 370, in _minimize_slsqp
    raise ValueError("Objective function must return a scalar")

ValueError: Objective function must return a scalar

Thanks,
Tobias
Loading...