-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
0055281
commit 7241271
Showing
76 changed files
with
1,238 additions
and
662 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
#ifndef BASE_CIR_DISCRETIZATION_H | ||
#define BASE_CIR_DISCRETIZATION_H | ||
|
||
#include <algorithm> | ||
|
||
namespace OptionPricer { | ||
|
||
class CIRDiscretization { | ||
public: | ||
virtual ~CIRDiscretization(); | ||
virtual double apply(const double &v, const double &dt, | ||
const double &kappa, const double &theta, | ||
const double &sigma_v, const double &z) const = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif //BASE_CIR_DISCRETIZATION_H |
17 changes: 17 additions & 0 deletions
17
include/model/discretization/explicit_euler_cir_discretization.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
#ifndef EXPLICIT_EULER_CIR_DISCRETIZATION_H | ||
#define EXPLICIT_EULER_CIR_DISCRETIZATION_H | ||
|
||
#include "model/discretization/base_cir_discretization.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class CIRExplicitEulerDiscretization : public CIRDiscretization { | ||
public: | ||
double apply(const double &v, const double &dt, | ||
const double &kappa, const double &theta, | ||
const double &sigma_v, const double &z) const override; | ||
}; | ||
|
||
} | ||
|
||
#endif //EXPLICIT_EULER_CIR_DISCRETIZATION_H |
16 changes: 16 additions & 0 deletions
16
include/model/discretization/milstein_cir_discretization.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,16 @@ | ||
#ifndef MILSTEIN_CIR_DISCRETIZATION_H | ||
#define MILSTEIN_CIR_DISCRETIZATION_H | ||
|
||
#include "model/discretization/explicit_euler_cir_discretization.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class CIRMilsteinDiscretization : public CIRExplicitEulerDiscretization { | ||
public: | ||
double apply(const double &v, const double &dt, const double &kappa, const double &theta, const double &sigma_v, | ||
const double &z) const override; | ||
}; | ||
|
||
} | ||
|
||
#endif //MILSTEIN_CIR_DISCRETIZATION_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
#ifndef HESTON_MODEL_H | ||
#define HESTON_MODEL_H | ||
|
||
#include "model/base_model.h" | ||
#include "model/discretization/base_cir_discretization.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class HestonModel final : public StockModel { | ||
public: | ||
HestonModel(const std::string& ticker, | ||
std::shared_ptr<IMarketData> marketData, | ||
std::shared_ptr<NumberGenerator> generator, | ||
const double& kappa, const double& theta, const double& sigma_v, | ||
const double& rho, const double& v0, | ||
std::shared_ptr<CIRDiscretization> varDiscretization = nullptr); | ||
~HestonModel() override; | ||
|
||
[[nodiscard]] double simulatePriceAtMaturity(const double& T) const override; | ||
[[nodiscard]] std::vector<double> simulatePrices(const double& T) const override; | ||
|
||
private: | ||
double kappa_; // Mean reversion rate | ||
double theta_; // Long-term variance | ||
double sigma_v_; // Volatility of variance | ||
double rho_; // Correlation between the two Brownian motions | ||
double v0_; // Initial variance | ||
std::shared_ptr<CIRDiscretization> varDiscretization_; // Discretization scheme for the variance process | ||
}; | ||
|
||
} | ||
|
||
|
||
|
||
|
||
#endif //HESTON_MODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
#ifndef KOU_MODEL_H | ||
#define KOU_MODEL_H | ||
|
||
#include "model/base_model.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class KouModel final: public StockModel { | ||
public: | ||
/* This class implements the Kou model which is an extension of the Merton Jump Diffusion model | ||
* which introduce asymmetry of jumps for modeling the skewness and kurtosis of stock returns. | ||
*/ | ||
KouModel(const std::string& ticker, | ||
std::shared_ptr<IMarketData> marketData, | ||
std::shared_ptr<NumberGenerator> generator, | ||
const double& lambda, const double& p, | ||
const double& eta1, const double& eta2); | ||
|
||
~KouModel() override; | ||
|
||
double simulatePriceAtMaturity(const double& T) const override; | ||
std::vector<double> simulatePrices(const double& T) const override; | ||
|
||
private: | ||
double lambda_; // Jump intensity | ||
double p_; // Probability of upward jump | ||
double eta1_; // Rate of upward jumps | ||
double eta2_; // Rate of downward jumps | ||
}; | ||
|
||
} | ||
|
||
#endif //KOU_MODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
#ifndef MERTON_JUMP_DIFFUSION_MODEL_H | ||
#define MERTON_JUMP_DIFFUSION_MODEL_H | ||
|
||
#include "model/base_model.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class MertonJumpDiffusionModel final : public StockModel { | ||
public: | ||
MertonJumpDiffusionModel(const std::string& ticker, | ||
std::shared_ptr<IMarketData> marketData, | ||
std::shared_ptr<NumberGenerator> generator, | ||
const double& lambda, const double& muJ, const double& sigmaJ); | ||
|
||
~MertonJumpDiffusionModel() override; | ||
|
||
double simulatePriceAtMaturity(const double& T) const override; | ||
std::vector<double> simulatePrices(const double& T) const override; | ||
|
||
private: | ||
double lambda_; // intensity of the Poisson process (mean number of jumps per unit time) | ||
double muJ_; // mean of the jump size distribution | ||
double sigmaJ_; // standard deviation of the jump size distribution | ||
}; | ||
|
||
} | ||
|
||
#endif // MERTON_JUMP_DIFFUSION_MODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
#ifndef VARIANCE_GAMMA_MODEL_H | ||
#define VARIANCE_GAMMA_MODEL_H | ||
|
||
#include "model/base_model.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class VarianceGammaModel : public StockModel { | ||
public: | ||
VarianceGammaModel(const std::string& ticker, | ||
std::shared_ptr<IMarketData> marketData, | ||
std::shared_ptr<NumberGenerator> generator, | ||
const double& sigma, const double& nu, const double& theta); | ||
|
||
~VarianceGammaModel() override; | ||
|
||
[[nodiscard]] double simulatePriceAtMaturity(const double& T) const override; | ||
[[nodiscard]] std::vector<double> simulatePrices(const double& T) const override; | ||
|
||
private: | ||
double sigma_; // Volatility parameter | ||
double nu_; // Variance rate of the Gamma process | ||
double theta_; // Drift of the Brownian motion | ||
double omega_; // Drift correction term | ||
}; | ||
|
||
} | ||
|
||
#endif //VARIANCE_GAMMA_MODEL_H |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.