diff options
Diffstat (limited to 'sql/serenitas.c')
| -rw-r--r-- | sql/serenitas.c | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/sql/serenitas.c b/sql/serenitas.c index 1ab3522b..64de484a 100644 --- a/sql/serenitas.c +++ b/sql/serenitas.c @@ -67,13 +67,28 @@ static inline TDate TDate_from_DateADT(DateADT d) { static inline const char* cal_from_currency(const char* curr) { static const char default_cal[] = "NONE"; - static const char us_cal[] = "/usr/share/cds/US"; + static const char us_cal[] = "/usr/share/cds/NYM"; + static const char jp_cal[] = "/usr/share/cds/TYO"; if (strcmp(curr, "USD") == 0) { return us_cal; + } else if (strcmp(surr, "JPY") == ) { + return jp_cal; } else { return default_cal; } } + +static inline const int16 curvetype_from_currency(const char* curr) { + if (strcmp(curr, "USD") == 0) { + return 531; + } else if (strcmp(curr, "EUR") == 0) { + return 530; + } else if (strcmp(curr, "JPY") == 0) { + return 532; + } +} + + PG_FUNCTION_INFO_V1(cds_accrued); Datum cds_accrued(PG_FUNCTION_ARGS) { @@ -199,7 +214,7 @@ Datum upfront_from_level(PG_FUNCTION_ARGS) { elog(ERROR, "something wrong happened"); } SPI_freetuptable(SPI_tuptable); - int16 curve_type = 532; + int16 curve_type = curvetype_from_currency(currency); sql_query = "SELECT curve FROM rate_curves WHERE effective_date=$1 AND curve_type=$2"; argtypes[0] = DATEOID; argtypes[1] = INT2OID; |
