QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
blackscholescalculator.cpp
Go to the documentation of this file.
1/* -*- mode: c++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2
3/*
4 Copyright (C) 2006 Ferdinando Ametrano
5
6 This file is part of QuantLib, a free-software/open-source library
7 for financial quantitative analysts and developers - http://quantlib.org/
8
9 QuantLib is free software: you can redistribute it and/or modify it
10 under the terms of the QuantLib license. You should have received a
11 copy of the license along with this program; if not, please email
12 <quantlib-dev@lists.sf.net>. The license is also available online at
13 <http://quantlib.org/license.shtml>.
14
15 This program is distributed in the hope that it will be useful, but WITHOUT
16 ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
17 FOR A PARTICULAR PURPOSE. See the license for more details.
18*/
19
21
22namespace QuantLib {
23
25 const ext::shared_ptr<StrikedTypePayoff>& payoff,
26 Real spot,
27 DiscountFactor growth,
28 Real stdDev,
29 DiscountFactor discount)
30 : BlackCalculator(payoff, spot*growth/discount, stdDev, discount),
31 spot_(spot), growth_(growth)
32 {
33 QL_REQUIRE(spot_>0.0,
34 "spot (" << spot_ << ") must be positive");
36 "growth (" << growth_ << ") must be positive");
37 }
38
40 Real strike,
41 Real spot,
42 DiscountFactor growth,
43 Real stdDev,
44 DiscountFactor discount)
45 : BlackCalculator(type, strike, spot*growth/discount, stdDev, discount),
46 spot_(spot), growth_(growth)
47 {
48 QL_REQUIRE(spot_>0.0,
49 "spot (" << spot_ << ") must be positive");
51 "growth (" << growth_ << ") must be positive");
52 }
53
54}
Black-Scholes formula calculator class.
Black 1976 calculator class.
BlackScholesCalculator(const ext::shared_ptr< StrikedTypePayoff > &payoff, Real spot, DiscountFactor growth, Real stdDev, DiscountFactor discount)
#define QL_REQUIRE(condition, message)
throw an error if the given pre-condition is not verified
Definition: errors.hpp:117
QL_REAL Real
real number
Definition: types.hpp:50
Real DiscountFactor
discount factor between dates
Definition: types.hpp:66
ext::shared_ptr< QuantLib::Payoff > payoff
Definition: any.hpp:35