Hi,
I have the following code: Real t = nextEvent();//years Date eventDate = start+t*Years; but this seems to be incorrect, because Period rounds t to an Integer. In the opposite direction I can get a year fraction using dayCounter.yearFraction(). How can I get a date, when I know the start date and the year fraction (possibly greater than 1)? Regards, Grzegorz ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi,
unfortunately, there's no defined inverse for yearFraction. You can probably get close by writing Date eventDate = start+(t*365)*Days; but then again, depending on the day counter that 365 might have to be 360 instead. You'll have to check what day counter is used in nextEvent(). Luigi On Mon, Feb 18, 2013 at 12:01 PM, Grześ Andruszkiewicz <[hidden email]> wrote: > Hi, > > I have the following code: > > Real t = nextEvent();//years > Date eventDate = start+t*Years; > > but this seems to be incorrect, because Period rounds t to an Integer. > In the opposite direction I can get a year fraction using > dayCounter.yearFraction(). How can I get a date, when I know the start > date and the year fraction (possibly greater than 1)? > > Regards, > Grzegorz > > ------------------------------------------------------------------------------ > The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, > is your hub for all things parallel software development, from weekly thought > leadership blogs to news, videos, case studies, tutorials, tech docs, > whitepapers, evaluation guides, and opinion stories. Check out the most > recent posts - join the conversation now. http://goparallel.sourceforge.net/ > _______________________________________________ > QuantLib-dev mailing list > [hidden email] > https://lists.sourceforge.net/lists/listinfo/quantlib-dev ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi Luigi,
I am using ActualActual currently. The reason is that I am dealing with natural events. Does it make sense? I have an end date as well, so would it make sense to use: Integer days = t*dayCounter.dayCount(start, end)/dayCounter.yearFraction(start, end); ? Ciao, Grzegorz On 18 February 2013 11:13, Luigi Ballabio <[hidden email]> wrote: > Hi, > unfortunately, there's no defined inverse for yearFraction. You > can probably get close by writing > > Date eventDate = start+(t*365)*Days; > > but then again, depending on the day counter that 365 might have to be > 360 instead. You'll have to check what day counter is used in > nextEvent(). > > Luigi > > On Mon, Feb 18, 2013 at 12:01 PM, Grześ Andruszkiewicz > <[hidden email]> wrote: >> Hi, >> >> I have the following code: >> >> Real t = nextEvent();//years >> Date eventDate = start+t*Years; >> >> but this seems to be incorrect, because Period rounds t to an Integer. >> In the opposite direction I can get a year fraction using >> dayCounter.yearFraction(). How can I get a date, when I know the start >> date and the year fraction (possibly greater than 1)? >> >> Regards, >> Grzegorz >> >> ------------------------------------------------------------------------------ >> The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, >> is your hub for all things parallel software development, from weekly thought >> leadership blogs to news, videos, case studies, tutorials, tech docs, >> whitepapers, evaluation guides, and opinion stories. Check out the most >> recent posts - join the conversation now. http://goparallel.sourceforge.net/ >> _______________________________________________ >> QuantLib-dev mailing list >> [hidden email] >> https://lists.sourceforge.net/lists/listinfo/quantlib-dev ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
So that it gives you some kind of conversion factor? Possibly.
However, if you want to deal with days, are you sure you don't want nextEvent() to return a Date instead? Luigi On Mon, Feb 18, 2013 at 12:21 PM, Grześ Andruszkiewicz <[hidden email]> wrote: > Hi Luigi, > > I am using ActualActual currently. The reason is that I am dealing > with natural events. Does it make sense? > > I have an end date as well, so would it make sense to use: > > Integer days = t*dayCounter.dayCount(start, > end)/dayCounter.yearFraction(start, end); > > ? > > Ciao, > Grzegorz > > On 18 February 2013 11:13, Luigi Ballabio <[hidden email]> wrote: >> Hi, >> unfortunately, there's no defined inverse for yearFraction. You >> can probably get close by writing >> >> Date eventDate = start+(t*365)*Days; >> >> but then again, depending on the day counter that 365 might have to be >> 360 instead. You'll have to check what day counter is used in >> nextEvent(). >> >> Luigi >> >> On Mon, Feb 18, 2013 at 12:01 PM, Grześ Andruszkiewicz >> <[hidden email]> wrote: >>> Hi, >>> >>> I have the following code: >>> >>> Real t = nextEvent();//years >>> Date eventDate = start+t*Years; >>> >>> but this seems to be incorrect, because Period rounds t to an Integer. >>> In the opposite direction I can get a year fraction using >>> dayCounter.yearFraction(). How can I get a date, when I know the start >>> date and the year fraction (possibly greater than 1)? >>> >>> Regards, >>> Grzegorz >>> >>> ------------------------------------------------------------------------------ >>> The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, >>> is your hub for all things parallel software development, from weekly thought >>> leadership blogs to news, videos, case studies, tutorials, tech docs, >>> whitepapers, evaluation guides, and opinion stories. Check out the most >>> recent posts - join the conversation now. http://goparallel.sourceforge.net/ >>> _______________________________________________ >>> QuantLib-dev mailing list >>> [hidden email] >>> https://lists.sourceforge.net/lists/listinfo/quantlib-dev ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Hi, The problem is that all the models seem to be continuous time, so I have to convert to days at some point... (luckily I don't have to worry about hours). Regards, On 18 Feb 2013 12:07, "Luigi Ballabio" <[hidden email]> wrote:
So that it gives you some kind of conversion factor? Possibly. ------------------------------------------------------------------------------ The Go Parallel Website, sponsored by Intel - in partnership with Geeknet, is your hub for all things parallel software development, from weekly thought leadership blogs to news, videos, case studies, tutorials, tech docs, whitepapers, evaluation guides, and opinion stories. Check out the most recent posts - join the conversation now. http://goparallel.sourceforge.net/ _______________________________________________ QuantLib-dev mailing list [hidden email] https://lists.sourceforge.net/lists/listinfo/quantlib-dev |
Free forum by Nabble | Edit this page |