Zum Hauptinhalt springen
Nicht aus der Schweiz? Besuchen Sie lehmanns.de

C# for Financial Markets (eBook)

eBook Download: EPUB
2013
John Wiley & Sons (Verlag)
978-1-118-50283-9 (ISBN)

Lese- und Medienproben

C# for Financial Markets - Daniel J. Duffy, Andrea Germani
Systemvoraussetzungen
65,99 inkl. MwSt
(CHF 64,45)
Der eBook-Verkauf erfolgt durch die Lehmanns Media GmbH (Berlin) zum Preis in Euro inkl. MwSt.
  • Download sofort lieferbar
  • Zahlungsarten anzeigen

A practice-oriented guide to using C# to design and program pricing and trading models

In this step-by-step guide to software development for financial analysts, traders, developers and quants, the authors show both novice and experienced practitioners how to develop robust and accurate pricing models and employ them in real environments. Traders will learn how to design and implement applications for curve and surface modeling, fixed income products, hedging strategies, plain and exotic option modeling, interest rate options, structured bonds, unfunded structured products, and more. A unique mix of modern software technology and quantitative finance, this book is both timely and practical. The approach is thorough and comprehensive and the authors use a combination of C# language features, design patterns, mathematics and finance to produce efficient and maintainable software.

Designed for quant developers, traders and MSc/MFE students, each chapter has numerous exercises and the book is accompanied by a dedicated companion website, www.datasimfinancial.com, providing all source code, alongside audio, support and discussion forums for readers to comment on the code and obtain new versions of the software.



Daniel J. Duffy has been working with numerical methods in finance, industry and engineering since 1979. He has written four books on financial models and numerical methods and C++ for computational finance and he has also developed a number of new schemes for this field. He is the founder of Datasim Education and has a PhD in Numerical Analysis from Trinity College, Dublin.

Andrea Germani was born in Lodi, Italy in 1975, where he currently lives. After graduating from the Bocconi University in Milano, he obtained the Certificate in Quantitative Finance in London under the supervision of Paul Wilmott. Since then he has been working as a trader in some of the major Italian banks, where he gained a deep knowledge of the financial markets. He also worked on valuation and pricing of equity and interest-derivatives, with a focus on the practical use of the models on the trading floor. He is active in training courses of Finance for students and practitioners.


A practice-oriented guide to using C# to design and program pricing and trading models In this step-by-step guide to software development for financial analysts, traders, developers and quants, the authors show both novice and experienced practitioners how to develop robust and accurate pricing models and employ them in real environments. Traders will learn how to design and implement applications for curve and surface modeling, fixed income products, hedging strategies, plain and exotic option modeling, interest rate options, structured bonds, unfunded structured products, and more. A unique mix of modern software technology and quantitative finance, this book is both timely and practical. The approach is thorough and comprehensive and the authors use a combination of C# language features, design patterns, mathematics and finance to produce efficient and maintainable software. Designed for quant developers, traders and MSc/MFE students, each chapter has numerous exercises and the book is accompanied by a dedicated companion website, www.datasimfinancial.com/forum/viewforum.php?f=196&sid=f30022095850dee48c7db5ff62192b34, providing all source code, alongside audio, support and discussion forums for readers to comment on the code and obtain new versions of the software.

DANIEL J. DUFFY has been working with numerical methods in finance, industry and engineering since 1979. He has written four books on financial models and numerical methods and C++ for computational finance and he has also developed a number of new schemes for this field. He is the founder of Datasim Education and has a PhD in Numerical Analysis from Trinity College, Dublin. ANDREA GERMANI was born in Lodi, Italy in 1975, where he currently lives. After graduating from Bocconi University in Milano, he obtained the Certificate in Quantitative Finance in London under the supervision of Paul Wilmott. Since then he has been working as a trader in some of the major Italian banks, where he gained a deep knowledge of financial markets. He also worked on valuation and pricing of equity and interest-derivatives, with a focus on the practical use of models on the trading floor. His teaching experience includes finance training courses for university students and practitioners. He is the Head of Interest Rate Derivatives Trading and Treasury in a bank.

2

C# Fundamentals

2.1 INTRODUCTION AND OBJECTIVES

The goal of this chapter is to introduce the C# language. We concentrate on fundamental issues such as built-in data types, memory management and basic console input and output. Of particular importance is the distinction between value types and reference types, how they are created, compared and finally removed from memory.

Without further ado, we deliver the extremely popular “Hello World” program:

using System; // Use the System namespace (Console etc.) // HelloWorld class. Every C# program has at least one class public class HelloWorld { // Each Main method must be enclosed in a class    // C# programs start in this Main() method    public static void Main()    { // Write string to console Console.WriteLine("Hello world!");    } }

