Restructure C++ core into cpp module and package bindings.

Move the pricing engine sources out of src/ into cpp/, add the closed-form engine and pybind wiring, and align tests/build targets with the new project layout.

Made-with: Cursor
This commit is contained in:
David Doebel
2026-04-02 16:30:33 +02:00
parent 61df0b425d
commit 087a2f0d74
53 changed files with 803 additions and 195 deletions

25
cpp/MonteCarloEngine.cpp Normal file
View File

@@ -0,0 +1,25 @@
/**
* @file MonteCarloEngine.cpp
* @brief Monte Carlo mean estimator with discounting.
*/
#include "MonteCarloEngine.hpp"
#include <iostream>
#include "Instrument.hpp"
#include "Statistics.hpp"
double MonteCarloEngine::calculate(const Instrument &instrument) const {
// parameters
double T = instrument.maturity();
double spot = process_->data().spot();
Statistics stats;
auto rNumbers = rng_->nextGaussianVector(numPaths_);
std::vector<double> payoffs(numPaths_);
for (std::size_t i = 0; i < numPaths_; ++i) {
double terminalPrice = process_->step(0.0,spot,T,rNumbers[i]);
double payoff = instrument.payoff()(terminalPrice);
stats.dump(payoff);
}
return stats.mean() * process_->data().yield_curve().discount(T);
}