Adapt Yield Curve and Volatility Surface and Market Data, to be better compatible with unit test.
Some checks failed
C++ CI / build (push) Has been cancelled

This commit is contained in:
David Doebel
2026-03-12 12:10:13 +01:00
parent 08298439ea
commit f98de4d0a3
13 changed files with 50 additions and 80 deletions

View File

@@ -1,2 +0,0 @@
// Minimal TU to satisfy CMake for test stubs
#include "FakeMarketData.hpp"

View File

@@ -1,38 +0,0 @@
//
// Created by David Doebel on 07.03.2026.
//
#ifndef QUANTENGINE_FAKEMARKETDATA_HPP
#define QUANTENGINE_FAKEMARKETDATA_HPP
#include "MarketData.hpp"
#include "FlatYieldCurve.hpp"
#include "FlatVolatilitySurface.hpp"
class FakeMarketData : public MarketData {
public:
FakeMarketData() = default;
FakeMarketData(const FakeMarketData &other)
{
}
FakeMarketData(FakeMarketData &&other) noexcept
{
}
FakeMarketData & operator=(const FakeMarketData &other) {
return *this;
}
FakeMarketData & operator=(FakeMarketData &&other) noexcept {
return *this;
}
double spot() const {return 100.0;}
YieldCurve& yield_curve(){return *yieldCurve_; };
VolatilitySurface& volatility_surface(){return *volatilitySurface_; };
private:
std::unique_ptr<FlatYieldCurve> yieldCurve_ = std::make_unique<FlatYieldCurve>();
std::unique_ptr<FlatVolatilitySurface> volatilitySurface_ = std::make_unique<FlatVolatilitySurface>();
};
#endif

View File

@@ -6,6 +6,12 @@
#include "VolatilitySurface.hpp"
class FlatVolatilitySurface : public VolatilitySurface {
double sigma(double K, double T) {return 0.2;}
public:
explicit FlatVolatilitySurface(double sigma = 0.2) : sigma_(sigma) {}
double sigma(double K, double T) const override {return sigma_;}
private:
double sigma_;
};
#endif
#endif

View File

@@ -7,10 +7,12 @@
#include <cmath>
class FlatYieldCurve : public YieldCurve{
public:
explicit FlatYieldCurve(double rate = 0.01) : rate_(rate) {}
double discount(double t) override {return std::exp(-rate_ * t); };
double zeroRate(double t) override {return rate_; }
double discount(double t) const override {return std::exp(-rate_ * t); };
double zeroRate(double t) const override {return rate_; }
private:
double rate_ = 0.01;
};
#endif
#endif