RE: How to convert among timeunits in Per iod object

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

RE: How to convert among timeunits in Per iod object

Perissin Francesco
Message
I would calculate the end dates of each period, with the plus method applied to the starting date (i.e. today.plus(myPeriod)) ). Now, with the start and the end dates, you calculate the time between them:
 
Time myTime = Actual365().yearFraction(today, endDay)
 
Is this what you were looking for?
 
ciao
Francesco 
-----Original Message-----
From: amar singh [mailto:[hidden email]]
Sent: mercoledì, 10 dicembre 2003 21:43
To: quantlib users
Subject: [Quantlib-users] How to convert among timeunits in Period object

I have a vector of Period objects of different time units - months/years.

 How can I easily convert this to another vector of timelength in year?

eg. consider the following vector available:

 std::vector<Period> swaptionMaturities;
        swaptionMaturities.push_back(Period(1, Months));
        swaptionMaturities.push_back(Period(3, Months));
        swaptionMaturities.push_back(Period(6, Months));
        swaptionMaturities.push_back(Period(1, Years));
        swaptionMaturities.push_back(Period(2, Years));
        swaptionMaturities.push_back(Period(3, Years));
        swaptionMaturities.push_back(Period(4, Years));
        swaptionMaturities.push_back(Period(5, Years));
        swaptionMaturities.push_back(Period(7, Years));
        swaptionMaturities.push_back(Period(10, Years));

 
I want to have a vector
std::vector<Time> times;
 which has timeunits in year.
 
I looked at Period / Date Classes, but there does not seem to be any method for conversion.
 
 
Can someone please help?
 
Thanks ,
Amar


Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard
############################### DISCLAIMER #################################

This message (including any attachments) is confidential and may be
privileged. If you have received it by mistake please notify the sender by
return e-mail and delete this message from your system. Any unauthorised
use or dissemination of this message in whole or in part is strictly
prohibited. Please note that e-mails are susceptible to change. Banca del
Gottardo (including its group companies) shall not be liable for the
improper or incomplete transmission of the information contained in this
communication nor for any delay in its receipt or damage to your system.
Banca del Gottardo (or its group companies) does not guarantee that the
integrity of this communication has been maintained nor that this
communication is free of viruses, interceptions or interference.

############################################################################
Reply | Threaded
Open this post in threaded view
|

RE: How to convert among timeunits in Per iod object

amar singh
 Wow, a neat trick! Francesco ,thanks very much for your help.
 
Regards,
Amar


Do you Yahoo!?
Protect your identity with Yahoo! Mail AddressGuard