SciComp SLV Calibrator

C# in Financial Markets What are the Advantages, the Trading Perspective?

C# in Financial Markets What are the Advantages, the Trading Perspective?

Andrea Germani, Daniel J. Duffy March 2013

In this blog the authors discuss some of the advantages of C# in computational finance from the perspective of the application developer and trader. As a language, it offers the user-friendliness of VBA and Excel integration on the one hand and the efficiency and object-oriented features of C++ on the other hand. This – together with .NET libraries – suggest that developer productivity levels will be high and that you can write efficient and robust code. These conclusions have been borne out in practical applications. We now discuss some of the features in C# and in the .NET Framework that support our claims. To this end, we base our discussion on the ISO 9126 standard that is a classification consisting of orthogonal characteristics that describe the quality of software products. In this case we discuss how these characteristics are realised in C#.

. Functionality: this is the capability to satisfy user needs. The .NET Framework is suitable for a wide range of applications due to its support for OOP and generic programming models. The .NET libraries have native support for containers, data classes for database (ADO.NET) and XML interoperability as well as LINQ (Language Integrated Query) that allows the developer to perform SQL-like queries on in-memory data structures. The framework is secure because all memory management is taken care of by the garbage collector. This last feature has the advantage that the developer does not have to worry about memory leaks, dangling pointers and other scary things.

. Interoperability: this subcharacteristic of Functionality is concerned with the ability of a system to interact with other (predefined) software. The .NET Framework supports a multi-language programming model. This means that you can use a number of languages (such as C#, VB.NET and F#) in a given program and compile them into a single executable file. It is also very easy to create Excel worksheet and COM add ins in C#. Finally, interoperability with native C++ code is also possible in combination with Microsoft’s Managed C++ compiled. In other words, we can wrap existing C++ legacy code in the .NET development environment. In one sense, we can say that C# is a one-stop shop.

. Reliability: this is the capability that a system maintains a given level of performance over a given period of time. In the current case we say that .NET uses managed code which entails that access to resources is organised by the Common Language Runtime (CLR). In particular, the CLR has a garbage collector that executes as part of your program, reclaiming memory for objects that are no longer referenced. Furthermore, C# is a type-safe language. This means that instances (objects) of types can interact only through protocols that they define. In other words, there is no danger of comparing apples and oranges as it were.

. Usability: this characteristic refers to the effort that is needed in order to use (as developer) a software system. C++ and Java developers tend to find C# easy to learn. Typically, you can become competent in the language within weeks. Of course, learning how to use the .NET libraries take some time. The use of Intellisense speeds up the development process.

. Efficiency: this characteristic refers to the level of performance and the amount of resources that are needed in order to achieve the performance. C# code can be compiled to native code and the just-in-time compiler (JIT) ensures that the code is fast. Furthermore, C# supports multithreading and .NET has the Task Parallel Library (TPL) that can improve the speedup of code that is amenable to parallelisation. The perennial discussion on whether C# is faster than C++ is not the central issue in our opinion.

. Maintainability: refers to the effort that is needed to make specific modifications to code in the system. Once a software system has started to gain a foothold with users you will find that the stability, testability and analysability of the code base become more important. The OOP and GP – if applied in an appropriate fashion – promote the maintainability of your code.

Conclusions We have found that C# and the .NET Framework to be a suitable development environment for finance. They offer tools and libraries that provide the optimal mix of number crunching ability (similar to C and C++), libraries for data processing and Excel interoperability (similar to VBA), resulting in measurable advantages for front office productivity.

Summary of Advantages of C# and the .NET Framework

1) Many native .NET classes, for example containers.

2) Advanced libraries, for example LINQ, multithreading and ADO.NET.

3) Easy to interface to MS Office, in particular Excel.

4) East Web and database connection.

5) No memory management issues.

6) You delegate to MS developers who create and optimise new classes for us.

7) One-stop shop; major advances in developer productivity levels.

8) A suitable development environment for computational finance and trading applications.

We discuss C# and its applications to computational finance in the recently published book “C# for Financial Markets” by Daniel J. Duffy and Andrea Germani. Published by John Wiley and Sons Chichester 2013.

Web site

http://www.datasimfinancial.com/forum/viewforum.php?f=196&sid=71dedd579d000d4c807a505c0763c6a2