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

#include <ored/marketdata/strike.hpp>

+ Inheritance diagram for MoneynessStrike:
+ Collaboration diagram for MoneynessStrike:

Public Types

enum class  Type { Spot , Forward }
 

Public Member Functions

 MoneynessStrike ()
 Default constructor. More...
 
 MoneynessStrike (Type type, QuantLib::Real moneyness)
 Explicit constructor. More...
 
- 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

Type type_
 
QuantLib::Real moneyness_
 
class boost::serialization::access
 Serialization. More...
 
Type type () const
 Return the moneyness type. More...
 
QuantLib::Real moneyness () const
 Return the moneyness level. 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...
 
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 where the strike is described by a moneyness type and a moneyness level.

Definition at line 206 of file strike.hpp.

Member Enumeration Documentation

◆ Type

enum class Type
strong

The MoneynessStrike type.

  • When the moneyness type is Spot, the moneyness level will be interpreted as the implicit strike divided by the spot value.
  • When the moneyness type is Forward, the moneyness level will be interpreted as the implicit strike divided by the forward value.
Enumerator
Spot 
Forward 

Definition at line 214 of file strike.hpp.

Constructor & Destructor Documentation

◆ MoneynessStrike() [1/2]

Default constructor.

Definition at line 167 of file strike.cpp.

◆ MoneynessStrike() [2/2]

MoneynessStrike ( Type  type,
QuantLib::Real  moneyness 
)

Explicit constructor.

Member Function Documentation

◆ type()

MoneynessStrike::Type type ( ) const

Return the moneyness type.

Definition at line 171 of file strike.cpp.

171{ return type_; }
+ Here is the caller graph for this function:

◆ moneyness()

Real moneyness ( ) const

Return the moneyness level.

Definition at line 173 of file strike.cpp.

173{ return moneyness_; }
QuantLib::Real moneyness_
Definition: strike.hpp:248
+ Here is the caller graph for this function:

◆ fromString()

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

Populate MoneynessStrike object from strStrike.

The strStrike is expected to be of the form MNY / Spot|Fwd / MONEYNESS_VALUE.

Implements BaseStrike.

Definition at line 175 of file strike.cpp.

175 {
176
177 // Expect strStrike of form "MNY / Spot|Fwd / MONEYNESS_VALUE"
178 vector<string> tokens;
179 boost::split(tokens, strStrike, boost::is_any_of("/"));
180 QL_REQUIRE(tokens.size() == 3, "MoneynessStrike::fromString expects 3 tokens.");
181 QL_REQUIRE(tokens[0] == "MNY", "MoneynessStrike::fromString expects 1st token to equal 'MNY'.");
182
183 type_ = parseMoneynessType(tokens[1]);
184 moneyness_ = parseReal(tokens[2]);
185}
Real parseReal(const string &s)
Convert text to Real.
Definition: parsers.cpp:112
MoneynessStrike::Type parseMoneynessType(const string &type)
Parse MoneynessStrike::Type from type.
Definition: strike.cpp:252
+ Here is the call graph for this function:

◆ toString()

string toString ( ) const
overridevirtual

Writes the MoneynessStrike object to string.

The string representation of the MoneynessStrike object is of the form MNY / Spot|Fwd / MONEYNESS_VALUE.

Implements BaseStrike.

Definition at line 187 of file strike.cpp.

187 {
188
189 // Write strike of form "MNY / Spot|Fwd / MONEYNESS_VALUE"
190 ostringstream oss;
191 oss << "MNY/" << type_ << "/" << to_string(moneyness_);
192 return oss.str();
193}
std::string to_string(const LocationInfo &l)
Definition: ast.cpp:28
+ Here is the call graph for this function:
+ 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 195 of file strike.cpp.

195 {
196 if (const MoneynessStrike* p = dynamic_cast<const MoneynessStrike*>(&other)) {
197 return type_ == p->type() && close(moneyness_, p->moneyness());
198 } else {
199 return false;
200 }
201}
MoneynessStrike()
Default constructor.
Definition: strike.cpp:167

◆ serialize()

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

Definition at line 309 of file strike.cpp.

309 {
310 ar& boost::serialization::base_object<BaseStrike>(*this);
311 ar& type_;
312 ar& moneyness_;
313}

Friends And Related Function Documentation

◆ boost::serialization::access

friend class boost::serialization::access
friend

Serialization.

Definition at line 251 of file strike.hpp.

Member Data Documentation

◆ type_

Type type_
private

Definition at line 247 of file strike.hpp.

◆ moneyness_

QuantLib::Real moneyness_
private

Definition at line 248 of file strike.hpp.