Preface

Python was quickly becoming the de-facto language for data science, machine learning and natural language processing; it would unlock new sources of innovation. Python would allow us to engage with its sizeable open source community, bringing state-of-the-art technology in-house quickly, while allowing for customization.1

Kindmann and Taylor (2021)

Why this Book?

Technological trends like online trading platforms, open source software, and open financial data have significantly lowered or even completely removed the barriers of entry to the global financial markets. Individuals with only limited amounts of cash at their free disposal can get started, for example, with algorithmic trading within hours. Students and academics in financial disciplines with a little bit of background knowledge in programming can easily apply cutting edge innovations in machine and deep learning to financial data — on the notebooks they bring to their finance classes. On the hardware side, cloud providers offer professional compute and data processing capabilities starting at 5 USD per month, billed by the hour and with almost unlimited scalability. So far, academic and professional finance education has only partly reacted to these trends.

This book teaches both finance and the Python programming language from ground up. Nowadays, finance and programming in general are closely intertwined disciplines, with Python being one of the most widely used programming languages in the financial industry. The book presents all relevant foundations — from mathematics, finance, and programming — in an integrated but not too technical fashion. Traditionally, theoretical finance and computational finance have been more or less separate disciplines. The fact that programming classes (for example, in Python but also in C++) have become an integral part of Master of Financial Engineering and similar university programs shows how important programming skills have become in the field.

However, mathematical foundations, theoretical finance, and basic programming techniques are still quite often taught independent from each other and only later on combined to computational finance. This book takes a different approach in that the mathematical concepts — for example, from linear algebra and probability theory — provide the common background against which financial ideas and programming techniques alike are introduced. Abstract mathematical concepts are thereby motivated from two different angles: finance and programming. In addition, this approach allows for a new learning experience since both mathematical and financial concepts can directly be translated into executable code that can then be explored interactively.

Several readers of one of my other books, Python for Finance (2nd ed., 2018, O’Reilly), pointed out that it teaches neither finance or Python from the ground up. Indeed, the reader of that book is expected to have at least some experience in both finance and (Python) programming. Financial Theory with Python closes this gap in that it focuses on more fundamental concepts from both finance and Python programming. In that sense, readers who finish this book can naturally progress to Python for Finance to further build and improve their Python skills as applied to finance.

Target Audience

I have written a number of books about Python applied to finance. My company, The Python Quants offers a number of live and online training classes in Python for finance. All my previous books and the training classes expect the book readers and training participants to have already some background knowledge in both finance and Python programming or a similar language.

This book starts completely from scratch, just expecting some basic knowledge in mathematics, in particular from calculus, linear algebra, and probability theory. Although the book material is almost self-contained with regard to the mathematical concepts introduced, it is recommended to use an introductory mathematics book like the one by Pemberton and Rau (2016) for further details if needed.

Given this approach, the book targets students, academics, and professionals alike who want to learn about financial theory, financial data modeling, and the use of Python for computational finance. It is a systematic introduction to the field on which to build through more advanced books or training programs. Reader with a formal financial background will find the mathematical and financial elements of the book rather simple and straightforward. On the other hand, readers with a stronger programming background will find the Python elements rather simple and easy to understand.

Even if the reader does not intend to move on to more advanced topics in computational finance, algorithmic trading, or asset management, the Python and finance skills acquired through this book can be applied beneficially to standard problems in finance, such as the composition of investment portfolios according to Modern Portfolio Theory (MPT). The book also teaches, for example, how to value options and other derivatives by standard methods such as replication portfolios or risk-neutral pricing.

The book is also suited for executives in the financial industry who want to learn about the Python programming language as applied to finance. On the other hand, it can also be read by those already proficient in Python or another programming language who want to learn more about the application of Python in finance.

Overview of the Book

The book consists of the following chapters:

Chapter 1

The first chapter sets the stage for the rest of the book. It provides a concise history of finance, explains the approach of the book take towards using Python for finance, and shows how to set up a basic Python infrastructure suited to work with the code provided in the book and the Jupyter notebooks that accompany the book. The first chapter also provides a comprehensive overview of the literature referenced in the book or useful for a more detailed study of the different topics covered in the book.

Chapter 2

The chapter covers the most simple model economy in which the analysis of finance under uncertainty is possible: there are only two relevant dates and two uncertain future states possible. One sometimes speaks of a static two state economy. Despite its simplicity, the framework allows to introduce such basic notions of finance as net present value, expected return, volatility, contingent claims, option replication, arbitrage pricing, martingale measure, market completeness, risk-neutral pricing and mean-variance portfolios.

