QuantLib: a free/open-source library for quantitative finance
fully annotated source code - version 1.34
Loading...
Searching...
No Matches
riskyassetswapoption.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) 2009 Roland Lichters
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
20#include <ql/event.hpp>
23#include <utility>
24
25namespace QuantLib {
26
27 RiskyAssetSwapOption::RiskyAssetSwapOption(ext::shared_ptr<RiskyAssetSwap> asw,
28 const Date& expiry,
29 Rate marketSpread,
30 Volatility spreadVolatility)
31 : asw_(std::move(asw)), expiry_(expiry), marketSpread_(marketSpread),
32 spreadVolatility_(spreadVolatility) {}
33
36 }
37
38
40 Real w;
41 if (asw_->fixedPayer()) // strike receiver = asw call = spread put
42 w = -1.0;
43 else
44 w = 1.0;
45
47 Time expiryTime = Actual365Fixed().yearFraction(today, expiry_);
48 Real stdDev = spreadVolatility_ * std::sqrt(expiryTime);
49 Real d = (asw_->spread() - marketSpread_) / stdDev;
50 Real A0 = asw_->nominal() * asw_->floatAnnuity();
51
52 NPV_ = A0 * stdDev * (w*d * CumulativeNormalDistribution()(w*d)
54 }
55
56}
Actual/365 (Fixed) day count convention.
Cumulative normal distribution function.
Concrete date class.
Definition: date.hpp:125
Time yearFraction(const Date &, const Date &, const Date &refPeriodStart=Date(), const Date &refPeriodEnd=Date()) const
Returns the period between two dates as a fraction of year.
Definition: daycounter.hpp:128
virtual bool hasOccurred(const Date &refDate=Date(), ext::optional< bool > includeRefDate=ext::nullopt) const
returns true if an event has already occurred before a date
Definition: event.cpp:28
Normal distribution function.
void performCalculations() const override
bool isExpired() const override
returns whether the instrument might have value greater than zero.
RiskyAssetSwapOption(ext::shared_ptr< RiskyAssetSwap > asw, const Date &expiry, Rate marketSpread, Volatility spreadVolatility)
ext::shared_ptr< RiskyAssetSwap > asw_
DateProxy & evaluationDate()
the date at which pricing is to be performed.
Definition: settings.hpp:147
static Settings & instance()
access to the unique instance
Definition: singleton.hpp:104
Base class for events associated with a given date.
Date d
Real Time
continuous quantity with 1-year units
Definition: types.hpp:62
QL_REAL Real
real number
Definition: types.hpp:50
Real Volatility
volatility
Definition: types.hpp:78
Real Rate
interest rates
Definition: types.hpp:70
Definition: any.hpp:35
STL namespace.
normal, cumulative and inverse cumulative distributions
option on risky asset swap