1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110
|
/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
/*
Copyright (C) 2010 Michael Heckl
This file is part of QuantLib, a free-software/open-source library
for financial quantitative analysts and developers - http://quantlib.org/
QuantLib is free software: you can redistribute it and/or modify it
under the terms of the QuantLib license. You should have received a
copy of the license along with this program; if not, please email
<quantlib-dev@lists.sf.net>. The license is also available online at
<http://quantlib.org/license.shtml>.
This program is distributed in the hope that it will be useful, but WITHOUT
ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
FOR A PARTICULAR PURPOSE. See the license for more details.
*/
#include <ql/experimental/processes/vegastressedblackscholesprocess.hpp>
namespace QuantLib {
VegaStressedBlackScholesProcess::VegaStressedBlackScholesProcess(
const Handle<Quote>& x0,
const Handle<YieldTermStructure>& dividendTS,
const Handle<YieldTermStructure>& riskFreeTS,
const Handle<BlackVolTermStructure>& blackVolTS,
Time lowerTimeBorderForStressTest,
Time upperTimeBorderForStressTest,
Real lowerAssetBorderForStressTest,
Real upperAssetBorderForStressTest,
Real stressLevel,
const boost::shared_ptr<discretization>& disc)
: GeneralizedBlackScholesProcess(x0, dividendTS, riskFreeTS,
blackVolTS, disc),
lowerTimeBorderForStressTest_(lowerTimeBorderForStressTest),
upperTimeBorderForStressTest_(upperTimeBorderForStressTest),
lowerAssetBorderForStressTest_(lowerAssetBorderForStressTest),
upperAssetBorderForStressTest_(upperAssetBorderForStressTest),
stressLevel_(stressLevel) {}
// returns the lower time border for the stress test
Real VegaStressedBlackScholesProcess::getLowerTimeBorderForStressTest() const {
return lowerTimeBorderForStressTest_;
}
// returns the upper time border for the stress test
Real VegaStressedBlackScholesProcess::getUpperTimeBorderForStressTest() const {
return upperTimeBorderForStressTest_;
}
// returns the lower asset border for the stress test
Real VegaStressedBlackScholesProcess::getLowerAssetBorderForStressTest() const {
return lowerAssetBorderForStressTest_;
}
// returns the upper asset border for the stress test
Real VegaStressedBlackScholesProcess::getUpperAssetBorderForStressTest() const {
return upperAssetBorderForStressTest_;
}
// returns the stress Level
Real VegaStressedBlackScholesProcess::getStressLevel() const {
return stressLevel_;
}
// set the lower time border for the stress test
void VegaStressedBlackScholesProcess::setLowerTimeBorderForStressTest(Time LTB) {
lowerTimeBorderForStressTest_ = LTB;
update();
}
// set the upper time border for the stress test
void VegaStressedBlackScholesProcess::setUpperTimeBorderForStressTest(Time UTB) {
upperTimeBorderForStressTest_ = UTB;
update();
}
// set the lower asset border for the stress test
void VegaStressedBlackScholesProcess::setLowerAssetBorderForStressTest(Real LAB) {
lowerAssetBorderForStressTest_ = LAB;
update();
}
// set the upper asset border for the stress test
void VegaStressedBlackScholesProcess::setUpperAssetBorderForStressTest(Real UBA) {
upperAssetBorderForStressTest_ = UBA;
update();
}
// set the stress Level
void VegaStressedBlackScholesProcess::setStressLevel(Real SL) {
stressLevel_ = SL;
update();
}
Real VegaStressedBlackScholesProcess::diffusion(Time t, Real x) const {
if (lowerTimeBorderForStressTest_ <= t && t <= upperTimeBorderForStressTest_
&& lowerAssetBorderForStressTest_ <= x && x <= upperAssetBorderForStressTest_) {
return GeneralizedBlackScholesProcess::diffusion(t, x)+stressLevel_;
} else {
return GeneralizedBlackScholesProcess::diffusion(t, x);
}
}
}
|