Python: BlackIborCouponPricer; SwapRateHelper solved

View: New views
4 Messages — Rating Filter:   Alert me  

Python: BlackIborCouponPricer; SwapRateHelper solved

by Chuck Swiger-4 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message


Thanks to the example in Python/test I found I had a wrong argument
(using libor6m, instead of libor6m() ).

Made much more progress with Bonds.cpp, now I'm stuck on how to
Pythonize:

        // Coupon pricers
         boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);


It exists in Quantlib-0.9.7/ql/cashflows/couponpricer.cpp, the closest I
can find in quantlib_wrap.cpp is  IborCoupon

Any clue appreciated..


--Chuck



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users

Re: Python: BlackIborCouponPricer; SwapRateHelper solved

by Luigi Ballabio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Thu, 2009-09-17 at 12:53 -0400, Charles Swiger wrote:
> Made much more progress with Bonds.cpp, now I'm stuck on how to
> Pythonize:
>
> // Coupon pricers
>          boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);
>
>
> It exists in Quantlib-0.9.7/ql/cashflows/couponpricer.cpp, the closest I
> can find in quantlib_wrap.cpp is  IborCoupon

That's not exported. It should be added to the SWIG interface. Do you
want to have a try? You should export
shared_ptr<FloatingRateCouponPricer>. You can look at the way
shared_ptr<CashFlow> is exported to get an example. I'll be here if you
get stuck.

Luigi


--

Olmstead's Law:
After all is said and done, a hell of a lot more is said
than done.



------------------------------------------------------------------------------
Come build with us! The BlackBerry® Developer Conference in SF, CA
is the only developer event you need to attend this year. Jumpstart your
developing skills, take BlackBerry mobile applications to market and stay
ahead of the curve. Join us from November 9-12, 2009. Register now!
http://p.sf.net/sfu/devconf
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users

Re: Python: BlackIborCouponPricer; SwapRateHelper solved

by Lluís Pujol :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hi,

I am also interested on using floating Rate Bonds on Python.
(unfortunatelly I am novice to both Quantlib and SWIG)

I am trying to create the shared_ptr<FloatingRateCouponPricer>
interface, as suggested I followed the shared_ptr<CashFlow>, but I got
lost with the private member and also the registerWith that cointains
IborCouponPricer.

This is the C++ version of IborCouponPricer, any help would be appreciated.

class IborCouponPricer : public FloatingRateCouponPricer {
      public:
        IborCouponPricer(const Handle<OptionletVolatilityStructure>& v =
                                         
Handle<OptionletVolatilityStructure>())
        : capletVol_(v) { registerWith(capletVol_); }

        Handle<OptionletVolatilityStructure> capletVolatility() const{
            return capletVol_;
        }
        void setCapletVolatility(
                            const Handle<OptionletVolatilityStructure>& v =
                                   
Handle<OptionletVolatilityStructure>()) {
            unregisterWith(capletVol_);
            capletVol_ = v;
            registerWith(capletVol_);
            update();
        }
      private:
        Handle<OptionletVolatilityStructure> capletVol_;
    };

Lluís


Luigi Ballabio escribió:

> On Thu, 2009-09-17 at 12:53 -0400, Charles Swiger wrote:
>  
>> Made much more progress with Bonds.cpp, now I'm stuck on how to
>> Pythonize:
>>
>> // Coupon pricers
>>          boost::shared_ptr<IborCouponPricer> pricer(new BlackIborCouponPricer);
>>
>>
>> It exists in Quantlib-0.9.7/ql/cashflows/couponpricer.cpp, the closest I
>> can find in quantlib_wrap.cpp is  IborCoupon
>>    
>
> That's not exported. It should be added to the SWIG interface. Do you
> want to have a try? You should export
> shared_ptr<FloatingRateCouponPricer>. You can look at the way
> shared_ptr<CashFlow> is exported to get an example. I'll be here if you
> get stuck.
>
> Luigi
>
>
>  



__________ Información de ESET NOD32 Antivirus, versión de la base de firmas de virus 4589 (20091109) __________

ESET NOD32 Antivirus ha comprobado este mensaje.

http://www.eset.com



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users

Re: Python: BlackIborCouponPricer; SwapRateHelper solved

by Luigi Ballabio :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

On Mon, 2009-11-09 at 21:13 +0100, Lluís Pujol wrote:
> I am trying to create the shared_ptr<FloatingRateCouponPricer>
> interface, as suggested I followed the shared_ptr<CashFlow>, but I got
> lost with the private member and also the registerWith that cointains
> IborCouponPricer.

Sorry for the delay.

I meant something like this for the base class:

%ignore IborCouponPricer;
class IborCouponPricer {
  public:
    // export the public interface here, if needed
};

%template(IborCouponPricer) boost::shared_ptr<IborCouponPricer>;

After that,
1) you'll add the setPricer() method to IborCoupon taking a
boost::shared_ptr<IborCouponPricer>;
2) you'll export the constructors for the concrete pricers such as
BlackIborCouponPricer with something like:

%{
typedef boost::shared_ptr<IborCouponPricer> BlackIborCouponPricerPtr;
%}

%rename(BlackIborCouponPricer) BlackIborCouponPricerPtr;
class BlackIborCouponPricerPtr
: public boost::shared_ptr<IborCouponPricer> {
  public:
    %extend {
        BlackIborCouponPricerPtr(...) {
            return new BlackIborCouponPricerPtr(
                new BlackIborCouponPricer(...));
        }
    }
};


Luigi




--

Discontent is the first necessity of progress.
-- Thomas A. Edison



------------------------------------------------------------------------------
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.  http://p.sf.net/sfu/bobj-july
_______________________________________________
QuantLib-users mailing list
QuantLib-users@...
https://lists.sourceforge.net/lists/listinfo/quantlib-users