codefinance.training

Coding for Finance

Machine Learning for Algorithmic Trading

Leverage machine learning to design and back-test automated trading strategies for real-world markets using pandas, TA-Lib, scikit-learn, LightGBM, SpaCy, Gensim, TensorFlow 2, Zipline, backtrader, Alphalens, and pyfolio.

Key Features

  • Design, train, and evaluate machine learning algorithms that underpin automated trading strategies
  • Create a research and strategy development process to apply predictive modeling to trading decisions
  • Leverage NLP and deep learning to extract tradeable signals from market and alternative data

Book Description

The explosive growth of digital data has boosted the demand for expertise in trading strategies that use machine learning (ML). This revised and expanded second edition enables you to build and evaluate sophisticated supervised, unsupervised, and reinforcement learning models.

This book introduces end-to-end machine learning for the trading workflow, from the idea and feature engineering to model optimization, strategy design, and backtesting. It illustrates this by using examples ranging from linear models and tree-based ensembles to deep-learning techniques from cutting edge research.

This edition shows how to work with market, fundamental, and alternative data, such as tick data, minute and daily bars, SEC filings, earnings call transcripts, financial news, or satellite images to generate tradeable signals. It illustrates how to engineer financial features or alpha factors that enable an ML model to predict returns from price data for US and international stocks and ETFs. It also shows how to assess the signal content of new features using Alphalens and SHAP values and includes a new appendix with over one hundred alpha factor examples.

By the end, you will be proficient in translating ML model predictions into a trading strategy that operates at daily or intraday horizons, and in evaluating its performance.

“Algorithmic Trading is about timing the market using data and algorithms in order to improve your own trading performance, outcomes, and earnings. The wealth of techniques, algorithms, and models that are used for those purposes are presented comprehensively in this giant book and are also applicable to countless other predictive modeling applications and diverse use cases. That makes this an excellent machine learning book for all learners and users of predictive algorithms in data science and analytics.”

Dr Kirk Borne, Principal Data Scientist, Data Science Fellow, and Executive Advisor at Booz Allen Hamilton, and co-author of Ten Signs of Data Science Maturity

Machine Learning in Finance: From Theory to Practice

This book introduces machine learning methods in finance. It presents a unified treatment of machine learning and various statistical and computational disciplines in quantitative finance, such as financial econometrics and discrete time stochastic control, with an emphasis on how theory and hypothesis tests inform the choice of algorithm for financial data modeling and decision making. With the trend towards increasing computational resources and larger datasets, machine learning has grown into an important skillset for the finance industry. This book is written for advanced graduate students and academics in financial econometrics, mathematical finance and applied statistics, in addition to quants and data scientists in the field of quantitative finance.

Machine Learning in Finance: From Theory to Practice is divided into three parts, each part covering theory and applications. The first presents supervised learning for cross-sectional data from both a Bayesian and frequentist perspective. The more advanced material places a firm emphasis on neural networks, including deep learning, as well as Gaussian processes, with examples in investment management and derivative modeling. The second part presents supervised learning for time series data, arguably the most common data type used in finance with examples in trading, stochastic volatility and fixed income modeling. Finally, the third part presents reinforcement learning and its applications in trading, investment and wealth management. Python code examples are provided to support the readers’ understanding of the methodologies and applications. The book also includes more than 80 mathematical and programming exercises, with worked solutions available to instructors. As a bridge to research in this emergent field, the final chapter presents the frontiers of machine learning in finance from a researcher’s perspective, highlighting how many well-known concepts in statistical physics are likely to emerge as important methodologies for machine learning in finance.

“This volume aims to present a broad yet technical treatment of (ML) algorithms used by financial practitioners and scholars alike. … the book fills a large void. … This encourages reproducibility as well as learning by doing, which is highly appreciated.” (Guillaume Coqueret, Quantitative Finance, October 15, 2020)

The Heston Model and its Extensions in Matlab and C#

