diff options
Diffstat (limited to 'c_layer/cdsbootstrap.c')
| -rw-r--r-- | c_layer/cdsbootstrap.c | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/c_layer/cdsbootstrap.c b/c_layer/cdsbootstrap.c new file mode 100644 index 0000000..f3ae975 --- /dev/null +++ b/c_layer/cdsbootstrap.c @@ -0,0 +1,50 @@ +#include "cdsbootstrap.h" + +int cdsBootstrapPointFunction +(double hazardRate, + void *data, + double *pv) +{ + int status = FAILURE; + + cds_bootstrap_ctx *context = (cds_bootstrap_ctx*)data; + + TCurve *discountCurve = context->discountCurve; + TCurve *cdsCurve = context->cdsCurve; + TDate cdsBaseDate = cdsCurve->fBaseDate; + TDate stepinDate = context->stepinDate; + TDate cashSettleDate = context->cashSettleDate; + + double pvC; /* PV of contingent leg */ + double pvF; /* PV of fee leg */ + cdsCurve->fArray[0].fRate = hazardRate; + + if (JpmcdsContingentLegPV (context->cl, + cdsBaseDate, + cashSettleDate, + stepinDate, + discountCurve, + cdsCurve, + context->recoveryRate, + &pvC) != SUCCESS) + goto done; + + if (JpmcdsFeeLegPV(context->fl, + cdsBaseDate, + stepinDate, + cashSettleDate, + discountCurve, + cdsCurve, + 1, + &pvF) != SUCCESS) + goto done; + /* Note: price is discounted to cdsBaseDate */ + *pv = pvC - context->spread * pvF; + status = SUCCESS; + + done: + + if (status != SUCCESS) + printf("Something went wrong"); + return status; +} |
