Posted by
Yan Kuang on
URL: http://quantlib.414.s1.nabble.com/reference-of-boost-shared-ptr-instead-of-Handle-tp7623p7639.html
Hi Luigi,
On the way home yesterday, I realissed
Create
method has to be virtual.
I have attached three files this time
us gbpliborswap as example. If this works, it will be better than the facotry
pattern I think.
Cheers,
Yan
Yan Kuang <[hidden email]> wrote on 14/09/2009 09:35:14
AM:
>
>
> Luigi Ballabio <[hidden email]> wrote on 12/09/2009
12:14:31 AM:
>
> > On Fri, 2009-09-11 at 14:28 +1000, Yan Kuang wrote:
> > > As I pointed in the last email, Aussie market has similar
situation
> > > (under 3 year swaps are different from 4 years and plus).
But that has
> > > been handle in the swap index.
> > >
> > > [...]
> > >
> > > There are may be a clever way of doing this, e.g., passing
in a
> > > generic swap index.
> > > The generic swap index should be able to tell you the market
> > > conventions for each tenor.
> >
> > We need some kind of factory. We could use a factory class,
but it's
> > probably overkill. We could just add a factory method to
SwapRate that
> > returns a correctly-instantiated rate of the same family but
with the
> > given tenor. Yan, do you want to give it a try?
> >
>
> Luigi,
>
> Thanks for the encouragement. I haven't done serious C++ programmingfor
quite
> a few years. I will certainly give it a go. However, I need to
> finish a validation
> project in two weeks times with quantlib, I then will take a two
> weeks leaves.
>
> I plan to use quantlib quite extensively to assist some exotic ir
> models validation
> in the next six months. Certainly I hope to contribute.
>
> Cheers,
> Yan
>
>
Hi Luigi,
I changed my mind, and had a go this afternoon. Basically I added a methods
in SwapIndex:
inline
boost::shared_ptr<SwapIndex> SwapIndex::Create(const
Period& new_tenor) {
return
boost::shared_ptr<SwapIndex> (new
SwapIndex(familyName_,
new_tenor,
fixingDays_,
currency_,
fixingCalendar_,
fixedLegTenor_,
fixedLegConvention_,
dayCounter_,
iborIndex_));
}
The object created is SwapIndex, not a subtype say GbpLiborSwapIsdaFix.
However I think
this is ok for two reasons: 1. One can always get the run time 'type' via
familyName.
2. Logically subtype like GbpLiborSwapIsdaFix
is almost like an instance (object) of SwapIndex.
I changed atmStrike method to:
Rate SwaptionVolatilityCube::atmStrike(const Date& optionD,
const Period& swapTenor) const {
return (swapIndexBase_->Create(swapTenor))->fixing(optionD);
}
Let me know what you think.
Cheers,
Yan
Please consider our environment before printing this email.
WARNING - This email and any attachments may be confidential. If received
in error, please delete and inform us by return email. Because emails and
attachments may be interfered with, may contain computer viruses or other
defects and may not be successfully replicated on other systems, you must
be cautious. Westpac cannot guarantee that what you receive is what we
sent. If you have any doubts about the authenticity of an email by Westpac,
please contact us immediately.
It is also important to check for viruses and defects before opening or
using attachments. Westpac's liability is limited to resupplying any affected
attachments.
This email and its attachments are not intended to constitute any form
of financial advice or recommendation of, or an offer to buy or offer to
sell, any security or other financial product. We recommend that you seek
your own independent legal or financial advice before proceeding with any
investment decision.
Westpac Institutional Bank is a division of Westpac Banking Corporation,
a company registered in New South Wales in Australia under the Corporations
Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom
by the Financial Services Authority and is registered at Cardiff in the
United Kingdom as Branch No. BR 106. Westpac operates in the United States
of America as a federally chartered branch, regulated by the Office of
the Comptroller of the Currency.
Westpac Banking Corporation ABN 33 007 457 141.[attachment "swapindex.hpp"
deleted by Yan Kuang/CORPAU/WBCAU/WBG] [attachment "swaptionvolcube.cpp"
deleted by Yan Kuang/CORPAU/WBCAU/WBG] ------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users
Please consider our environment before printing this email.
WARNING - This email and any attachments may be confidential. If received in error, please delete and inform us by return email. Because emails and attachments may be interfered with, may contain computer viruses or other defects and may not be successfully replicated on other systems, you must be cautious. Westpac cannot guarantee that what you receive is what we sent. If you have any doubts about the authenticity of an email by Westpac, please contact us immediately.
It is also important to check for viruses and defects before opening or using attachments. Westpac's liability is limited to resupplying any affected attachments.
This email and its attachments are not intended to constitute any form of financial advice or recommendation of, or an offer to buy or offer to sell, any security or other financial product. We recommend that you seek your own independent legal or financial advice before proceeding with any investment decision.
Westpac Institutional Bank is a division of Westpac Banking Corporation, a company registered in New South Wales in Australia under the Corporations Act 2001 (Cth). Westpac is authorised and regulated in the United Kingdom by the Financial Services Authority and is registered at Cardiff in the United Kingdom as Branch No. BR 106. Westpac operates in the United States of America as a federally chartered branch, regulated by the Office of the Comptroller of the Currency.
Westpac Banking Corporation ABN 33 007 457 141.
------------------------------------------------------------------------------
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
[hidden email]
https://lists.sourceforge.net/lists/listinfo/quantlib-users