Tap into the power of the most popular stochastic volatility model for pricing equity derivatives

Since its introduction in 1993, the Heston model has become a popular model for pricing equity derivatives, and the most popular stochastic volatility model in financial engineering. This vital resource provides a thorough derivation of the original model, and includes the most important extensions and refinements that have allowed the model to produce option prices that are more accurate and volatility surfaces that better reflect market conditions. The book’s material is drawn from research papers and many of the models covered and the computer codes are unavailable from other sources.

The book is light on theory and instead highlights the implementation of the models. All of the models found here have been coded in Matlab and C#. This reliable resource offers an understanding of how the original model was derived from Ricatti equations, and shows how to implement implied and local volatility, Fourier methods applied to the model, numerical integration schemes, parameter estimation, simulation schemes, American options, the Heston model with time-dependent parameters, finite difference methods for the Heston PDE, the Greeks, and the double Heston model.

  • A groundbreaking book dedicated to the exploration of the Heston model—a popular model for pricing equity derivatives
  • Includes a companion website, which explores the Heston model and its extensions all coded in Matlab and C#
  • Written by Fabrice Douglas Rouah a quantitative analyst who specializes in financial modeling for derivatives for pricing and risk management

Engaging and informative, this is the first book to deal exclusively with the Heston Model and includes code in Matlab and C# for pricing under the model, as well as code for parameter estimation, simulation, finite difference methods, American options, and more.

In his excellent new book, Fabrice Rouah provides a careful presentation of all aspects of the Heston model, with a strong emphasis on getting the model up and running in practice. This highly practical and useful book is recommended for anyone working with stochastic volatility models.”
–Leif B. G. Andersen, Bank of America Merrill Lynch

 

“Without a doubt, Fabrice provides a very valuable contribution to quantitative analysts interested in pricing options with state-of-the art techniques.”
–Marco Avellaneda, New York University

 

“The Heston model is one of the great success stories of academic finance. Rouah’s impressive book provides users with all the tools required to implement the Heston model, and wonderfully bridges the gap between academia and practice.”
–Peter Christoffersen, University of Toronto

 

“In this encyclopedic work, the author takes delight in exploring every aspect of the Heston model. Together with its included Matlab and C# code, this book will prove invaluable to anyone interested in option pricing. I highly recommend it.”
–Jim Gatheral, Baruch College author of The Volatility Surface: A Practitioner’s Guide

Stochastic Simulation and Applications in Finance with MATLAB Programs

Stochastic Simulation and Applications in Finance with MATLAB Programs explains the fundamentals of Monte Carlo simulation techniques, their use in the numerical resolution of stochastic differential equations and their current applications in finance. Building on an integrated approach, it provides a pedagogical treatment of the need–to–know materials in risk management and financial engineering.

The book takes readers through the basic concepts, covering the most recent research and problems in the area, including: the quadratic re–sampling technique, the Least Squared Method, the dynamic programming and Stratified State Aggregation technique to price American options, the extreme value simulation technique to price exotic options and the retrieval of volatility method to estimate Greeks.   The authors also present modern term structure of interest rate models and pricing swaptions with the BGM market model, and give a full explanation of corporate securities valuation and credit risk based on the structural approach of Merton. Case studies on financial guarantees illustrate how to implement the simulation techniques in pricing and hedging.

“This book provides a very useful set of tools for those who are interested in the simulation method of asset pricing and its implementation with MatLab. It is pitched at just the right level for anyone who seeks to learn about this fascinating area of finance. The collection of specific topics thoughtfully selected by the authors, such as credit risk, loan guarantee and value–at–risk, is an additional nice feature, making it a great source of reference for researchers and practitioners. The book is a valuable contribution to the fast growing area of quantitative finance.”

–Tan Wang, Sauder School of Business, UBC

This book is a good companion to text books on theory, so if you want to get straight to the meat of implementing the classical quantitative finance models here′s the answer.

—Paul Wilmott, wilmott.com

