-
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.
finished developing regression strategies, basis functions, and makin…
…g it work with american monte carlo pricer
- Loading branch information
1 parent
4d6fac0
commit 9c8d22f
Showing
65 changed files
with
895 additions
and
380 deletions.
There are no files selected for viewing
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,21 @@ | ||
#ifndef GBM_STOCK_PRICE_MODEL_H | ||
#define GBM_STOCK_PRICE_MODEL_H | ||
|
||
#include <cmath> | ||
#include <random> | ||
#include <model/base_model.h> | ||
#include <market_data/interface_market_data.h> | ||
|
||
namespace OptionPricer { | ||
|
||
class GeometricBrownianMotionModel : public StockModel { | ||
public: | ||
GeometricBrownianMotionModel(const std::string& ticker, std::shared_ptr<IMarketData> marketData); | ||
|
||
[[nodiscard]] double simulatePriceAtMaturity(const double& T, const double& z) const override; | ||
[[nodiscard]] double simulateStepPrice(const double& dt, const double& z) const override; | ||
}; | ||
|
||
} | ||
|
||
#endif //GBM_STOCK_PRICE_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,17 @@ | ||
#ifndef BASE_DISTRIBUTION_H | ||
#define BASE_DISTRIBUTION_H | ||
|
||
#include <random> | ||
|
||
namespace OptionPricer { | ||
|
||
class Distribution { | ||
public: | ||
virtual ~Distribution(); | ||
[[nodiscard]] virtual double inv_cdf(const double& quantile) const = 0; | ||
virtual double operator()(std::mt19937& gen) = 0; | ||
}; | ||
|
||
} | ||
|
||
#endif //BASE_DISTRIBUTION_H |
23 changes: 23 additions & 0 deletions
23
include/random/distribution/standard_normal_distribution.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,23 @@ | ||
#ifndef STANDARD_NORMAL_DISTRIBUTION_H | ||
#define STANDARD_NORMAL_DISTRIBUTION_H | ||
|
||
#include <cmath> | ||
#include "random/distribution/base_distribution.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class StandardNormalDistribution final: public Distribution { | ||
public: | ||
explicit StandardNormalDistribution(); | ||
~StandardNormalDistribution() override; | ||
|
||
[[nodiscard]] double inv_cdf(const double& quantile) const override; | ||
double operator()(std::mt19937& gen) override; | ||
|
||
private: | ||
std::normal_distribution<> normal_dist_; | ||
}; | ||
|
||
} | ||
|
||
#endif //STANDARD_NORMAL_DISTRIBUTION_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,24 @@ | ||
#ifndef BASE_NUMBER_GENERATOR_H | ||
#define BASE_NUMBER_GENERATOR_H | ||
|
||
#include "random/distribution/base_distribution.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class NumberGenerarator { | ||
public: | ||
explicit NumberGenerarator(std::shared_ptr<Distribution> dist); | ||
explicit NumberGenerarator(std::shared_ptr<Distribution> dist, const unsigned int& seed); | ||
|
||
virtual ~NumberGenerarator(); | ||
|
||
virtual double generate(const int& step) = 0; | ||
|
||
protected: | ||
std::shared_ptr<Distribution> dist_; | ||
unsigned int seed_; | ||
}; | ||
|
||
} | ||
|
||
#endif //BASE_NUMBER_GENERATOR_H |
26 changes: 26 additions & 0 deletions
26
include/random/number_generator/base_quasi_random_generator.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,26 @@ | ||
#ifndef BASE_QUASI_RANDOM_GENERATOR_H | ||
#define BASE_QUASI_RANDOM_GENERATOR_H | ||
|
||
#include "random/number_generator/base_generator.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class QRNGenerator : public NumberGenerarator { | ||
public: | ||
explicit QRNGenerator(std::shared_ptr<Distribution> dist, const unsigned int& dim); | ||
QRNGenerator(std::shared_ptr<Distribution> dist, const unsigned int& seed, const unsigned int& dim); | ||
|
||
~QRNGenerator() override; | ||
|
||
unsigned int getDim() const; | ||
|
||
protected: | ||
void validateDim() const; | ||
|
||
unsigned int dim_; | ||
std::vector<double> point_; // Maybe use array | ||
}; | ||
|
||
} | ||
|
||
#endif //BASE_QUASI_RANDOM_GENERATOR_H |
24 changes: 24 additions & 0 deletions
24
include/random/number_generator/faure_quasi_random_generator.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,24 @@ | ||
#ifndef FAURE_QUASI_RANDOM_GENERATOR_H | ||
#define FAURE_QUASI_RANDOM_GENERATOR_H | ||
|
||
#include <boost/random/faure.hpp> | ||
#include "random/number_generator/base_quasi_random_generator.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class FaureGenerator final: public QRNGenerator { | ||
public: | ||
explicit FaureGenerator(std::shared_ptr<Distribution> dist, const unsigned int& dim); | ||
FaureGenerator(std::shared_ptr<Distribution> dist, const unsigned int& seed, const unsigned int& dim); | ||
|
||
~FaureGenerator() override; | ||
|
||
[[nodiscard]] double generate(const int& step) override; | ||
|
||
private: | ||
boost::random::faure faureQrng_; | ||
}; | ||
|
||
} | ||
|
||
#endif //FAURE_QUASI_RANDOM_GENERATOR_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,21 @@ | ||
#ifndef RANDOM_NUMBER_GENERATOR_H | ||
#define RANDOM_NUMBER_GENERATOR_H | ||
|
||
#include "random/number_generator/base_generator.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class RNGenerator final: public NumberGenerarator { | ||
public: | ||
explicit RNGenerator(std::shared_ptr<Distribution> dist); | ||
RNGenerator(std::shared_ptr<Distribution> dist, const unsigned int& seed); | ||
|
||
[[nodiscard]] double generate(const int& step) override; | ||
|
||
private: | ||
std::mt19937 generator_; // Mersenne Twister PRNG | ||
}; | ||
|
||
} | ||
|
||
#endif //RANDOM_NUMBER_GENERATOR_H |
24 changes: 24 additions & 0 deletions
24
include/random/number_generator/sobol_quasi_random_generator.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,24 @@ | ||
#ifndef SOBOL_QUASI_RANDOM_GENERATOR_H | ||
#define SOBOL_QUASI_RANDOM_GENERATOR_H | ||
|
||
#include <boost/random/sobol.hpp> | ||
#include "random/number_generator/base_quasi_random_generator.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class SobolGenerator final: public QRNGenerator { | ||
public: | ||
explicit SobolGenerator(std::shared_ptr<Distribution> dist, const unsigned int& dim); | ||
SobolGenerator(std::shared_ptr<Distribution> dist, const unsigned int& seed, const unsigned int& dim); | ||
|
||
~SobolGenerator() override; | ||
|
||
[[nodiscard]] double generate(const int& step) override; | ||
|
||
private: | ||
boost::random::sobol sobolQrng_; | ||
}; | ||
|
||
} | ||
|
||
#endif //SOBOL_QUASI_RANDOM_GENERATOR_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
21 changes: 21 additions & 0 deletions
21
include/solver/monte_carlo/basis_function/base_basis_function_strategy.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,21 @@ | ||
#ifndef BASE_BASIS_FUNCTION_H | ||
#define BASE_BASIS_FUNCTION_H | ||
|
||
#include <Eigen/Dense> | ||
|
||
namespace OptionPricer { | ||
|
||
class BasisFunctionStrategy { | ||
public: | ||
explicit BasisFunctionStrategy(const unsigned int& numberBasis); | ||
virtual ~BasisFunctionStrategy(); | ||
|
||
[[nodiscard]] virtual Eigen::MatrixXd generate(const Eigen::VectorXd& x) const = 0; | ||
|
||
protected: | ||
unsigned int numberBasis_; // Number of basis functions to generate | ||
}; | ||
|
||
} | ||
|
||
#endif //BASE_BASIS_FUNCTION_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,18 @@ | ||
#ifndef CHEBYSHEV_H | ||
#define CHEBYSHEV_H | ||
|
||
#include "solver/monte_carlo/basis_function/base_basis_function_strategy.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class ChebyshevBasisFunction : public BasisFunctionStrategy { | ||
public: | ||
using BasisFunctionStrategy::BasisFunctionStrategy; | ||
~ChebyshevBasisFunction() override; | ||
|
||
[[nodiscard]] Eigen::MatrixXd generate(const Eigen::VectorXd& x) const override; | ||
}; | ||
|
||
} | ||
|
||
#endif //CHEBYSHEV_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,18 @@ | ||
#ifndef LAGUERRE_H | ||
#define LAGUERRE_H | ||
|
||
#include "solver/monte_carlo/basis_function/base_basis_function_strategy.h" | ||
|
||
namespace OptionPricer { | ||
|
||
class LaguerreBasisFunction final : public BasisFunctionStrategy { | ||
public: | ||
using BasisFunctionStrategy::BasisFunctionStrategy; | ||
~LaguerreBasisFunction() override; | ||
|
||
[[nodiscard]] Eigen::MatrixXd generate(const Eigen::VectorXd& x) const override; | ||
}; | ||
|
||
} | ||
|
||
#endif //LAGUERRE_H |
Oops, something went wrong.