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

#include <ored/marketdata/strike.hpp>

+ Inheritance diagram for AtmStrike:
+ Collaboration diagram for AtmStrike:

Public Member Functions

 AtmStrike ()
 Default constructor. More...
 
 AtmStrike (QuantLib::DeltaVolQuote::AtmType atmType, boost::optional< QuantLib::DeltaVolQuote::DeltaType > deltaType=boost::none)
 
- Public Member Functions inherited from BaseStrike
virtual ~BaseStrike ()
 
virtual void fromString (const std::string &strStrike)=0
 Populate the Strike object from strStrike. More...
 
virtual std::string toString () const =0
 Write the Strike object to string. More...
 

Inspectors

QuantLib::DeltaVolQuote::AtmType atmType_
 
boost::optional< QuantLib::DeltaVolQuote::DeltaType > deltaType_
 
class boost::serialization::access
 Serialization. More...
 
QuantLib::DeltaVolQuote::AtmType atmType () const
 Return the ATM type. More...
 
boost::optional< QuantLib::DeltaVolQuote::DeltaType > deltaType () const
 Return the delta type. More...
 
void fromString (const std::string &strStrike) override
 
std::string toString () const override
 
bool equal_to (const BaseStrike &other) const override
 Override in derived classes to compare specific Strikes. More...
 
void check () const
 Perform validation. More...
 
template<class Archive >
void serialize (Archive &ar, const unsigned int version)
 

Additional Inherited Members

virtual bool equal_to (const BaseStrike &other) const =0
 Override in derived classes to compare specific Strikes. More...
 

Detailed Description

Strike implementation for an at-the-money strike of various types.

Definition at line 149 of file strike.hpp.

Constructor & Destructor Documentation

◆ AtmStrike() [1/2]

AtmStrike ( )

Default constructor.

Definition at line 98 of file strike.cpp.

98: atmType_(DeltaVolQuote::AtmSpot) {}
QuantLib::DeltaVolQuote::AtmType atmType_
Definition: strike.hpp:193

◆ AtmStrike() [2/2]

AtmStrike ( QuantLib::DeltaVolQuote::AtmType  atmType,
boost::optional< QuantLib::DeltaVolQuote::DeltaType >  deltaType = boost::none 
)

Explicit constructor. Note that:

  • an atmType of AtmNull throws an error.
  • if atmType is AtmDeltaNeutral, a deltaType is needed.
  • if atmType is not AtmDeltaNeutral, deltaType should not be provided.
  • if atmType is AtmPutCall50, deltaType must be DeltaVolQuote::Fwd.

Member Function Documentation

◆ atmType()

DeltaVolQuote::AtmType atmType ( ) const

Return the ATM type.

Definition at line 105 of file strike.cpp.

105{ return atmType_; }
+ Here is the caller graph for this function:

◆ deltaType()

boost::optional< DeltaVolQuote::DeltaType > deltaType ( ) const

Return the delta type.

Definition at line 107 of file strike.cpp.

107{ return deltaType_; }
boost::optional< QuantLib::DeltaVolQuote::DeltaType > deltaType_
Definition: strike.hpp:194
+ Here is the caller graph for this function:

◆ fromString()

void fromString ( const std::string &  strStrike)
overridevirtual

Populate AtmStrike object from strStrike.

The strStrike is expected to be of the form: ATM / AtmSpot|AtmFwd|AtmDeltaNeutral|AtmVegaMax|AtmGammaMax|AtmPutCall50 followed by an optional / DEL / Spot|Fwd|PaSpot|PaFwd to specify the delta if it is needed. An exception is thrown if strStrike is not of this form and cannot be parsed properly.

Implements BaseStrike.

Definition at line 109 of file strike.cpp.

