Casos de usuarios

Nykredit Develops Risk Management and Portfolio Analysis Applications to Minimize Operational Risk


Enable financial analysts to make rapid, fact-based decisions by providing them with direct access to risk management and portfolio analysis information


Develop and deploy easy-to-use graphical financial analysis applications using MATLAB and MATLAB Compiler


  • Productivity increased threefold
  • Operational risk mitigated
  • Analysis time reduced from days to hours

“Data handling, programming, debugging, and plotting are much easier in MATLAB, where everything is in one environment. For performance calculation GUIs, MATLAB provides a real error-checked application that makes cool customized plots for client reports. This has turned a several-hour task in a spreadsheet into a two-minute no-brainer.”

Peter Ahlgren, Nykredit Asset Management
Nykredit’s tool for calculating and visualizing risk statistics. The plot shows portfolio expected tracking error broken out by industry.

With a strong emphasis on balanced risk management, the Analytic Support Unit within Nykredit’s Asset Management division provides quantitative analysis support for their fund managers and analysts, including asset allocation, corporate bond profiling, performance metrics, and risk measures.

To enable Nykredit analysts to make faster, better-informed decisions, the Analytic Support Unit used MathWorks tools to build, deploy, and help manage risk and portfolio analysis applications in their front office.

“With MATLAB it’s very easy to bring data in from a database, process it, and perform on-demand analysis for various scenarios,” says Peter Ahlgren, analyst at Nykredit. “In a few hours we can develop a simple prototype. If we want to keep it, we can put together a user interface and use MATLAB Compiler to build a production application that portfolio managers can use without any formal training or knowledge of the underlying algorithms.”


Like many financial services organizations, Nykredit uses spreadsheets for many data analysis tasks. For applications where stability is key, however, spreadsheets proved difficult to work with. “It is too easy for someone to make a minor change in a spreadsheet—such as inserting a new column—and suddenly end up with the wrong results,” notes Ahlgren. “The operational risk for spreadsheets in a production environment is very high.”

Having already developed some lower-level statistical algorithms in C++, the group briefly considered developing a complete solution in C++. “You can do anything in C++ if you have a large amount of time, but we quickly found that we did not have that,” says Ahlgren. “You could spend two or three months pulling together libraries and still not have everything you require.”

The Analytics Support Unit needed tools to rapidly develop algorithms, access information in databases, visualize results, and deploy operational standalone applications to Nykredit portfolio managers.


Nykredit analysts used MATLAB®, Database Toolbox™, and MATLAB Compiler™ to build easy-to-use risk management and portfolio analysis applications for use in production throughout the company.

The team used Database Toolbox to import corporate bond data, rate infor­mation, and other financial data from Nykredit’s Oracle databases.

They developed and tested algorithms in MATLAB for calculating relevant risk metrics, including expected shortfall and value at risk. The team identified distributions that fit the data and then ran simulations using copulas to account for correlation between various market sectors.

For some functions, the Analytic Support Unit adapted code samples that they downloaded from MATLAB Central. The team also reused legacy C++ code by calling the routines directly from MATLAB. The open architecture and development environment in MATLAB, particularly features such as the editor, debugger, and code profiler, enabled Ahlgren to build reliable quantitative applications quickly.

For presentation and reporting, the team used MATLAB plotting capabilities to visualize results in multiple formats, making it easy to identify the markets or industries that contribute most to the overall risk.

Once they had fully tested and fine-tuned the algorithms, the team developed a user interface in the MATLAB GUI design environment and used MATLAB Compiler to generate standalone applications, which they deployed to Nykredit analysts and portfolio managers.

Working with student interns from a local university, the team also created a MATLAB based application for producing monthly reports with plots and graphs for Nykredit clients.

The Analytic Support Unit uses MATLAB for rapid analysis tasks as well. In one instance, they analyzed option-adjusted spreads, assessing and visualizing their dependence on interest rates as well as option volatilities.

The risk management and portfolio analysis applications are now in use across the Nykredit Asset Management organization.


  • Productivity increased threefold. “Development with MATLAB is three to five times faster than development in C++,” says Ahlgren. “Put another way, we would need two or three times the staff if we were developing in C++ because of the extra effort needed to import data from data­bases, produce plots to visualize results, and check for errors in the libraries.”

  • Operational risk mitigated. “With MATLAB and MATLAB Compiler, I can quickly create a foolproof standalone production application,” says Ahlgren. “Unlike deploying a spreadsheet, I have complete control of the data and the algorithms, so the operational risk is practically zero.”

  • Analysis time reduced from days to hours. “When I was evaluating option adjusted spreads for a scientific paper, I used MATLAB to complete the analysis and went from idea to answers in about half a day,” says Ahlgren. “With C++, it would have taken at least a week.”