Hedge Fund Modelling and Analysis: An Object Oriented Approach Using C++
By Paul Darbyshire and David Hampton
()
About this ebook
Low interest rates, overcrowded markets and greater regulatory oversight are just some of the many reasons it is close to impossible for hedge funds to draw competitive returns. The solution for many hedge fund managers, quantitative investment analysts and risk managers is to adopt new technologies, platforms and programming languages to better manage their risks and maximise the benefits of their return profiles.
Hedge Fund Modelling and Analysis is a full course in the latest analytic strategies for hedge fund investing, complete with a one-of-a-kind primer on both C++ and object oriented programming (OOP). Covering both basic and risk-adjusted performance measures, this practitioner's guide enables you to manage risk easily and make the most of key statistics with simple and advanced analysis techniques. This highly anticipated third book in the widely used Hedge Fund Modelling and Analysis series is the only guide available for applying the powerful C++ language to revolutionise hedge fund trading. Even if you've never worked with code before, the focused overview of C++ gives you everything you need to navigate the technical aspects of object oriented programming, which enables you to build sophisticated analysis programs from small units of reusable code. This book is your breakthrough introduction to winning with hedge funds in the new reality of trading.
Jumpstart your new approach to beating the markets with:
- All the guidance and hands-on support you need to use quantitative strategies to optimise hedge fund decision-making.
- Illustrative modelling exercises and worked-out problems demonstrating what to expect when assessing risk and return factors in the real world.
- A companion website offering additional C++ programs, algorithms and data to download.
Make reading Hedge Fund Modelling and Analysis your new routine and gain all the insight and relevant information you need to beat the markets.
Related to Hedge Fund Modelling and Analysis
Titles in the series (100)
Structured Finance: The Object Oriented Approach Rating: 0 out of 5 stars0 ratingsCredit Risk Modeling using Excel and VBA Rating: 3 out of 5 stars3/5Rumors in Financial Markets: Insights into Behavioral Finance Rating: 0 out of 5 stars0 ratingsMulti-moment Asset Allocation and Pricing Models Rating: 0 out of 5 stars0 ratingsAdvanced Modelling in Finance using Excel and VBA Rating: 3 out of 5 stars3/5Equity Valuation: Models from Leading Investment Banks Rating: 0 out of 5 stars0 ratingsFinancial Applications using Excel Add-in Development in C / C++ Rating: 0 out of 5 stars0 ratingsMacrofinancial Risk Analysis Rating: 0 out of 5 stars0 ratingsFinancial Engineering with Finite Elements Rating: 0 out of 5 stars0 ratingsLevy Processes in Credit Risk Rating: 0 out of 5 stars0 ratingsStochastic Claims Reserving Methods in Insurance Rating: 3 out of 5 stars3/5The Future of Banking: In a Globalised World Rating: 0 out of 5 stars0 ratingsThe Art of Credit Derivatives: Demystifying the Black Swan Rating: 4 out of 5 stars4/5Derivatives Demystified: A Step-by-Step Guide to Forwards, Futures, Swaps and Options Rating: 3 out of 5 stars3/5Exotic Options and Hybrids: A Guide to Structuring, Pricing and Trading Rating: 4 out of 5 stars4/5An Arbitrage Guide to Financial Markets Rating: 0 out of 5 stars0 ratingsUnderstanding Islamic Finance Rating: 5 out of 5 stars5/5Measuring Operational and Reputational Risk: A Practitioner's Approach Rating: 5 out of 5 stars5/5Modeling and Forecasting Electricity Loads and Prices: A Statistical Approach Rating: 0 out of 5 stars0 ratingsPositive Alpha Generation: Designing Sound Investment Processes Rating: 0 out of 5 stars0 ratingsRisk Quantification: Management, Diagnosis and Hedging Rating: 0 out of 5 stars0 ratingsProperty Derivatives: Pricing, Hedging and Applications Rating: 0 out of 5 stars0 ratingsThe LIBOR Market Model in Practice Rating: 0 out of 5 stars0 ratingsCredit Derivatives: Trading, Investing, and Risk Management Rating: 0 out of 5 stars0 ratingsModelling Single-name and Multi-name Credit Derivatives Rating: 0 out of 5 stars0 ratingsRisk Management in Commodity Markets: From Shipping to Agriculturals and Energy Rating: 0 out of 5 stars0 ratingsFourier Transform Methods in Finance Rating: 0 out of 5 stars0 ratingsPlumbers and Visionaries: Securities Settlement and Europe's Financial Market Rating: 0 out of 5 stars0 ratingsElectricity Markets: Pricing, Structures and Economics Rating: 3 out of 5 stars3/5Operational Risk Assessment: The Commercial Imperative of a more Forensic and Transparent Approach Rating: 0 out of 5 stars0 ratings
Related ebooks
Measuring and Managing Liquidity Risk Rating: 0 out of 5 stars0 ratingsHedge Fund Modelling and Analysis using MATLAB Rating: 0 out of 5 stars0 ratingsTactical Portfolios: Strategies and Tactics for Investing in Hedge Funds and Liquid Alternatives Rating: 0 out of 5 stars0 ratingsThe Exchange-Traded Funds Manual Rating: 0 out of 5 stars0 ratingsActiveBeta Indexes: Capturing Systematic Sources of Active Equity Returns Rating: 0 out of 5 stars0 ratingsFinancial Risk Management: Applications in Market, Credit, Asset and Liability Management and Firmwide Risk Rating: 0 out of 5 stars0 ratingsFinancial Risk Modelling and Portfolio Optimization with R Rating: 4 out of 5 stars4/5Modern Portfolio Theory: Foundations, Analysis, and New Developments Rating: 0 out of 5 stars0 ratingsApplied Probabilistic Calculus for Financial Engineering: An Introduction Using R Rating: 0 out of 5 stars0 ratingsFinancial Engineering and Arbitrage in the Financial Markets Rating: 0 out of 5 stars0 ratingsEffective Product Control: Controlling for Trading Desks Rating: 5 out of 5 stars5/5Managed Futures for Institutional Investors: Analysis and Portfolio Construction Rating: 0 out of 5 stars0 ratingsIntermediate Structured Finance Modeling: Leveraging Excel, VBA, Access, and Powerpoint Rating: 0 out of 5 stars0 ratingsVisual Guide to Hedge Funds Rating: 0 out of 5 stars0 ratingsStrategic Asset Allocation in Fixed Income Markets: A Matlab Based User's Guide Rating: 0 out of 5 stars0 ratingsThe Trader's Guide to the Euro Area: Economic Indicators, the ECB and the Euro Crisis Rating: 0 out of 5 stars0 ratingsAlternative Assets: Investments for a Post-Crisis World Rating: 0 out of 5 stars0 ratingsQualified Appraisals and Qualified Appraisers: Expert Tax Valuation Witness Reports, Testimony, Procedure, Law, and Perspective Rating: 0 out of 5 stars0 ratingsAsymmetric Dependence in Finance: Diversification, Correlation and Portfolio Management in Market Downturns Rating: 0 out of 5 stars0 ratingsOperational Risk Assessment: The Commercial Imperative of a more Forensic and Transparent Approach Rating: 0 out of 5 stars0 ratingsPension Revolution: A Solution to the Pensions Crisis Rating: 0 out of 5 stars0 ratingsModelling Single-name and Multi-name Credit Derivatives Rating: 0 out of 5 stars0 ratingsMulti-Asset Investing: A Practitioner's Framework Rating: 0 out of 5 stars0 ratingsThe Art of Credit Derivatives: Demystifying the Black Swan Rating: 4 out of 5 stars4/5Credit Models and the Crisis: A Journey into CDOs, Copulas, Correlations and Dynamic Models Rating: 0 out of 5 stars0 ratingsHedge Fund Course Rating: 1 out of 5 stars1/5The Handbook of Risk Management: Implementing a Post-Crisis Corporate Culture Rating: 0 out of 5 stars0 ratingsAlternative Investments Complete Self-Assessment Guide Rating: 0 out of 5 stars0 ratingsHedge Funds Of Funds: A Guide for Investors Rating: 0 out of 5 stars0 ratingsAn Introduction to the Bond Markets Rating: 0 out of 5 stars0 ratings
Finance & Money Management For You
The Intelligent Investor, Rev. Ed: The Definitive Book on Value Investing Rating: 4 out of 5 stars4/5Capitalism and Freedom Rating: 4 out of 5 stars4/5The Psychology of Money: Timeless lessons on wealth, greed, and happiness Rating: 5 out of 5 stars5/5The Richest Man in Babylon Rating: 4 out of 5 stars4/5Die With Zero: Getting All You Can from Your Money and Your Life Rating: 4 out of 5 stars4/5The Great Reset: And the War for the World Rating: 4 out of 5 stars4/5Principles: Life and Work Rating: 4 out of 5 stars4/5The 7 Habits of Highly Effective People: 15th Anniversary Infographics Edition Rating: 5 out of 5 stars5/5Financial Words You Should Know: Over 1,000 Essential Investment, Accounting, Real Estate, and Tax Words Rating: 4 out of 5 stars4/5The Great Awakening: Defeating the Globalists and Launching the Next Great Renaissance Rating: 4 out of 5 stars4/5Good to Great: Why Some Companies Make the Leap...And Others Don't Rating: 4 out of 5 stars4/5Set for Life: An All-Out Approach to Early Financial Freedom Rating: 4 out of 5 stars4/5Just Keep Buying: Proven ways to save money and build your wealth Rating: 5 out of 5 stars5/5The Total Money Makeover by Dave Ramsey: Summary and Analysis Rating: 4 out of 5 stars4/5The Freedom Shortcut: How Anyone Can Generate True Passive Income Online, Escape the 9-5, and Live Anywhere Rating: 5 out of 5 stars5/5Buy, Rehab, Rent, Refinance, Repeat: The BRRRR Rental Property Investment Strategy Made Simple Rating: 5 out of 5 stars5/5The Book on Advanced Tax Strategies: Cracking the Code for Savvy Real Estate Investors Rating: 4 out of 5 stars4/5The Tax and Legal Playbook: Game-Changing Solutions To Your Small Business Questions Rating: 3 out of 5 stars3/5Built to Last: Successful Habits of Visionary Companies Rating: 4 out of 5 stars4/5Alchemy: The Dark Art and Curious Science of Creating Magic in Brands, Business, and Life Rating: 4 out of 5 stars4/5Wealthology: The Science of Smashing Money Blocks Rating: 3 out of 5 stars3/5The Price of Tomorrow: Why Deflation is the Key to an Abundant Future Rating: 5 out of 5 stars5/5Black Fortunes: The Story of the First Six African Americans Who Escaped Slavery and Became Millionaires Rating: 4 out of 5 stars4/5
Reviews for Hedge Fund Modelling and Analysis
0 ratings0 reviews
Book preview
Hedge Fund Modelling and Analysis - Paul Darbyshire
Preface
This book is a practical introduction to modelling and analysing hedge funds using the C++ programming language. The structure of the book is as follows. Chapter 1 gives an overview of the C++ syntax in enough detail to approach the material covered in the technical chapters. Chapter 1 also introduces the concept of object oriented programming which allow us to build large and complex programs that can be broken down into smaller self-contained reusable code units known as classes. We will develop a series of classes throughout the book to tackle many of the problems encountered. Please note that this book is not intended to be an exhaustive exploration of C++ to solve problems in modelling and analysing hedge fund data. In addition, C++ is used to facilitate the solution of such problems through object oriented programming methods and various details highlighted as and when necessary.
Chapters 2 and 3 give an update of the current state of the global hedge fund industry and a detailed look at the primary data sources available to hedge fund managers and analysts. With this fundamental knowledge in place, Chapters 4–7 cover the more quantitative and theoretical material needed to effectively analyse a series of hedge fund returns and extract the relevant information required in order to make critical investment decisions.
C++ Source Code
Throughout the book there are numerous C++ source boxes (e.g., Source 2.4) typically listing the AClass.h, AClass.cpp, and main.cpp files and a console window showing the results of the class implementation. For example, an extract from the Optimise class is shown in Source P.1.
Source P.1: A Sample C++ Source Code
Comment blocks, such as:
// ...
// main.cpp
// ...
are used to omit parts of the source code (above and below) when new code is added to existing definitions or implementations. As we progress through the book we will gradually reduce unnecessary overuse of comments (//) within source listings once we feel confident we have clearly defined such routines and concepts in previous listings.
Please note that we do not give any warranty for completeness, nor do we guarantee that the code is error free. Any damage or loss incurred in the application of the C++ source code, algorithms and classes discussed in the book are entirely the reader's responsibility. If you notice any errors in the C++ source code, algorithms or classes, or you wish to submit some new method as a C++ function, algorithm, class, model or some improvement of the method illustrated in the book, you are very welcome.
Hypothetical Hedge Fund Data
Throughout the book there is constant reference to many monthly hedge fund return series. The 10 hedge funds are all hypothetical and have been simulated by the authors as a unique data set for demonstration purposes only. The techniques and models used in the book can therefore be tested on the hypothetical data before being applied to real-life situations by the reader. The hypothetical data is nonetheless close to what would be expected in reality. The 10 funds are a mixture of several major hedge fund strategies i.e. Commodity Trading Advisor (CTA), Long/Short Equity (LS), Global Macro (GM) and Market Neutral (MN) strategies as described in Table P.1.
Table P.1 10 Hypothetical Hedge Funds
All data files used throughout the book are identified in italics e.g. 10_hedge_funds.dat.
Book Website
The official website for the book is located at: www.darbyshirehampton.com
The website provides free downloads to all of the hypothetical data, C++ programs and classes, as well as many other useful resources.
The authors can be contacted on any matter relating to the book, or in a professional capacity, at the following email addresses:
Paul Darbyshire: [email protected]
David Hampton: [email protected]
CHAPTER 1
Essential C++
This chapter covers the fundamental requirements necessary to allow the reader to get up and running building quantitative models using the C++ programming language. This introduction is in no way intended to be an in-depth treatment of the C++ programming language but more an overview of the basics required to build your own efficient and adaptable programs. Once the key concepts have been developed, object-oriented principles are introduced and many of the advantages of building quantitative systems using such programming approaches are outlined. It is assumed that the reader will have some prerequisite knowledge of a low-level programming language and the necessary computation skills to effectively grasp and apply the material presented here.
1.1 A Brief History of C and C++
C is a procedural1 programming language developed at Bell Laboratories between 1969 and 1973 for the UNIX operating system. Early versions of C were known as K&R C after the publication of the book The C Programming Language written by Brian Kernighan and Dennis Ritchie in 1978. However, as the language developed and became more standardised, a version known as ANSI2 C became more prominent. Although C is no longer the choice of many developers, there is still a huge amount of legacy software coded in it that is actively maintained. Indeed, C has greatly influenced other programming languages, in particular C++ which began purely as an extension of C.
Often described as a superset of the C language, C++ uses an entirely different set of programming concepts designed around the Object-Oriented Programming (OOP) paradigm. Solving a computer problem with OOP involves the design of so-called classes that are abstractions of physical objects containing the state, members, capabilities and methods of the object. C++ was initially developed by Bjarne Stroustrup in 1979 whilst at Bell Laboratories as an enhancement to C; originally known as C with Classes. The language was renamed C++ in the early 80s and by 1998, C++ was standardised as ANSI/ISO3 C++. During this time several new features were added to the language, including virtual functions, operator overloading, multiple inheritance and exception handling. The ANSI/ISO standard is based on two main components: the core language and the C++ Standard Library that incorporates the C Standard Library with a number of modifications optimised for use with the C++ language. The C++ Standard Library also includes most of the Standard Template Library (STL); a set of tools, such as containers and iterators that provide array-like functionality, as well as algorithms designed specifically for sorting and searching tasks. C++11 is the most recent complete overhaul of the C++ programming language approved by ANSI/ISO on 12 August 2011, replacing C++03, and superseded by C++14 on 18 August 2014. The naming convention follows the tradition of naming language versions by the year of the specification's publication, although it was formerly known as C++0x to take into account many publication delays. C++14 is the informal name for the most recent revision of the C++ ANSI/ISO standard, intended to be a small extension over C++11, featuring mainly bug fixes and small syntax improvements.
1.2 A Basic C++ Program
Without doubt the best method of learning a programming language is to actually start by writing and analysing programs. Source 1.1 implements a basic C++ program that simply outputs a string of text, once the program has been compiled and executed, to the console window. Although the program looks very simple it nevertheless contains many of the fundamental components that every C++ program generally requires.
Source 1.1: A basic C++ program
Statements beginning with a hash symbol (#) indicate directives to the preprocessor that initialise when the compiler is first invoked, in this case, to inform the compiler that certain functions from the C++ Standard Library must be included. #include
std::cout << \n
<< Hedge Fund Modelling and Analysis: An Object Oriented Approach Using C++
;
std::cin.get();
Although in this case there are only two occasions where we need std, you can imagine how this could quickly clog up code for very large programs. Note also that all C++ statements must end with a semi-colon (;).
A commonly identified problem with the C language is the issue of running out of names for definitions and functions when programs reach very large sizes eventually resulting in name clashes. Standard C++ has a mechanism to prevent such a clash through the use of the namespace keyword. Each set of C++ definitions in a library or program is wrapped into a namespace, and if some other definition has an identical name, but is in a different namespace, then there is no conflict. All Standard C++ libraries are wrapped in a single namespace called std and invoked with the using keyword:
using namespace std;
Whether to use using namespace std or explicitly state their use through using std::cout, for example, is purely a preference of programming style. The main reason we do not invoke using namespace std in our programs is that this leaves us the opportunity of defining our own namespaces if we wish and it is generally good practice to have only one namespace invocation in each program.
The main() function is the point at which all C++ programs start their execution even if there are several other functions declared in the same program. For this reason, it is an essential requirement that all C++ programs have a main() function within the body at some point in the program. Once the text is output to the console window, cin.get() is used to cause the program to pause so that the user can read the output and then close and exit the window by pressing any key. Technically, in C or C++ the main() function must return a value because it is declared as int i.e. the main function should return an integer data type. The int value that main() returns is usually the value that will be passed back to the operating system; in this case it is 0i.e. return 0 which indicates that the program ran successfully. It is not necessary to state return 0 explicitly, because the compiler invokes this automatically when main() terminates, but it is good practice to include a return type for all functions (including main()).
1.3 Variables
A variable is a name associated with a portion of memory used to store and manipulate the data associated with that variable. The compiler sets aside a specific amount of memory space to store the data assigned to the variable and associates the variable name with that memory address. As the name implies, variables can be changed within a program as and when required. When new data is assigned to the same variable, the old data is overwritten and restored in the same memory address. The data stored in a variable is only temporary and only exists as long as the variable itself exists (defined by the scope of the variable). If the data stored in a variable is required beyond its existence then it must be written to a permanent storage device, such as a disk or file.
A variable name can be any length and composed of lower and upper case letters, numbers and the underscore (_) character, but keep in mind that variables are case-sensitive. In practice, a programmer will usually develop their own variable naming convention but bear in mind that C++ reserves certain keywords for variable names so try not to clash with these. Table 1.1 shows a list of reserved C++ keywords.
Table 1.1 Reserved C++ keywords
There are sevenal built-in data types provided by C++ along with specific type modifiers to further quantify the data. A complete list of all the data types and their associated modifiers are described in Table 1.2.
Table 1.2 Common C++ data types
In Table 1.2, other than char (which has a size of exactly one byte), none of the fundamental types has a standard size (only a minimum size, at most). This does not mean that these types are of an undetermined size, but that there is no standard size across all compilers and machines; each compiler implementation can specify the sizes that best fit the architecture where the program is going to be executing. This rather generic size specification of data types allows the C++ language a lot of flexibility in adapting to work optimally on all kinds of platforms, both present and future.
1.3.1 Characters and Strings
When using the chardata type, we use single quotes, for example:
char Stock = MSFT
;
Certain characters, such as single (‘’) and double () quotes have special meaning in C++ and have to be treated with care. In addition, C++ reserves special characters for formatting text and other processing tasks known as character escape sequences (or backslash character constants) as shown in Table 1.3.
Table 1.3 Character escape sequences
A more versatile data type than char is string which can be a combination of characters, numbers, spaces and symbols of any length. C++ does not have a built-in data type to hold strings instead it is defined in the C++ Standard Library through the inclusion of the header file
Source 1.2: String variables
In Source 1.2, two string variables are declared and initialised and then joined together to form another string. The (+) symbol is used for joining (or concatenating) two variables together, and in this context the (+) symbol is often referred to as the concatenation operator.
1.3.2 Variable Declarations
Before a variable can be used in a program it must first be declared as shown in Source 1.3. Declaring the variable and its data type allows the compiler to set aside the appropriate amount of memory for storage and subsequent manipulation.
Source 1.3: Declaring variables
It is possible to declare more than one variable of the same type in the same declaration statement. It is also possible to assign initial values to variables whilst they are being declared through the process of initialisation, for example:
int x, y = 4, z = 3;
There is another useful method of initialising a variable known as constructor initialisation:
int x(0);
1.3.3 Type Casting
One way to force an expression to produce a result that is of a different type to the variables declared in the expression is to use a construct called cast (i.e. type casting). Source 1.4 shows an example of declaring two variables as int and dividing them to produce an int and double division through type casting.