109 {
110
111 // Expect strStrike of form:
112 // "ATM / AtmSpot|AtmFwd|AtmDeltaNeutral|AtmVegaMax|AtmGammaMax|AtmPutCall50"
113 // with an optional following "/ DEL / Spot|Fwd|PaSpot|PaFwd"
114 vector<string> tokens;
115 boost::split(tokens, strStrike, boost::is_any_of("/"));
116 QL_REQUIRE(tokens.size() == 2 || tokens.size() == 4, "AtmStrike::fromString expects 2 or 4 tokens.");
117 QL_REQUIRE(tokens[0] == "ATM", "AtmStrike::fromString expects 1st token to equal 'ATM'.");
118
119 atmType_ = parseAtmType(tokens[1]);
120
121 deltaType_ = boost::none;
122 if (tokens.size() == 4) {
123 QL_REQUIRE(tokens[2] == "DEL", "AtmStrike::fromString expects 3rd token to equal 'DEL'.");
124 deltaType_ = parseDeltaType(tokens[3]);
125 }
126
127 check();
128}
void check() const
Perform validation.
Definition: strike.cpp:154
DeltaVolQuote::AtmType parseAtmType(const std::string &s)
Convert text to QuantLib::DeltaVolQuote::AtmType.
Definition: parsers.cpp:746
DeltaVolQuote::DeltaType parseDeltaType(const std::string &s)
Convert text to QuantLib::DeltaVolQuote::DeltaType.
Definition: parsers.cpp:763
+ Here is the call graph for this function:

◆ toString()

string toString ( ) const
overridevirtual

Writes the AtmStrike object to string.

The string representation of the DeltaStrike object is of the form ATM / AtmSpot|AtmFwd|AtmDeltaNeutral|AtmVegaMax|AtmGammaMax|AtmPutCall50 followed by an optional / DEL / Spot|Fwd|PaSpot|PaFwd if the delta type has been populated.

Implements BaseStrike.

Definition at line 130 of file strike.cpp.

130 {
131
132 // Write strike of form:
133 // "ATM / AtmSpot|AtmFwd|AtmDeltaNeutral|AtmVegaMax|AtmGammaMax|AtmPutCall50"
134 // with an optional following "/ DEL / Spot|Fwd|PaSpot|PaFwd" if delta type is populated.
135 ostringstream oss;
136 oss << "ATM/" << atmType_;
137
138 if (deltaType_) {
139 oss << "/DEL/" << (*deltaType_);
140 }
141
142 return oss.str();
143}
+ Here is the caller graph for this function:

◆ equal_to()

bool equal_to ( const BaseStrike other) const
overrideprotectedvirtual

Override in derived classes to compare specific Strikes.

Implements BaseStrike.

Definition at line 145 of file strike.cpp.

145 {
146 if (const AtmStrike* p = dynamic_cast<const AtmStrike*>(&other)) {
147 return (atmType_ == p->atmType()) &&
148 ((!deltaType_ && !p->deltaType()) || (deltaType_ && p->deltaType() && (*deltaType_ == *p->deltaType())));
149 } else {
150 return false;
151 }
152}
AtmStrike()
Default constructor.
Definition: strike.cpp:98

◆ check()

void check ( ) const
private

Perform validation.

Definition at line 154 of file strike.cpp.

154 {
155 QL_REQUIRE(atmType_ != DeltaVolQuote::AtmNull, "AtmStrike type must not be AtmNull.");
156 if (atmType_ == DeltaVolQuote::AtmDeltaNeutral) {
157 QL_REQUIRE(deltaType_, "If AtmStrike type is AtmDeltaNeutral, we need a delta type.");
158 } else {
159 QL_REQUIRE(!deltaType_, "If AtmStrike type is not AtmDeltaNeutral, delta type should not be given.");
160 }
161 if (atmType_ == DeltaVolQuote::AtmPutCall50) {
162 QL_REQUIRE(deltaType_ && *deltaType_ == DeltaVolQuote::Fwd,
163 "If AtmStrike type is AtmPutCall50, delta type must be AtmFwd.");
164 }
165}
+ Here is the caller graph for this function:

◆ serialize()

template void serialize ( Archive &  ar,
const unsigned int  version 
)
private

Definition at line 303 of file strike.cpp.

303 {
304 ar& boost::serialization::base_object<BaseStrike>(*this);
305 ar& atmType_;
306 ar& deltaType_;
307}

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialization.

Definition at line 200 of file strike.hpp.

Member Data Documentation

◆ atmType_

QuantLib::DeltaVolQuote::AtmType atmType_
private

Definition at line 193 of file strike.hpp.

◆ deltaType_

boost::optional<QuantLib::DeltaVolQuote::DeltaType> deltaType_
private

Definition at line 194 of file strike.hpp.