-
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
6082d81
commit 7dcf7ad
Showing
6 changed files
with
46 additions
and
3 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,12 @@ | ||
#ifndef FACTORY_DIGITAL_OPTION_H | ||
#define FACTORY_DIGITAL_OPTION_H | ||
|
||
#include "option/single_path/factory_single_path_option.h" | ||
|
||
namespace OptionPricer { | ||
class DigitalOptionFactory final: public SinglePathOptionFactory { | ||
std::shared_ptr<SinglePathOption> createOption(const ParameterObject& params, const std::string& type) override; | ||
}; | ||
} | ||
|
||
#endif //FACTORY_DIGITAL_OPTION_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 |
---|---|---|
|
@@ -9,6 +9,4 @@ namespace OptionPricer { | |
}; | ||
} | ||
|
||
|
||
|
||
#endif //FACTORY_EUROPEAN_OPTION_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,30 @@ | ||
#include "option/single_path/factory_digital_option.h" | ||
|
||
#include <market_data/market_data.h> | ||
#include "option/single_path/digital_option.h" | ||
#include "payoff/single_strike/factory_payoff_digital.h" | ||
|
||
namespace OptionPricer { | ||
std::shared_ptr<SinglePathOption> DigitalOptionFactory::createOption(const ParameterObject ¶ms, | ||
const std::string &type) { | ||
auto marketData = MarketData::getInstance(); | ||
std::shared_ptr<SinglePathOption> eurOption = nullptr; | ||
|
||
try { | ||
PayoffDigitalFactory payoffFactory; | ||
auto payoff = payoffFactory.createPayoff(type, params.getParameter<double>("K")); | ||
eurOption = std::shared_ptr<SinglePathOption>(new DigitalOption( | ||
params.getParameter<std::string>("ticker"), | ||
std::move(payoff), | ||
params.getParameter<double>("T"), | ||
marketData | ||
)); | ||
} catch (const std::invalid_argument& e) { | ||
const std::string err = std::string(e.what()) + "\n" + invalidParams("Digital Option"); | ||
throw std::invalid_argument(err); // Re-throw the caught exception | ||
} | ||
|
||
eurOption->initialize(); | ||
return eurOption; | ||
} | ||
} |
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