Login  Register

Re: swig some class are not wrapped

Posted by archlight on Mar 03, 2011; 4:15am
URL: http://quantlib.414.s1.nabble.com/swig-some-class-are-not-wrapped-tp6058p6062.html

Hi

  I tried Python swig. I can build and install it and run sample code (swap.i) without problem.

  However after I modified volalilities.i to add class SwaptionVolCube2, I got error below (I can build and install)
-------------things I change in volalilities.i ---------------------------------------------------------
%include indexes.i ( I add this header otherwise it won't compile)

%{
using QuantLib::SwaptionVolCube2;
typedef boost::shared_ptr<SwaptionVolatilityStructure>
    SwaptionVolCube2Ptr;
%}

%rename(SwaptionVolCube2) SwaptionVolCube2Ptr;
class SwaptionVolCube2Ptr
    : public boost::shared_ptr<SwaptionVolatilityStructure> {
  public:
    %extend {
        SwaptionVolCube2Ptr(const Handle<SwaptionVolatilityStructure>& atmVolStructure,
                            const std::vector<Period>& optionTenors,
                            const std::vector<Period>& swapTenors,
                            const std::vector<Spread>& strikeSpreads,
                            const std::vector<std::vector<Handle<Quote> > >& volSpreads,
                            const boost::shared_ptr<SwapIndex>& swapIndexBase,
                            const boost::shared_ptr<SwapIndex>& shortSwapIndexBase,
                            bool vegaWeightedSmileFit) {
            return new SwaptionVolCube2Ptr(
                new SwaptionVolCube2(atmVolStructure,optionTenors,swapTenors,
                                     strikeSpreads,volSpreads, swapIndexBase, shortSwapIndexBase, vegaWeightedSmileFit));
        }
    }
};

---------------------------------------------------------------------------------------------------
  Traceback (most recent call last):
  File "swap.py", line 215, in <module>
    report(spot,'depo-fut-swap')
  File "swap.py", line 200, in report
    formatRate(swap.fairSpread(),4),
  File "C:\Python27\lib\site-packages\QuantLib\QuantLib.py", line 10406, in fair
Spread
    def fairSpread(self): return _QuantLib.VanillaSwap_fairSpread(self)
RuntimeError: result not available


    I have no idea how to proceed. your help is much appreciated.

Regards
Jeff Burnett wrote
Because of the way Quantlib is written, not every class or method signature is exposed via SWiG. You will probably have to extend the SWiG files, which isn't too hard once you get the hang of it.

archlight wrote
Hi all,

    I am working on a project of visualizing quantlib, like tree, term structure. However I cannot initialize some of class e.g EqualJumpsBinomialTree. it seems not wrapped in C#. I need a way to access lattice. Any suggestion?

   Thanks for your time

archlight
Regards