Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
time.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2022 Quaternion Risk Management Ltd
3 All rights reserved.
4
5 This file is part of ORE, a free-software/open-source library
6 for transparent pricing and risk analysis - http://opensourcerisk.org
7
8 ORE is free software: you can redistribute it and/or modify it
9 under the terms of the Modified BSD License. You should have received a
10 copy of the license along with this program.
11 The license is also available online at <http://opensourcerisk.org>
12
13 This program is distributed on the basis that it will form a useful
14 contribution to risk analytics and model standardisation, but WITHOUT
15 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or
16 FITNESS FOR A PARTICULAR PURPOSE. See the license for more details.
17*/
18
19/*! \file qle/utilities/time.hpp
20 \brief time related utilities.
21*/
22
23#pragma once
24
25#include <ql/time/date.hpp>
26#include <ql/time/daycounter.hpp>
27#include <ql/time/period.hpp>
28
29namespace QuantExt {
30
31/* convert period to time using 1Y = 1, 1M = 1/12, 1W = 7/365, 1D = 1/365 */
32QuantLib::Real periodToTime(const QuantLib::Period& p);
33
34/*! Imply cds index term from start and end date. If no reasonable term can be implied, 0 * Days is returned */
35QuantLib::Period implyIndexTerm(const QuantLib::Date& startDate, const QuantLib::Date& endDate);
36
37/* For t >= 0 get the largest date d such that dc.yearFraction(refDate, d) <= t. If the condition
38 dc.yearFraction(refDate, d+1) > t is not met, an exception is thrown. */
39QuantLib::Date lowerDate(const QuantLib::Real t, const QuantLib::Date& refDate, const QuantLib::DayCounter& dc);
40
41/* Find period such that the difference to length is < 1.0 / 365.25 and prefer unit years > months > days */
42QuantLib::Period tenorFromLength(const QuantLib::Real length);
43
44/* Get the accumulated daylight savings correction between two dates, both treated as "included" for different
45 locations (see http://www.webexhibits.org/daylightsaving)
46 Null no daylight saving, returns 0 always
47 US Start: Second Sunday in March
48 End : First Sunday in November
49*/
50QuantLib::Integer daylightSavingCorrection(const std::string& location, const QuantLib::Date& start,
51 const QuantLib::Date& end);
52
53} // namespace QuantExt
QuantLib::Period tenorFromLength(const QuantLib::Real length)
Definition: time.cpp:94
Real periodToTime(const Period &p)
Definition: time.cpp:37
QuantLib::Date lowerDate(const Real t, const QuantLib::Date &refDate, const QuantLib::DayCounter &dc)
Definition: time.cpp:66
QuantLib::Integer daylightSavingCorrection(const std::string &location, const QuantLib::Date &start, const QuantLib::Date &end)
Definition: time.cpp:102
QuantLib::Period implyIndexTerm(const Date &startDate, const Date &endDate)
Definition: time.cpp:52