Logo
Fully annotated reference manual - version 1.8.12
Loading...
Searching...
No Matches
Public Member Functions | Private Attributes | List of all members
AnalyticDoubleBarrierBinaryEngine Class Reference

Analytic pricing engine for double barrier binary options. More...

#include <qle/pricingengines/analyticdoublebarrierbinaryengine.hpp>

+ Inheritance diagram for AnalyticDoubleBarrierBinaryEngine:
+ Collaboration diagram for AnalyticDoubleBarrierBinaryEngine:

Public Member Functions

 AnalyticDoubleBarrierBinaryEngine (ext::shared_ptr< GeneralizedBlackScholesProcess > gbsp, const Date &payDate, const bool flipResults=false)
 
void calculate () const override
 

Private Attributes

ext::shared_ptr< GeneralizedBlackScholesProcess > process_
 
Date payDate_
 
bool flipResults_
 

Detailed Description

Analytic pricing engine for double barrier binary options.

Definition at line 34 of file analyticdoublebarrierbinaryengine.hpp.

Constructor & Destructor Documentation

◆ AnalyticDoubleBarrierBinaryEngine()

AnalyticDoubleBarrierBinaryEngine ( ext::shared_ptr< GeneralizedBlackScholesProcess >  gbsp,
const Date &  payDate,
const bool  flipResults = false 
)
explicit

Definition at line 36 of file analyticdoublebarrierbinaryengine.hpp.

38 : QuantLib::AnalyticDoubleBarrierBinaryEngine(gbsp), process_(std::move(gbsp)), payDate_(payDate),
39 flipResults_(flipResults) {
40 registerWith(process_);
41 }
ext::shared_ptr< GeneralizedBlackScholesProcess > process_

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 27 of file analyticdoublebarrierbinaryengine.cpp.

27 {
28
29 QuantLib::AnalyticDoubleBarrierBinaryEngine::calculate();
30
31 // If a payDate was provided (and is greater than the expiryDate)
32 if (payDate_ > arguments_.exercise->lastDate()) {
33 Rate payDateDiscount = process_->riskFreeRate()->discount(payDate_);
34 Rate expiryDateDiscount = process_->riskFreeRate()->discount(arguments_.exercise->lastDate());
35 Rate factor = payDateDiscount / expiryDateDiscount;
36 results_.value *= factor;
37 }
38
39 if (flipResults_) {
40 // Invert spot, costOfCarry
41 auto it = results_.additionalResults.find("spot");
42 if (it != results_.additionalResults.end())
43 it->second = 1. / boost::any_cast<Real>(it->second);
44 it = results_.additionalResults.find("costOfCarry");
45 if (it != results_.additionalResults.end())
46 it->second = -1. * boost::any_cast<Real>(it->second);
47
48 // Swap riskFreeRate and dividendYield
49 auto rfDiscountIt = results_.additionalResults.find("riskFreeRate");
50 auto divDiscountIt = results_.additionalResults.find("dividendYield");
51 if (rfDiscountIt != results_.additionalResults.end() && divDiscountIt != results_.additionalResults.end())
52 std::swap(rfDiscountIt->second, divDiscountIt->second);
53
54 // Invert and swap barrierLow and barrierHigh
55 auto barrierLowIt = results_.additionalResults.find("barrierLow");
56 auto barrierHighIt = results_.additionalResults.find("barrierHigh");
57 if (barrierLowIt != results_.additionalResults.end() && barrierHighIt != results_.additionalResults.end()) {
58 barrierLowIt->second = 1. / boost::any_cast<Real>(barrierLowIt->second);
59 barrierHighIt->second = 1. / boost::any_cast<Real>(barrierHighIt->second);
60 std::swap(barrierLowIt->second, barrierHighIt->second);
61 }
62 }
63}
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_

Member Data Documentation

◆ process_

ext::shared_ptr<GeneralizedBlackScholesProcess> process_
private

Definition at line 45 of file analyticdoublebarrierbinaryengine.hpp.

◆ payDate_

Date payDate_
private

Definition at line 46 of file analyticdoublebarrierbinaryengine.hpp.

◆ flipResults_

bool flipResults_
private

Definition at line 47 of file analyticdoublebarrierbinaryengine.hpp.