In this case we have created a class called HelloWorld containing a method called Main() which is the entry point to the program. We explain this (and more extended) syntax in the rest of this chapter.

We are assuming that the reader has knowledge of programming in some object-oriented language, in particular what classes and objects are, some knowledge of data types and basic exception handling. For those readers with minimal programming experience and who need to learn fundamental C# syntax, please consult a book on C#, for example Albahari 2010. In this chapter we deliver a simple C# class that implements the Black Scholes equation. For an introduction to object-oriented programming, see Appendix 1.

2.2 BACKGROUND TO C#

C# is a modern object-oriented language developed by Microsoft Corporation. Many of the features have their equivalents in other languages such as Java, C++ and C. Those readers who know one or more of these languages should find it easy to learn the fundamental syntax of C# and to start writing small applications in a matter of days or weeks. For C++ developers the transition to C# is relatively painless because the syntax of C++ and C# is similar and we do not have to worry about heap-based memory management in C# because this is taken care of by the garbage collector in the runtime system. For Java developers, the transition to C# is also relatively straightforward, although C# has support for generic classes and interfaces since .NET 2.0 while generics appeared relatively recently in Java and they may not be familiar to all Java developers. Finally, those developers who are familiar with C++ template programming should have little difficulty in learning and applying C# generics.

2.3 VALUE TYPES, REFERENCE TYPES AND MEMORY MANAGEMENT

Our discussion of C# begins with an introduction to memory and its relationship to objects and data. We restrict the scope at the moment to stack and heap memory regions. Briefly, stack memory is fixed and defined at compile-time while heap memory is dynamic and is defined at run-time. In C# we distinguish between two categories of data types. First, a value type variable is created on the stack and it is popped off the stack when it goes out of scope. The variable contains the value. Variables of this type are passed by value (in other words, a copy of the variable is made) and it is copied when it is assigned to other variables. Examples of value types are intrinsic (built-in) types and user-defined structs that we shall discuss in detail in later sections. Second, a reference type variable data is created on the heap. Thus, reference type variables are not copied and it is possible to define several variables that reference the same object in memory. Objects, strings and arrays are reference data types and we create variables of these types in combination with the keyword ‘new’.

Value types and reference types should be familiar to those developers who have worked with languages such as C++, Java and Pascal. We discuss built-in and user-defined value types in this chapter. Chapter 3 introduces user-defined reference types.

2.4 BUILT-IN DATA TYPES IN C#

C# supports a range of numeric, byte and character types. A summary of the various data types – including their size, minimum and maximum values – is shown in Table 2.1.

Table 2.1 Built-in data types in C#

We first discuss the numeric types, namely float, double and decimal. These types contain the numeric data that we will use in future chapters. It is possible to define literals of these types as follows:

// double, decimal and float literals double a=1D;  // a=1.0 double b=3.14E3;   // b=3140.0 scientific notation decimal c=1.1234M;   // c=1.1234

Furthermore, we can test numeric calculations for division by zero and overflow, for example:

float pi=1.0F/0.0F;   // Positive infinity (pi==POSITIVE_INFINITY) double ni=-1.0/0.0;   // Negative infinity (ni==NEGATIVE_INFINITY) float nan=0.0f/0.0f;   // Not a number (nan==NaN)

When we print the above variables we get the following output:

1 3140 1.1234 Infinity -Infinity NaN

We now turn our attention to integer types such as int and long. Integers use modulo arithmetic so that no overflow can occur. However, division by zero causes an exception of type DivideByZeroException to be thrown as the following example shows:

