You are previewing Practical C++ Financial Programming.
O'Reilly logo
Practical C++ Financial Programming

Book Description

Practical C++ Financial Programming is a hands-on book for programmers wanting to apply C++ to programming problems in the financial industry. The book explains those aspects of the language that are more frequently used in writing financial software, including the STL, templates, and various numerical libraries. The book also describes many of the important problems in financial engineering that are part of the day-to-day work of financial programmers in large investment banks and hedge funds. The author has extensive experience in the New York City financial industry that is now distilled into this handy guide.

Focus is on providing working solutions for common programming problems. Examples are plentiful and provide value in the form of ready-to-use solutions that you can immediately apply in your day-to-day work. You’ll learn to design efficient, numerical classes for use in finance, as well as to use those classes provided by Boost and other libraries. You’ll see examples of matrix manipulations, curve fitting, histogram generation, numerical integration, and differential equation analysis, and you’ll learn how all these techniques can be applied to some of the most common areas of financial software development. These areas include performance price forecasting, optimizing investment portfolios, and more. The book style is quick and to-the-point, delivering a refreshing view of what one needs to master in order to thrive as a C++ programmer in the financial industry.

  • Covers aspects of C++ especially relevant to financial programming.
  • Provides working solutions to commonly-encountered problems in finance.
  • Delivers in a refreshing and easy style with a strong focus on the practical.
  • Table of Contents

    1. Cover
    2. Title
    3. Copyright
    4. Dedication
    5. Contents at a Glance
    6. Contents
    7. About the Author
    8. About the Technical Reviewer
    9. Acknowledgments
    10. Introduction
    11. Chapter 1: The Fixed Income Market
      1. Fixed Income Overview
      2. Why Using C++
      3. Calculating Simple Interest Rates
        1. Problem
        2. Solution
        3. How It Works
        4. Complete Code
        5. Sample Use
      4. Compound Interest
        1. Problem
        2. Solution
        3. How It Works
        4. Complete Code
        5. Sample Use
      5. Modeling Cash Flows
        1. Problem
        2. Solution
        3. Complete Code
        4. Running the Code
      6. Modeling Bonds
        1. Problem
        2. Solution
        3. Complete Code
        4. Running the Code
      7. Further Reference
      8. Conclusion
    12. Chapter 2: The Equities Market
      1. Equities Market Concepts
      2. Moving Average Calculation
        1. Problem
        2. Solution
        3. Complete Code
        4. Running the Code
      3. Calculating Volatility
        1. Problem
        2. Solution
        3. Complete Code
        4. Running the Code
      4. Computing Instrument Correlation
        1. Problem
        2. Solution
        3. Complete Code
        4. Running the Code
      5. Calculating Fundamental Indicators
        1. Problem
        2. Solution
        3. Complete Code
        4. Running the Code
      6. Conclusion
    13. Chapter 3: C++ Programming Techniques in Finance
      1. Calculating Interest Rates for Investment Instruments
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Creating Financial Statement Objects
        1. Solution
        2. Smart Pointers
        3. Using Auto Pointers
        4. Complete Code
        5. Transferring Ownership
        6. Pitfalls of Auto Pointers
      3. Determining Credit Ratings
        1. Solution
        2. Using Shared Pointers
        3. Complete Code
        4. Using the auto Keyword
      4. Collecting Transaction Data
        1. Solution
        2. Exception Handling
        3. Complete Code
      5. Implementing Vector Operations
        1. Solution
        2. Operator Overloading
        3. Complete Code
      6. Conclusion
    14. Chapter 4: Common Libraries for Financial Applications
      1. Handling Analyst Recommendations
        1. Solution
        2. More About STL Vectors and Maps
        3. Complete Code
      2. Performing Time-Series Transformations
        1. Solution
        2. Using STL Algorithms
        3. Complete Code
        4. Running the Code
      3. Copying Transaction Files
        1. Solution
        2. Boost Libraries
        3. Complete Code
        4. Running the Code
      4. Handling Dates
        1. Solution
        2. Complete Code
        3. Running the Code
      5. Conclusion
    15. Chapter 5: Designing Numerical Classes
      1. Representing Matrices in C++
        1. Solution
        2. Complete Code
      2. Using Templates to Calculate Factorials
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Representing Calmar Ratios at Compile Time
        1. Solution
        2. Representing Calmar Ratios
        3. Complete Code
        4. Running the Code
      4. Generating Statistical Data
        1. Solution
        2. Probability Distributions
        3. Complete Code
        4. Running the Code
      5. Conclusion
    16. Chapter 6: Plotting Financial Data
      1. Plotting with Gnuplot
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Plotting Data from a GUI
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Conclusion
    17. Chapter 7: Linear Algebra
      1. Using Basic Linear Algebra Operations
        1. Solution
        2. Complete Code
      2. Using Matrix-Oriented Operations
        1. Solution
        2. Complete Code
        3. Running the Application
      3. Calculate the Determinant of a Matrix
        1. Solution
        2. Complete Code
      4. Conclusion
    18. Chapter 8: Interpolation
      1. Linear Interpolation
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Polynomial Interpolation
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Conclusion
    19. Chapter 9: Calculating Roots of Equations
      1. Bisection Method
        1. Solution
        2. Complete Code
        3. Running the Code
      2. The Secant Method
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Newton’s Method
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    20. Chapter 10: Numerical Integration
      1. The Midpoint Method
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Trapezoid Method
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Using Simpson’s Method
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    21. Chapter 11: Solving ODEs and PDEs
      1. Solving Ordinary Differential Equations
        1. Solution
        2. Euler’s Method
        3. Complete Code
        4. Running the Code
      2. Runge-Kutta Method for Solving ODEs
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Solving the Black-Scholes Equation
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    22. Chapter 12: Optimization
      1. Interfacing with a Linear Programming Solver
        1. Solution
        2. Linear Programming Concepts
        3. Using LP Solver Libraries
        4. Complete Code
        5. Running the Code
      2. Solving Two-Dimensional Investment Problems
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Creating Mixed-Integer Programming Models
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    23. Chapter 13: Asset and Portfolio Optimization
      1. Financial Resource Allocation
        1. Solution
        2. Implementation
        3. Complete Code
        4. Running the Code
      2. Portfolio Optimization
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Extensions to Modified CAP
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    24. Chapter 14: Monte Carlo Methods
      1. Monte Carlo-Based Integral Computation
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Simulating Asset Prices
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Calculating Option Probabilities
        1. Solution
        2. Determining Profit Probabilities
        3. Complete Code
        4. Running the Code
      4. Conclusion
    25. Chapter 15: Extending Financial Libraries
      1. Exporting C++ Stock Handling Code to Python
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Exporting C++ Classes Directly to Python
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Using Lua as an Extension Language
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    26. Chapter 16: Using C++ with R and Maxima
      1. Integrating C++ with R
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Integrating with the Maxima CAS
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Conclusion
    27. Chapter 17: Multithreading
      1. Creating Threads with the Pthreads Library
        1. Solution
        2. Complete Code
        3. Running the Code
      2. Calculating Options Probabilities in Parallel
        1. Solution
        2. Complete Code
        3. Running the Code
      3. Using Mutexes to Prevent Unsynchronized Access
        1. Solution
        2. Complete Code
        3. Running the Code
      4. Conclusion
    28. Appendix A: C++11/14 Features
      1. Automatic Type Detection
      2. Lambdas
      3. User-Defined Literals
      4. Range-based for
      5. Rvalue References
      6. New Function Declarator Syntax and Decltype
      7. Delegating Constructors
      8. Inheriting Constructors
      9. Generalized Attributes
      10. Generalized Constant Expressions
      11. Null Pointer Constant
      12. Defaulted and Deleted Member Functions
      13. Right-Angle Brackets
      14. Initializer Lists
    29. Index