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

Analytic pricing engine for American vanilla options with digital payoff. More...

#include <qle/pricingengines/analyticdigitalamericanengine.hpp>

+ Inheritance diagram for AnalyticDigitalAmericanEngine:
+ Collaboration diagram for AnalyticDigitalAmericanEngine:

Public Member Functions

 AnalyticDigitalAmericanEngine (ext::shared_ptr< GeneralizedBlackScholesProcess > process, const QuantLib::Date &payDate, const bool flipResults=false)
 
void calculate () const override
 
virtual bool knock_in () const override
 

Private Attributes

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

Detailed Description

Analytic pricing engine for American vanilla options with digital payoff.

Definition at line 37 of file analyticdigitalamericanengine.hpp.

Constructor & Destructor Documentation

◆ AnalyticDigitalAmericanEngine()

AnalyticDigitalAmericanEngine ( ext::shared_ptr< GeneralizedBlackScholesProcess >  process,
const QuantLib::Date &  payDate,
const bool  flipResults = false 
)

Definition at line 39 of file analyticdigitalamericanengine.hpp.

41 : QuantLib::AnalyticDigitalAmericanEngine(process), process_(std::move(process)), payDate_(payDate),
42 flipResults_(flipResults) {
43 registerWith(process_);
44 }
ext::shared_ptr< GeneralizedBlackScholesProcess > process_

Member Function Documentation

◆ calculate()

void calculate ( ) const
override

Definition at line 30 of file analyticdigitalamericanengine.cpp.

30 {
31
32 QuantLib::AnalyticDigitalAmericanEngine::calculate();
33
34 // If a payDate was provided (and is greater than the expiryDate)
35 if (payDate_ > arguments_.exercise->lastDate()) {
36 Rate payDateDiscount = process_->riskFreeRate()->discount(payDate_);
37 Rate expiryDateDiscount = process_->riskFreeRate()->discount(arguments_.exercise->lastDate());
38 Rate factor = payDateDiscount / expiryDateDiscount;
39 results_.value *= factor;
40
41 auto discTouchProbIt = results_.additionalResults.find("discountedTouchProbability");
42 if (discTouchProbIt != results_.additionalResults.end()) {
43 if (knock_in())
44 discTouchProbIt->second = boost::any_cast<Real>(discTouchProbIt->second) * factor;
45 else
46 discTouchProbIt->second = 1.0 - (factor * (1.0 - boost::any_cast<Real>(discTouchProbIt->second)));
47 }
48 }
49
50 if (flipResults_) {
51 // Invert spot, forward, strike
52 auto resToInvert = vector<string>({"spot", "forward", "strike"});
53 for (const string& res : resToInvert) {
54 auto it = results_.additionalResults.find(res);
55 if (it != results_.additionalResults.end())
56 it->second = 1. / boost::any_cast<Real>(it->second);
57 }
58
59 // Swap riskFreeDiscount and dividendDiscount
60 auto rfDiscountIt = results_.additionalResults.find("riskFreeDiscount");
61 auto divDiscountIt = results_.additionalResults.find("dividendDiscount");
62 if (rfDiscountIt != results_.additionalResults.end() && divDiscountIt != results_.additionalResults.end())
63 std::swap(rfDiscountIt->second, divDiscountIt->second);
64 }
65}
const Instrument::results * results_
Definition: cdsoption.cpp:81
Swap::arguments * arguments_
+ Here is the call graph for this function:

◆ knock_in()

virtual bool knock_in ( ) const
overridevirtual

Reimplemented in AnalyticDigitalAmericanKOEngine.

Definition at line 46 of file analyticdigitalamericanengine.hpp.

46{ return true; }
+ Here is the caller graph for this function:

Member Data Documentation

◆ process_

ext::shared_ptr<GeneralizedBlackScholesProcess> process_
private

Definition at line 49 of file analyticdigitalamericanengine.hpp.

◆ payDate_

QuantLib::Date payDate_
private

Definition at line 50 of file analyticdigitalamericanengine.hpp.

◆ flipResults_

bool flipResults_
private

Definition at line 51 of file analyticdigitalamericanengine.hpp.