int zero=0; try {    zero=100/zero; // Throws DivideByZeroException } catch (DivideByZeroException ex) {    Console.WriteLine(ex); }

We shall discuss exception handling in C# in chapter 3.

The final example in this section creates two int variables. The first variable has the largest value (2147483647) possible. We compute the sum of these integers. The result will wrap around and does not produce overflow:

int i1=2147483647, i2=1; int sum=i1+i2; // Wraps to -2147483648 (smallest int)

2.5 CHARACTER AND STRING TYPES

The char data type can contain Unicode characters and the Unicode character set is able to hold 65536 different characters. The ASCII characters (range 0x00 to 0xFF) have the same values as the Unicode character range, namely u0000 to u00FF. Finally, it is possible to represent escape characters by prepending them with the backslash character ‘/’. Some examples of creating characters are:

char a='A'; // ‘A’ character char newline='/n'; // Newline (/n) character char one1='/u0031'; // ‘1’ character (hexadecimal) char one2='/x0031'; // ‘1’ character (hexadecimal)

The string data type represents a sequence of Unicode characters. Strings are immutable, that is they are read-only. They can be compared using the operators == and !=. In general, string literals are automatically converted to string objects.

Some examples on how to define strings are:

string s1="Hello World"; // Create new string Console.WriteLine(s1); string s2=s1 + "Hello World"; // Concatenate two strings Console.WriteLine(s2); s1="New String"; // Put new string in existing reference Console.WriteLine(s1); string str="Price:/t/u20AC10.00//"; // "Price: €10.00/" Console.WriteLine(str);

Here we see how to concatenate two strings and how to embed escape characters in a string.

The C# built-in string class has many methods for creating, editing, modifying and accessing strings. We discuss string later in Section 5.12; however, we give a summary of the main methods:

  • Creating strings and copying strings to other strings.
  • Comparing strings.
  • Remove leading or trailing blanks from a string.
  • Methods returning a bool; for example, does a string contain a substring, does a string start or end with a given sequence of characters?
  • Remove or replace characters in a string.
  • Convert the characters in a string to upper case or to lower case.

These methods are useful in text and string processing applications, for example in interactive applications where user input needs to be validated or in pattern-matching applications.

Our main interest in the short term is in creating strings and comparing strings. The main methods for string creation are:

  • From a string literal.
  • By using the static method Copy().
  • By using the static method Clone().

The method Copy() creates a new instance of a string as a copy of its source string while in the case of Clone() the return value is not an independent copy of the source string; it is another view of the same data. In this sense we see that using Clone() is more memory efficient than Copy().

Some examples of string creation are:

// Copying and creating strings string s1 = "is this a string that I see before me?"; string s2 = string.Copy(s1); string s3 = (string)s2.Clone();

The return type of Clone()is object which is the base class for all C# classes. This means that when we clone a string we must cast the result to a string instance, as can be seen from the above...

Erscheint lt. Verlag 14.1.2013
Reihe/Serie The Wiley Finance Series
Wiley Finance Series
Wiley Finance Series
Sprache englisch
Themenwelt Mathematik / Informatik Informatik Programmiersprachen / -werkzeuge
Recht / Steuern Wirtschaftsrecht
Wirtschaft Betriebswirtschaft / Management Finanzierung
Schlagworte C# for financial markets, C# for designing trading models, quantitative finance, C# for quantitative finance, guide to C# for quantitative finance • Finance & Investments • Financial Engineering • Finanztechnik • Finanz- u. Anlagewesen
ISBN-10 1-118-50283-3 / 1118502833
ISBN-13 978-1-118-50283-9 / 9781118502839
Informationen gemäß Produktsicherheitsverordnung (GPSR)
Haben Sie eine Frage zum Produkt?
EPUBEPUB (Adobe DRM)

Kopierschutz: Adobe-DRM
Adobe-DRM ist ein Kopierschutz, der das eBook vor Mißbrauch schützen soll. Dabei wird das eBook bereits beim Download auf Ihre persönliche Adobe-ID autorisiert. Lesen können Sie das eBook dann nur auf den Geräten, welche ebenfalls auf Ihre Adobe-ID registriert sind.
Details zum Adobe-DRM

Dateiformat: EPUB (Electronic Publication)
EPUB ist ein offener Standard für eBooks und eignet sich besonders zur Darstellung von Belle­tristik und Sach­büchern. Der Fließ­text wird dynamisch an die Display- und Schrift­größe ange­passt. Auch für mobile Lese­geräte ist EPUB daher gut geeignet.

Systemvoraussetzungen:
PC/Mac: Mit einem PC oder Mac können Sie dieses eBook lesen. Sie benötigen eine Adobe-ID und die Software Adobe Digital Editions (kostenlos). Von der Benutzung der OverDrive Media Console raten wir Ihnen ab. Erfahrungsgemäß treten hier gehäuft Probleme mit dem Adobe DRM auf.
eReader: Dieses eBook kann mit (fast) allen eBook-Readern gelesen werden. Mit dem amazon-Kindle ist es aber nicht kompatibel.
Smartphone/Tablet: Egal ob Apple oder Android, dieses eBook können Sie lesen. Sie benötigen eine Adobe-ID sowie eine kostenlose App.
Geräteliste und zusätzliche Hinweise

Buying eBooks from abroad
For tax law reasons we can sell eBooks just within Germany and Switzerland. Regrettably we cannot fulfill eBook-orders from other countries.

Mehr entdecken
aus dem Bereich
Apps programmieren für macOS, iOS, watchOS und tvOS

von Thomas Sillmann

eBook Download (2025)
Carl Hanser Verlag GmbH & Co. KG
CHF 58,60
Deterministische und randomisierte Algorithmen

von Volker Turau; Christoph Weyer

eBook Download (2024)
De Gruyter (Verlag)
CHF 63,45