This powerful book is a comprehensive guide for Monte Carlo methods in finance. Every quant knows that one of the biggest issues in finance is to well understand the mathematical framework in order to translate it in programming code. Look at the chapter on Quasi Monte Carlo or the paragraph on variance reduction techniques and you will see that Huu Tue Huynh, Van Son Lai and Issouf Soumaré have done a very good job in order to provide a bridge between the complex mathematics used in finance and the programming implementation. Because it adopts both theoretical and practical point of views with a lot of applications, because it treats about some sophisticated financial problems (like Brownian bridges, jump processes, exotic options pricing or Longstaff–Schwartz methods) and because it is easy to understand, this handbook is valuable for academics, students and financial engineers who want to learn the computational aspects of simulations in finance.

—Thierry Roncalli, Head of Investment Products and Strategies, SGAM Alternative Investments & Professor of Finance, University of Evry

Foundations of Computational Finance with MATLAB®

Foundations of Computational Finance with MATLAB® is an introductory text for both finance professionals looking to branch out from the spreadsheet, and for programmers who wish to learn more about finance. As financial data grows in volume and complexity, its very nature has changed to the extent that traditional financial calculators and spreadsheet programs are simply no longer enough. Today’s analysts need more powerful data solutions with more customization and visualization capabilities, and MATLAB provides all of this and more in an easy-to-learn skillset.

This book walks you through the basics, and then shows you how to stretch your new skills to create customized solutions. Part I demonstrates MATLAB’s capabilities as they apply to traditional finance concepts, and PART II shows you how to create interactive and reusable code, link with external data sources, communicate graphically, and more.

From the Back Cover

Staying competitive in corporate and investment finance today means a lot more than proficiency with spreadsheets and calculators. Advances in data collection and analytics have fundamentally changed how we manage money, and traditional tools and data sets are no longer enough. But where’s the best place to start? Foundations of Computational Finance with MATLAB® offers a robust introduction to the most up-do-date ways traditional finance practices are being optimized on the MATLAB® computational platform.

With an understanding of linear algebra and statistics, as well as access to MATLAB® and the associated toolboxes, you can use this hands-on guide alongside your computer to develop the knowledge base and skillset to enter the world of computational finance. Designed for the self-learner—clarifying chapter introductions, referenced source material, and sample codes walk you through creating interactive and reusable code, measuring and forecasting uncertainty, using graphics to analyze and communicate results in multiple formats, and more.

Presented in a masterful pedagogy by a MathWorks Certified MATLAB® Associate, the authoritative coverage focuses on developing a practical understanding of MATLAB®‘s built-in functions in order to develop programming solutions. It enables users to immediately use the platform in real-world practice, with a solid foundation for launching into more advanced operations. Students and professionals alike can efficiently jumpstart their path to success in the financial industry with:

  • Best practices for working with data, dates and times, and basic programming
  • Step-by-step instruction for importing, manipulating, and visualizing financial data from popular external sources
  • Illustrative explanations for applying time value of money calculations and applications to cash flows, time periods, and interest rates

This versatile resource stays with you after you’ve mastered the basics with a section of appendices featuring handy, quick- reference MATLAB® functions, as well as guidance for publishing code, creating interactive files, and conducting regression and time series analysis.

Foundations of Computational Finance with MATLAB® is your one-stop primer to the new approach to financial analysis and management.

Reproducible Finance with R

Reproducible Finance with R: Code Flows and Shiny Apps for Portfolio Analysis is a unique introduction to data science for investment management that explores the three major R/finance coding paradigms, emphasizes data visualization, and explains how to build a cohesive suite of functioning Shiny applications. The full source code, asset price data and live Shiny applications are available at reproduciblefinance.com. The ideal reader works in finance or wants to work in finance and has a desire to learn R code and Shiny through simple, yet practical real-world examples.

