O'Reilly logo

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Mastering R for Quantitative Finance

Book Description

Use R to optimize your trading strategy and build up your own risk management system

In Detail

R is a powerful open source functional programming language that provides high level graphics and interfaces to other languages. Its strength lies in data analysis, graphics, visualization, and data manipulation. R is becoming a widely used modeling tool in science, engineering, and business.

The book is organized as a step-by-step practical guide to using R. Starting with time series analysis, you will also learn how to forecast the volume for VWAP Trading. Among other topics, the book covers FX derivatives, interest rate derivatives, and optimal hedging. The last chapters provide an overview on liquidity risk management, risk measures, and more.

The book pragmatically introduces both the quantitative finance concepts and their modeling in R, enabling you to build a tailor-made trading system on your own. By the end of the book, you will be well versed with various financial techniques using R and will be able to place good bets while making financial decisions.

What You Will Learn

  • Analyze high frequency financial data

  • Build, calibrate, test, and implement theoretical models such as cointegration, VAR, GARCH, APT, Black-Scholes, Margrabe, logoptimal portfolios, core-periphery, and contagion

  • Solve practical, real-world financial problems in R related to big data, discrete hedging, transaction costs, and more.

  • Discover simulation techniques and apply them to situations where analytical formulas are not available

  • Create a winning arbitrage, speculation, or hedging strategy customized to your risk preferences

  • Understand relationships between market factors and their impact on your portfolio

  • Assess the trade-off between accuracy and the cost of your trading strategy

  • Downloading the example code for this book. You can download the example code files for all Packt books you have purchased from your account at http://www.PacktPub.com. If you purchased this book elsewhere, you can visit http://www.PacktPub.com/support and register to have the files e-mailed directly to you.

    Table of Contents

    1. Mastering R for Quantitative Finance
      1. Table of Contents
      2. Mastering R for Quantitative Finance
      3. Credits
      4. About the Authors
      5. About the Reviewers
      6. www.PacktPub.com
        1. Support files, eBooks, discount offers, and more
          1. Why subscribe?
          2. Free access for Packt account holders
      7. Preface
        1. What this book covers
        2. What you need for this book
        3. Who this book is for
        4. Conventions
        5. Reader feedback
        6. Customer support
          1. Downloading the example code
          2. Errata
          3. Piracy
          4. Questions
      8. 1. Time Series Analysis
        1. Multivariate time series analysis
          1. Cointegration
          2. Vector autoregressive models
            1. VAR implementation example
          3. Cointegrated VAR and VECM
        2. Volatility modeling
          1. GARCH modeling with the rugarch package
            1. The standard GARCH model
            2. The Exponential GARCH model (EGARCH)
            3. The Threshold GARCH model (TGARCH)
          2. Simulation and forecasting
        3. Summary
        4. References and reading list
      9. 2. Factor Models
        1. Arbitrage pricing theory
          1. Implementation of APT
          2. Fama-French three-factor model
        2. Modeling in R
          1. Data selection
          2. Estimation of APT with principal component analysis
          3. Estimation of the Fama-French model
        3. Summary
        4. References
      10. 3. Forecasting Volume
        1. Motivation
        2. The intensity of trading
        3. The volume forecasting model
        4. Implementation in R
          1. The data
          2. Loading the data
          3. The seasonal component
          4. AR(1) estimation and forecasting
          5. SETAR estimation and forecasting
          6. Interpreting the results
        5. Summary
        6. References
      11. 4. Big Data – Advanced Analytics
        1. Getting data from open sources
        2. Introduction to big data analysis in R
        3. K-means clustering on big data
          1. Loading big matrices
          2. Big data K-means clustering analysis
        4. Big data linear regression analysis
          1. Loading big data
          2. Fitting a linear regression model on large datasets
        5. Summary
        6. References
      12. 5. FX Derivatives
        1. Terminology and notations
        2. Currency options
        3. Exchange options
          1. Two-dimensional Wiener processes
          2. The Margrabe formula
          3. Application in R
        4. Quanto options
          1. Pricing formula for a call quanto
          2. Pricing a call quanto in R
        5. Summary
        6. References
      13. 6. Interest Rate Derivatives and Models
        1. The Black model
          1. Pricing a cap with Black's model
        2. The Vasicek model
        3. The Cox-Ingersoll-Ross model
        4. Parameter estimation of interest rate models
        5. Using the SMFI5 package
        6. Summary
        7. References
      14. 7. Exotic Options
        1. A general pricing approach
        2. The role of dynamic hedging
        3. How R can help a lot
        4. A glance beyond vanillas
        5. Greeks – the link back to the vanilla world
        6. Pricing the Double-no-touch option
        7. Another way to price the Double-no-touch option
        8. The life of a Double-no-touch option – a simulation
        9. Exotic options embedded in structured products
        10. Summary
        11. References
      15. 8. Optimal Hedging
        1. Hedging of derivatives
          1. Market risk of derivatives
          2. Static delta hedge
          3. Dynamic delta hedge
          4. Comparing the performance of delta hedging
        2. Hedging in the presence of transaction costs
          1. Optimization of the hedge
          2. Optimal hedging in the case of absolute transaction costs
          3. Optimal hedging in the case of relative transaction costs
        3. Further extensions
        4. Summary
        5. References
      16. 9. Fundamental Analysis
        1. The basics of fundamental analysis
        2. Collecting data
        3. Revealing connections
        4. Including multiple variables
        5. Separating investment targets
        6. Setting classification rules
        7. Backtesting
        8. Industry-specific investment
        9. Summary
        10. References
      17. 10. Technical Analysis, Neural Networks, and Logoptimal Portfolios
        1. Market efficiency
        2. Technical analysis
          1. The TA toolkit
          2. Markets
          3. Plotting charts - bitcoin
          4. Built-in indicators
            1. SMA and EMA
            2. RSI
            3. MACD
          5. Candle patterns: key reversal
          6. Evaluating the signals and managing the position
          7. A word on money management
          8. Wraping up
        3. Neural networks
          1. Forecasting bitcoin prices
            1. Evaluation of the strategy
        4. Logoptimal portfolios
          1. A universally consistent, non-parametric investment strategy
          2. Evaluation of the strategy
        5. Summary
        6. References
      18. 11. Asset and Liability Management
        1. Data preparation
          1. Data source at first glance
          2. Cash-flow generator functions
          3. Preparing the cash-flow
        2. Interest rate risk measurement
        3. Liquidity risk measurement
        4. Modeling non-maturity deposits
          1. A Model of deposit interest rate development
          2. Static replication of non-maturity deposits
        5. Summary
        6. References
      19. 12. Capital Adequacy
        1. Principles of the Basel Accords
          1. Basel I
          2. Basel II
            1. Minimum capital requirements
            2. Supervisory review
            3. Transparency
          3. Basel III
        2. Risk measures
          1. Analytical VaR
          2. Historical VaR
          3. Monte-Carlo simulation
        3. Risk categories
          1. Market risk
          2. Credit risk
          3. Operational risk
        4. Summary
        5. References
      20. 13. Systemic Risks
        1. Systemic risk in a nutshell
        2. The dataset used in our examples
        3. Core-periphery decomposition
          1. Implementation in R
          2. Results
        4. The simulation method
          1. The simulation
          2. Implementation in R
          3. Results
        5. Possible interpretations and suggestions
        6. Summary
        7. References
      21. Index