diff options
| author | Guillaume Horel <guillaume.horel@gmail.com> | 2018-10-25 14:54:04 -0400 |
|---|---|---|
| committer | Guillaume Horel <guillaume.horel@gmail.com> | 2019-02-22 13:38:34 -0500 |
| commit | 85624fe9462e801b225b7f3c709c0c4dbc32264d (patch) | |
| tree | e3e260ec8051631b9984805d84dd68afc01aa499 /c_layer/curve.hpp | |
| parent | e2dab76d3519d3de7f22ca8eeb93e8184431593e (diff) | |
| download | pyisda-85624fe9462e801b225b7f3c709c0c4dbc32264d.tar.gz | |
work in progress
wip
wip
wip2
fix C++
Diffstat (limited to 'c_layer/curve.hpp')
| -rw-r--r-- | c_layer/curve.hpp | 61 |
1 files changed, 61 insertions, 0 deletions
diff --git a/c_layer/curve.hpp b/c_layer/curve.hpp new file mode 100644 index 0000000..5479e72 --- /dev/null +++ b/c_layer/curve.hpp @@ -0,0 +1,61 @@ +#pragma once + +#include <vector> +#include <string> +#include "isda/bastypes.h" +#include "isda/cdate.h" +#include "isda/tcurve.h" + +namespace pyisda { + class Curve { + + public: + Curve(TCurve* const curve) : ptr(curve) {}; + Curve(const Curve &curve2) : + ptr(JpmcdsCopyCurve(curve2.ptr)) {}; + + ~Curve() { + JpmcdsFreeTCurve(ptr); + } + explicit operator TCurve*() const { return ptr; } + unsigned char* serialize(unsigned char* buf); + double zeroPrice(const TDate date); + double zeroPrice(const TDate date1, const TDate date2); + double survivalProb(const TDate start_date, const TDate maturity_date); + double survivalProb(const TDate start_date, const TDate maturity_date, double eps); + static void tweak(TCurve* ptr, double epsilon); + static void tweak(TCurve* ptr, double epsilon, unsigned long mask); + void tweak(double epsilon); + void tweak(double epsilon, unsigned long mask); + size_t size(); + private: + TCurve* ptr; + }; + + class YieldCurve : public Curve { + public: + YieldCurve(TCurve* const curve, const std::vector<TDate>& dates); + YieldCurve(const YieldCurve &curve2) : + Curve(curve2), + dates(curve2.dates) {}; + size_t size(); + unsigned char* serialize(unsigned char* buf); + std::vector<TDate> dates; + }; + + class SpreadCurve : public Curve { + public: + SpreadCurve(TCurve* const curve, const std::vector<double>& recovery_rates, + std::string ticker); + SpreadCurve(const SpreadCurve &curve2) : + Curve(curve2), + recovery_rates(curve2.recovery_rates), + ticker(curve2.ticker) {}; + + std::vector<double> recovery_rates; + std::string ticker; + size_t size(); + unsigned char* serialize(unsigned char* buf); + }; + +} |
