-
Notifications
You must be signed in to change notification settings - Fork 2
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
Showing
11 changed files
with
150 additions
and
53 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,23 @@ | ||
#pragma once | ||
|
||
#include "Pricer/kwBlackScholes.h" | ||
#include "Pricer/kwFd1d.h" | ||
|
||
|
||
namespace kw { | ||
|
||
class Fd1d_BlackScholes_Pricer : public Pricer | ||
{ | ||
private: | ||
BlackScholes_Pricer | ||
m_bs; | ||
Fd1d_Pricer | ||
m_fd1d; | ||
|
||
public: | ||
Error | ||
init(const Config& config) final; | ||
Error | ||
price(const vector<Option>& assets, vector<f64>& prices) final; | ||
}; | ||
} |
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,43 @@ | ||
#include "Pricer/kwF1d1_BlackScholes.h" | ||
|
||
using namespace kw; | ||
|
||
|
||
Error | ||
Fd1d_BlackScholes_Pricer::init(const Config& config) | ||
{ | ||
if (auto err = m_fd1d.init(config); !err.empty()) | ||
return "Fd1d_BlackScholes_Pricer::init : " + err; | ||
|
||
return ""; | ||
} | ||
|
||
Error | ||
Fd1d_BlackScholes_Pricer::price(const vector<Option>& assets, vector<f64>& prices) | ||
{ | ||
if (auto err = m_fd1d.price(assets, prices); !err.empty()) | ||
return "Fd1d_BlackScholes_Pricer::price : " + err; | ||
|
||
auto assets_ = assets; | ||
for (auto& asset : assets_) | ||
asset.e = false; | ||
|
||
vector<f64> pricesFd1d; | ||
pricesFd1d.resize(prices.size()); | ||
if (auto err = m_fd1d.price(assets_, pricesFd1d); !err.empty()) | ||
return "Fd1d_BlackScholes_Pricer::price : " + err; | ||
|
||
vector<f64> pricesBs; | ||
pricesBs.resize(prices.size()); | ||
|
||
BlackScholes_Pricer bs; | ||
if (auto err = m_bs.price(assets_, pricesBs); !err.empty()) | ||
return "Fd1d_BlackScholes_Pricer::price : " + err; | ||
|
||
|
||
for (auto i = 0; i < prices.size(); i++) { | ||
prices[i] += pricesBs[i] - pricesFd1d[i]; | ||
} | ||
|
||
return ""; | ||
} |
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