Last fixing date of a swap with respect to today [Kind of urgent]

classic Classic list List threaded Threaded
6 messages Options
Reply | Threaded
Open this post in threaded view
|

Last fixing date of a swap with respect to today [Kind of urgent]

Leon Sit
Hi all

In quantlib, is there a way to query the last fixing date of a swap
with respect to the evaluation date?

Thanks tons

Leon

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Exposing additional functions to Python

Seb Venus
Hi,

I would like to ask about the SWIG module for Python. I noticed that each function/object is defined in QuantLib.py and quantlib_wrap.cpp, and that the latter is automatically generated. What are the steps to expose additional functionality to Python? I am not familiar with SWIG...

Thanks in advance for your help.

Seb
------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Exposing additional functions to Python

Bojan Nikolic

Seb Venus <[hidden email]> writes:

> I would like to ask about the SWIG module for Python. I noticed that
> each function/object is defined in QuantLib.py and quantlib_wrap.cpp,
> and that the latter is automatically generated.

They are both automatically generated I think

> What are the steps to
> expose additional functionality to Python? I am not familiar with
> SWIG...

You need to add to the SWIG interface files which have the "*.i"
extension.

Best,
Bojan

--
Bojan Nikolic          ||          http://www.bnikolic.co.uk

------------------------------------------------------------------------------
Protect Your Site and Customers from Malware Attacks
Learn about various malware tactics and how to avoid them. Understand
malware threats, the impact they can have on your business, and how you
can protect your company and customers by using code signing.
http://p.sf.net/sfu/oracle-sfdevnl
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Last fixing date of a swap with respect to today [Kind of urgent]

Luigi Ballabio
In reply to this post by Leon Sit

On Jan 20, 2011, at 8:03 PM, Leon Sit wrote:
> In quantlib, is there a way to query the last fixing date of a swap
> with respect to the evaluation date?

Yes, but it's kind of complex.  You'll have to:
- ask the swap for its floating leg; if it's a VanillaSwap, call its  
floatingLeg() method; if it's a generic Swap, use the leg(i) method by  
passing the correct index;
- get a pointer to the last CashFlow; that's leg.back()
- downcast it to FloatingRateCoupon; that's
coupon = boost::dynamic_pointer_cast<FloatingRateCoupon>(leg.back());
- now you can use its fixingDate() method.

Luigi


------------------------------------------------------------------------------
Special Offer-- Download ArcSight Logger for FREE (a $49 USD value)!
Finally, a world-class log management solution at an even better price-free!
Download using promo code Free_Logger_4_Dev2Dev. Offer expires
February 28th, so secure your free ArcSight Logger TODAY!
http://p.sf.net/sfu/arcsight-sfd2d
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Exposing additional functions to Python

Seb Venus
In reply to this post by Bojan Nikolic
Thanks a lot for your help.

I am having some trouble in exposing the class LinearLeastSquaresRegression
since it is dependent on templates (I think this issue was discussed at the
recent QuantLib forum).

Could someone please give advice on the best way to do this? So far I just
have this, which I wrote in a new .i file:

%{
using QuantLib::TimeGrid;
using QuantLib::LinearLeastSquaresRegression;
using QuantLib::EarlyExerciseTraits<Path>;
%}

template <class ArgumentType>
class LinearLeastSquaresRegression  {
public:
    %extend                      
         LinearLeastSquaresRegression( const std::vector<ArgumentType>& x,
                                       const std::vector<Real>& y,
                                       const
std::vector<boost::function1<Real, ArgumentType> > & v);

                                                               
         const Array& coefficients()   const;            
         const Array& residuals()      const;            
         const Array& standardErrors() const;
};

%template(LinearLeastSquaresRegression1)
LinearLeastSquaresRegression<EarlyExerciseTraits<Path> >;

Cheers,

Seb

-----Original Message-----
From: Bojan Nikolic [mailto:[hidden email]]
Sent: 20 January 2011 21:14
To: Seb Venus
Cc: [hidden email]
Subject: Re: [Quantlib-users] Exposing additional functions to Python


Seb Venus <[hidden email]> writes:

> I would like to ask about the SWIG module for Python. I noticed that
> each function/object is defined in QuantLib.py and quantlib_wrap.cpp,
> and that the latter is automatically generated.

They are both automatically generated I think

> What are the steps to
> expose additional functionality to Python? I am not familiar with
> SWIG...

You need to add to the SWIG interface files which have the "*.i"
extension.

Best,
Bojan

--
Bojan Nikolic          ||          http://www.bnikolic.co.uk


------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Reply | Threaded
Open this post in threaded view
|

Re: Exposing additional functions to Python

Bojan Nikolic

In your example the syntax of "%extend" is wrong -- you need braces
after it and you need to %include the relevant .hpp files. You need to
look at some of the other .i files in more detail or consult the SWIG
manual.

You also picked a function which is not the easiest to wrap -- one of
the arguments is a vector of boost function objects, so you will need to
have a way of creating these too.

Best,
Bojan

--
Bojan Nikolic          ||          http://www.bnikolic.co.uk/ql

------------------------------------------------------------------------------
Free Software Download: Index, Search & Analyze Logs and other IT data in
Real-Time with Splunk. Collect, index and harness all the fast moving IT data
generated by your applications, servers and devices whether physical, virtual
or in the cloud. Deliver compliance at lower cost and gain new business
insights. http://p.sf.net/sfu/splunk-dev2dev 
_______________________________________________
QuantLib-users mailing list
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users