Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
capfloor.cpp
Go to the documentation of this file.
1/*
2 Copyright (C) 2016 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
21
22#include <ql/pricingengines/capfloor/bacheliercapfloorengine.hpp>
23#include <ql/pricingengines/capfloor/blackcapfloorengine.hpp>
24
25#include <boost/make_shared.hpp>
26
27namespace ore {
28namespace data {
29
30QuantLib::ext::shared_ptr<PricingEngine> CapFloorEngineBuilder::engineImpl(const std::string& index) {
31 string ccyCode = parseIborIndex(index)->currency().code();
32 Handle<YieldTermStructure> yts = market_->discountCurve(ccyCode, configuration(MarketContext::pricing));
33 Handle<OptionletVolatilityStructure> ovs = market_->capFloorVol(index, configuration(MarketContext::pricing));
34
35 switch (ovs->volatilityType()) {
36 case ShiftedLognormal:
37 LOG("Build BlackCapFloorEngine for index " << index);
38 return QuantLib::ext::make_shared<BlackCapFloorEngine>(yts, ovs, ovs->displacement());
39 break;
40 case Normal:
41 LOG("Build BachelierCapFloorEngine for index " << index);
42 return QuantLib::ext::make_shared<BachelierCapFloorEngine>(yts, ovs);
43 break;
44 default:
45 QL_FAIL("Caplet volatility type, " << ovs->volatilityType() << ", not covered in EngineFactory");
46 return nullptr; // avoid gcc warning
47 break;
48 }
49}
50} // namespace data
51} // namespace ore
builder that returns an engine to price a cap or floor on IBOR instrument
QuantLib::ext::shared_ptr< PricingEngine > engineImpl(const std::string &index) override
Definition: capfloor.cpp:30
QuantLib::ext::shared_ptr< Market > market_
const string & configuration(const MarketContext &key)
Return a configuration (or the default one if key not found)
QuantLib::ext::shared_ptr< IborIndex > parseIborIndex(const string &s, const Handle< YieldTermStructure > &h)
Convert std::string to QuantLib::IborIndex.
Classes and functions for log message handling.
@ data
Definition: log.hpp:77
#define LOG(text)
Logging Macro (Level = Notice)
Definition: log.hpp:552
Serializable Credit Default Swap.
Definition: namespaces.docs:23