Coverage Report

Created: 2025-08-28 06:30

/src/quantlib/ql/discretizedasset.cpp
Line
Count
Source (jump to first uncovered line)
1
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3
/*
4
 Copyright (C) 2001, 2002, 2003 Sadruddin Rejeb
5
 Copyright (C) 2004 StatPro Italia srl
6
7
 This file is part of QuantLib, a free-software/open-source library
8
 for financial quantitative analysts and developers - http://quantlib.org/
9
10
 QuantLib is free software: you can redistribute it and/or modify it
11
 under the terms of the QuantLib license.  You should have received a
12
 copy of the license along with this program; if not, please email
13
 <quantlib-dev@lists.sf.net>. The license is also available online at
14
 <http://quantlib.org/license.shtml>.
15
16
 This program is distributed in the hope that it will be useful, but WITHOUT
17
 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
18
 FOR A PARTICULAR PURPOSE.  See the license for more details.
19
*/
20
21
#include <ql/discretizedasset.hpp>
22
23
namespace QuantLib {
24
25
0
    void DiscretizedOption::postAdjustValuesImpl() {
26
        /* In the real world, with time flowing forward, first
27
           any payment is settled and only after options can be
28
           exercised. Here, with time flowing backward, options
29
           must be exercised before performing the adjustment.
30
        */
31
0
        underlying_->partialRollback(time());
32
0
        underlying_->preAdjustValues();
33
0
        Size i;
34
0
        switch (exerciseType_) {
35
0
          case Exercise::American:
36
0
            if (time_ >= exerciseTimes_[0] && time_ <= exerciseTimes_[1])
37
0
                applyExerciseCondition();
38
0
            break;
39
0
          case Exercise::Bermudan:
40
0
          case Exercise::European:
41
0
            for (i=0; i<exerciseTimes_.size(); i++) {
42
0
                Time t = exerciseTimes_[i];
43
0
                if (t >= 0.0 && isOnTime(t))
44
0
                    applyExerciseCondition();
45
0
            }
46
0
            break;
47
0
          default:
48
0
            QL_FAIL("invalid exercise type");
49
0
        }
50
0
        underlying_->postAdjustValues();
51
0
    }
52
53
}
54