Chapter 3

This chapter introduces a third uncertain future state to the model, analyzing a static three state economy. This allows to analyze such notions as market incompleteness, indeterminacy of martingale measures, super-replication of contingent claims, and approximate replication of contingent claims. It also introduces the Capital Asset Pricing Model as an equilibrium pricing approach for financial assets.

Chapter 4

In this chapter, agents with their individual decision problems are introduced. The analysis in this chapter mainly rests on the dominating paradigm in finance for decision making under uncertainty: expected utility maximization. Based on a so-called representative agent equilibrium notions are introduced and the connection between optimality and equilibrium on the one hand and martingale measures and risk-neutral pricing on the other hand are illustrated. The representative agent is also one way of overcoming the difficulties that arise in economies with incomplete markets.

Chapter 5

This chapter generalizes the previous notions and results to a setting with a finite, but possibly large, number of uncertain future states. It requires a bit more mathematical formalism to analyze this general static economy.

Chapter 6

Building on the analysis of the general static economy, this chapter introduces dynamics to the financial modeling arsenal — to analyze two special cases of a dynamic economy in discrete time. The basic insight is that uncertainty about future states of an economy in general resolves gradually over time. This can be modeled by the use of stochastic processes, an example of which is the binomial process that can be represented visually by a binomial tree.

Chapter 7

The final chapter provides a wealth of additional resources to explore in the fields of mathematics, financial theory, and Python programming. It also provides guidance on how to proceed after the reader has finished this book.

Conventions Used in This Book

The following typographical conventions are used in this book:

Italic

Indicates new terms, URLs, email addresses, filenames, and file extensions.

Constant width

Used for program listings, as well as within paragraphs to refer to program elements such as variable or function names, databases, data types, environment variables, statements, and keywords.

Constant width bold

Shows commands or other text that should be typed literally by the user.

Constant width italic

Shows text that should be replaced with user-supplied values or by values determined by context.

Tip

This element signifies a tip or suggestion.

Note

This element signifies a general note.

Warning

This element indicates a warning or caution.

Using Code Examples

Supplemental material (code examples, exercises, etc.) will available for download later on.

If you have a technical question or a problem using the code examples, please send email to .

This book is here to help you get your job done. In general, if example code is offered with this book, you may use it in your programs and documentation. You do not need to contact us for permission unless you’re reproducing a significant portion of the code. For example, writing a program that uses several chunks of code from this book does not require permission. Selling or distributing examples from O’Reilly books does require permission. Answering a question by citing this book and quoting example code does not require permission. Incorporating a significant amount of example code from this book into your product’s documentation does require permission.

We appreciate, but generally do not require, attribution. An attribution usually includes the title, author, publisher, and ISBN. For example: “Financial Theory with Python by Yves Hilpisch (O’Reilly). Copyright 2021 Yves Hilpisch, 978-1-098-10435-1.”

If you feel your use of code examples falls outside fair use or the permission given above, feel free to contact us at .

O’Reilly Online Learning

Note

For more than 40 years, O’Reilly Media has provided technology and business training, knowledge, and insight to help companies succeed.

Our unique network of experts and innovators share their knowledge and expertise through books, articles, and our online learning platform. O’Reilly’s online learning platform gives you on-demand access to live training courses, in-depth learning paths, interactive coding environments, and a vast collection of text and video from O’Reilly and 200+ other publishers. For more information, visit http://oreilly.com.

How to Contact Us

Please address comments and questions concerning this book to the publisher:

  • O’Reilly Media, Inc.
  • 1005 Gravenstein Highway North
  • Sebastopol, CA 95472
  • 800-998-9938 (in the United States or Canada)
  • 707-829-0515 (international or local)
  • 707-829-0104 (fax)

We have a web page for this book, where we list errata, examples, and any additional information. You can access this page at https://www.oreilly.com/library/view/financial-theory-with/9781098104344/.

Email to comment or ask technical questions about this book.

For news and information about our books and courses, visit http://oreilly.com.

Find us on Facebook: http://facebook.com/oreilly.

Follow us on Twitter: http://twitter.com/oreillymedia.

Watch us on YouTube: http://www.youtube.com/oreillymedia.

1 Kindman, Andrew and Tom Taylor (2021): “Why We Rewrote our USD30 billion Asset Management Platform in Python.” 21. March 2021, https://man.com.

..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
18.117.182.179