Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
optionpricesurface.hpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2019 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 optionpricesurface.hpp
20 \brief Surface to store option prices
21 */
22
23#pragma once
24
25#include <ql/math/interpolations/linearinterpolation.hpp>
26#include <ql/termstructure.hpp>
27#include <ql/time/calendars/nullcalendar.hpp>
28#include <ql/time/date.hpp>
30
31namespace QuantExt {
32
33//! Option Price Surface based on sparse matrix.
34//! \ingroup termstructures
35class OptionPriceSurface : public QuantLib::TermStructure,
36 public OptionInterpolator2d<QuantLib::Linear, QuantLib::Linear> {
37
38public:
39 OptionPriceSurface(const QuantLib::Date& referenceDate, const std::vector<QuantLib::Date>& dates,
40 const std::vector<QuantLib::Real>& strikes, const std::vector<QuantLib::Real>& prices,
41 const QuantLib::DayCounter& dayCounter,
42 const QuantLib::Calendar& calendar = QuantLib::NullCalendar())
43 : QuantLib::TermStructure(referenceDate, calendar, dayCounter),
44 OptionInterpolator2d<QuantLib::Linear, QuantLib::Linear>(referenceDate, dayCounter, dates, strikes, prices){};
45
46 //! \name TermStructure interface
47 //@{
48 QuantLib::Date maxDate() const override { return QuantLib::Date::maxDate(); }
49 const QuantLib::Date& referenceDate() const override { return OptionInterpolator2d::referenceDate(); }
50 QuantLib::DayCounter dayCounter() const override { return OptionInterpolator2d::dayCounter(); }
51 //@}
52
53 QuantLib::Real price(QuantLib::Time t, QuantLib::Real strike) const { return getValue(t, strike); };
54 QuantLib::Real price(QuantLib::Date d, QuantLib::Real strike) const { return getValue(d, strike); };
55};
56
57} // namespace QuantExt
std::vector< std::vector< QuantLib::Real > > strikes() const
QuantLib::DayCounter dayCounter() const
QuantLib::Real getValue(QuantLib::Time t, QuantLib::Real strike) const override
const QuantLib::Date & referenceDate() const
QuantLib::DayCounter dayCounter() const override
QuantLib::Date maxDate() const override
QuantLib::Real price(QuantLib::Time t, QuantLib::Real strike) const
QuantLib::Real price(QuantLib::Date d, QuantLib::Real strike) const
OptionPriceSurface(const QuantLib::Date &referenceDate, const std::vector< QuantLib::Date > &dates, const std::vector< QuantLib::Real > &strikes, const std::vector< QuantLib::Real > &prices, const QuantLib::DayCounter &dayCounter, const QuantLib::Calendar &calendar=QuantLib::NullCalendar())
const QuantLib::Date & referenceDate() const override