The book begins with the first step in data science: importing and wrangling data, which in the investment context means importing asset prices, converting to returns, and constructing a portfolio. The next section covers risk and tackles descriptive statistics such as standard deviation, skewness, kurtosis, and their rolling histories. The third section focuses on portfolio theory, analyzing the Sharpe Ratio, CAPM, and Fama French models. The book concludes with applications for finding individual asset contribution to risk and for running Monte Carlo simulations. For each of these tasks, the three major coding paradigms are explored and the work is wrapped into interactive Shiny dashboards.

Introduction to Computational Economics Using Fortran

Introduction to Computational Economics Using Fortran is the essential guide to conducting economic research on a computer. Aimed at students of all levels of education as well as advanced economic researchers, it facilitates the first steps into writing programs using Fortran.

Introduction to Computational Economics Using Fortran assumes no prior experience as it introduces the reader to this programming language. It shows the reader how to apply the most important numerical methods conducted by computational economists using the toolbox that accompanies this text. It offers various examples from economics and finance organized in self-contained chapters that speak to a diverse range of levels and academic backgrounds. Each topic is supported by an explanation of the theoretical background, a demonstration of how to implement the problem on the computer, and a discussion of simulation results. Readers can work through various exercises that promote practical experience and deepen their economic and technical insights.

This textbook is accompanied by a website from which readers can download all program codes as well as a numerical toolbox, and receive technical information on how to install Fortran on their computer.

QuantLib Python Cookbook

The book collects updated posts from Goutham’s blog and the transcripts of the screencasts that Luigi is publishing on YouTube.

The posts and screencasts use Jupyter notebooks to demonstrate the QuantLib library. Together, they provide a sort of cookbook that showcases features of the library by means of working examples and provides guidance to its use.

Among other content, the book also includes notebooks that reproduce the results from the often-cited Ametrano and Bianchetti paper, Everything You Always Wanted to Know About Multiple Interest Rate Curve Bootstrapping but Were Afraid to Ask.

If you’re interested in the architecture of QuantLib and want to know how to extend it, you might want to look at Implementing QuantLib, too.

Implementing QuantLib

This book is a report on the design and implementation of QuantLib, alike in spirit—but, hopefully, with less frightening results—to the “How I did it” book prominently featured in Mel Brooks’ Young Frankenstein (in this case, of course, it would be “how we did it”). If you are, or want to be, a QuantLib user, you will find here useful information on the design of the library that might not be readily apparent when reading the code. If you’re working in quantitative finance, even if not using QuantLib, you can still read it as a field report on the design of a financial library. You will find that it covers issues that you might also face, as well as some possible solutions and their rationale. Based on your constraints, it is possible—even likely—that you will choose other solutions; but you might profit from this discussion just the same.The book is primarily aimed at users wanting to extend the library with their own instruments or models; if you desire to do so, the description of the available class hierarchies and frameworks will provide you with information about the hooks you need to integrate your code with QuantLib and take advantage of its facilities. If you’re not this kind of user, don’t give up on the book yet; you can find useful information too. However, you might want to look at the QuantLib Python Cookbook instead; it’s available in all electronic formats from Leanpub.

Advanced Quantitative Finance with C++

This book will introduce you to the key mathematical models used to price financial derivatives, as well as the implementation of main numerical models used to solve them. In particular, equity, currency, interest rates, and credit derivatives are discussed. In the first part of the book, the main mathematical models used in the world of financial derivatives are discussed. Next, the numerical methods used to solve the mathematical models are presented. Finally, both the mathematical models and the numerical methods are used to solve some concrete problems in equity, forex, interest rate, and credit derivatives.

The models used include the Black-Scholes and Garman-Kohlhagen models, the LIBOR market model, structural and intensity credit models. The numerical methods described are Monte Carlo simulation (for single and multiple assets), Binomial Trees, and Finite Difference Methods. You will find implementation of concrete problems including European Call, Equity Basket, Currency European Call, FX Barrier Option, Interest Rate Swap, Bankruptcy, and Credit Default Swap in C++.