summaryrefslogtreecommitdiffstats
path: root/yearfrac.pyx
diff options
context:
space:
mode:
authorGuillaume Horel <guillaume.horel@serenitascapital.com>2016-06-28 15:30:16 -0400
committerGuillaume Horel <guillaume.horel@serenitascapital.com>2016-06-28 15:30:16 -0400
commit60e49a606ae270fb4d455da1b565e0ea656ffb3c (patch)
treeada0b2e8bfa6b5bb4dc8180f7d83ca57572378e5 /yearfrac.pyx
downloadpyisda-60e49a606ae270fb4d455da1b565e0ea656ffb3c.tar.gz
initial import
Diffstat (limited to 'yearfrac.pyx')
-rw-r--r--yearfrac.pyx11
1 files changed, 11 insertions, 0 deletions
diff --git a/yearfrac.pyx b/yearfrac.pyx
new file mode 100644
index 0000000..48b8995
--- /dev/null
+++ b/yearfrac.pyx
@@ -0,0 +1,11 @@
+from pyisda.yearfrac cimport JpmcdsStringToDayCountConv
+
+cdef long dcc(str day_count):
+ cdef long r
+ dc_bytes = day_count.encode('utf-8')
+ cdef char* dc = dc_bytes
+ cdef err = JpmcdsStringToDayCountConv(<char*> dc, &r)
+ if err == 0:
+ return r
+ else:
+ raise ValueError('{0} is not a valid day count'.format(day_count))