Please rotate your tablet to be horizontal.

You can dismiss this notice but please note that this experience has not been designed for mobile devices and so will be less than optimal

Back To Schedule

Using std::chrono Calendar Dates for Finance

14:45 - 15:45 Friday 16th September 2022 MDT Summit 8 & 9 / Online C
Beginner
Intermediate
Advanced
Math & Numbers

Dates and date calculations might not sound exciting, but they are vitally important in financial software development, particularly in areas such as fixed income analytics, mortgage backed-securities (MBS), and interest rate derivatives A prime example is in applying the correct day-count convention to interest rate derivative calculations, as failure to do so can result in potentially significant losses for a trading desk.

Up until C++20, C++ financial developers had to rely on an external library for dates, or write their own customized code. This has now fortunately changed with the addition of the `std::chrono` calendar date classes.

Some of the operations are not exactly trivial, however, as one needs to identify and use the appropriate tools in the library. For example, naively applying the addition assignment operator to add a period of two months to December 30 can result in an invalid date of February 30. Another possible complication is if a date generated in a payment schedule falls on a non-business day at the end of the month. Remedies in these cases are provided by using a std::chrono object that represents the last day of the month object rather than a standard date.

Handling edge cases such as these is standard fare in working with financial date calculations. Methods available in `std::chrono` to adjust for them will be presented, and then parlayed into designing C++ code to properly generate a schedule of cash flows, perform business day adjustments for weekends and end of the month, construct and interpolate a term structure of interest rates, and calculate the present value of fixed income securities such as bonds and interest rate swaps.

Daniel Hanson

Daniel Hanson spent 24 years in quantitative development in finance, primarily with C++ implementation of option pricing and portfolio risk models, and related library development. He subsequently held a full-time lecturer position through 2022 in the Department of Applied Mathematics at the University of Washington, teaching quantitative development courses in the Computational Finance & Risk Management (CFRM) graduate and undergraduate programs. This included intermediate and advanced classes in computational C++, and mentoring students in Google Summer of Code projects involving implementation of mathematical models in C++ and R.