What This Book Includes
        Is This Book for You
        What Do You Need to Use This Book
        How This Book is Organized
        Using Code Examples
        Customer Support


In recent years, quantitative finance has been an attractive field due to the intellectual challenge and high remuneration. Many scientists, engineers, and students wish to change their careers to become a quant developer or analyst in investment banks or hedge fund firms. Most of them have solid background in mathematics, statistical analysis, physics modeling, and programming, but lack knowledge and experience in quantitative finance. A question that they constantly ask is “what do I need to prepare myself to become a quant developer/analyst?” This book will provide answer to this question and prepare you with solid technical skills in quantitative analysis and development.

On the other hand, more and more individuals want to become independent (“retail”) quantitative traders who are looking to start their own quantitative or algorithmic trading business. The most common issue they are facing is what kind of background do they need in order to be success in quantitative trading? Most of those individuals received their advanced degrees in physics, math, engineering, or computer science. This kind of training in hard sciences will give them an edge in quantitative analysis and pricing complex derivative instruments. However, the capability to convert trading ideas into trading strategies and the programming skill in implementing the automatic trading system are equally important. This book will prepare you with all the necessary analysis and programming techniques to become a well-equipped individual quant trader.

So what kinds of applications, desktop or web, are more suitable in quantitative finance? Financial applications development began with desktop applications, which can be used in specific machines in which the applications have been installed. Generally, writing code for desktop application is relatively easier, and you have much greater control over how your application works. Another benefit is that desktop applications are always offline because they are executable programs that need not to be accessed over the internet. In my previously published book, Practical C# and WPF for Financial Markets, I presented the detailed explanation on how to build desktop applications in finance using C#, WPF, MVVM, and .NET framework.

In contrast to desktop applications, a web-based application is a software that can be accessed through the internet. The software and database are resided in a central server rather than being in the local desktop system. Web based applications are the better way to take advantage of today’s technology to enhance the productivity and efficiency. Web or distributed applications are mostly used on client-server networks where the user’s computer accesses information from the server or cloud computing server. There are some obvious advantages of web applications over desktop applications. Web applications need to be installed only once, which can avoid the burden in deploying in each client machine and make software updates and maintenance much easier. They are platform independent, adaptable in mobile application, and can be accessed from anywhere in the world.

Here, I would like to point out the difference between the website and web application, even though they are not entirely exclusive and the difference is simply a matter of perspective. Websites are primarily informational and defined by their content. In this sense, and http://www.espn .com are websites, not web applications. Web applications are primarily interactive, and allow users to perform actions. Google Gmail and Google Maps are examples of web applications. That is, a website consists of static content repository that is dealt out to all visitors, while a web application depends on interaction and requires user input and data processing.

If you are thinking about creating your own web applications, you have probably heard that there are two main design patterns: multi-page application (MPA) and single-page application (SPA). MPA works in a more traditional way. It has slower speed because it needs to fetch pages from the server for each request. The main advantage of MPA is its simple search engine optimization (SEO) scheme. The architecture of MPA allows you to optimize every page for search engines. Developer can easily add the meta tags for any page. Another advantage is that developing a multi-page application is much easier than SPA because MPA requires a smaller stack of technologies. MPA is more suitable for developing websites.

SPA is a web application that fits on a single web page with dynamic actions without the need to refresh the page. It is fast, as most resources like HTHL, CSS, and Scripts are only loaded once throughout the lifespan of application. SPA allows you to simulate the work of a desktop application. The architecture of SPA is arranged in such a way that when you go to a new page, only a portion of the content is updated. Thus, there is no need to reload the same elements from the server.

SPA is highly decoupled between client-side and server, and the codes for both ends can be kept separately. SPA interacts with the server only through the web service (or web API) built by server-side developers to fetch and display data. On the other hand, MPA has a tight coupling of front-end and back-end. It is usually one big project, which will house all the codes together. The codes in MPA for both ends are often inter-dependent. SPA also simplifies mobile development as we can reuse the same backend for web application and native mobile application, while MPA usually requires separate code base for mobile application.

SPA is a good fit for web application development. However, building single-page applications is a complicated task. It can be challenge to integrate server-side and client-side code well or even just to choose a productive project setup in the first place. This means that SPA usually requires more development effort to build than MPA.

I write this book with the intention of providing a complete and comprehensive explanation of ultra-modern web application development in quantitative finance using the latest technology stacks: ASP.NET Core 2.2 and SPA framework Angular 7. This book pays special attention to creating various business applications and reusable .NET/TypeScript libraries that can be used directly in real-world finance applications. Much of this book contains the original work based on my own programming experience when I was developing business applications for quantitative analysis in financial field.

Practical Quantitative Finance with ASP.NET Core and Angular provides everything you need to create your own advanced single-page web applications in quantitative finance and reusable packages using ASP.NET Core and Angular. Individually, each of these two frameworks is powerful and feature-rich, but using them together combines the dynamic flexibility of Angular with the solid infrastructure of ASP.NET Core. This book shows you how to use ASP.NET Core together with Angular to build a variety of financial applications that range from simple database, market data API, data visualization, quantitative analysis to pricing equity options and complex fixed income instruments, machine learning, and trading strategy development. I will try my best to introduce you to ultra-modern web application development in quantitative finance in a simple way – simple enough to be easily followed by a quant or .NET/web developer who has basic prior experience in developing business applications using .NET technology or JavaScript framework.

What this Book Includes

This book and its sample code listings, which are available for download at my website at, provide you with:

Is This Book for You?

You do not have to be an experienced quant developer/analyst or .NET/web developer to use this book. I designed this book to be useful to people of all levels of .NET/web programming experience and financial background. In fact, I believe that if you have some prior experience with quantitative analysis/ development and programming language C++, Java, R, Python, VBA, C#, or JavaScript, you will be able to sit down in front of your computer, start up Microsoft Visual Studio Community 2017, follow the examples provided in this book, and quickly become proficient with quantitative application development. For those of you who are already experienced quant analyst/developer or .NET programmers, I believe this book has much to offer as well. A great deal of the information in this book about .NET/web programming in quantitative finance is not available in other tutorial and reference books. In addition, you can use most of the example programs in this book directly in your own real-world application development. This book will provide you with a level of detail, explanation, instruction, and sample program code that will enable you to do just about anything related to quantitative finance application development using ASP.NET Core and Angular.

Perhaps you are a scientist, an engineer, a mathematician, or a student, rather than a professional quant developer/analyst, .NET programmer, or web developer; nevertheless, this book is still a good bet for you. In fact, my own background is in theoretical physics, a field involving extensive physical modeling, numerical calculations, and graphical representations of calculated data. I devoted my effort to this field for many years, starting from undergraduate up to PhD. My first computer experience was with FORTRAN. Later on, I had programming experience with Basic, C, C++, R, Python, JavaScript, and Matlab. I always tried to find an ideal development tool that would allow me not only to generate data easily (computation capability) but also to represent data graphically (graphics and chart power). The .NET Core and Microsoft Visual Studio development environment made it possible to develop such integrated applications. Ever since Microsoft .NET 1.0 came out, I have been in love with the C# language, and able to use this tool successfully to create powerful business applications for quantitative analysis.

Quant analysts/developers, individual quant traders, and .NET/web developers can use the majority of the example programs in this book routinely. Throughout the book, I emphasize the usefulness of web application development to real-world quantitative finance problems. If you follow the instructions presented in this book closely, you will easily be able to develop various practical business applications in quantitative finance, from linear analysis, machine learning to pricing engines, and trading strategy development. At the same time, I will not spend too much time discussing the programming style, execution speed, and code optimization, because a plethora of books out there already deals with these topics. Most of the example programs you will find in this book omit error handlings, which makes the code easier to understand by focusing only on the key concepts and practical applications.

What Do You Need to Use This Book?

You will need no special equipment to make the best use of this book and understand the algorithms. This book will take full advantage of open source frameworks and libraries. To run and modify the sample programs, you will need a computer capable of running either Windows 7, 8, or 10. The server-side software installed on your computer should include Visual Studio 2017 (Community version is fine), the .NET Core 2.2 SDK or higher, and SQL Server Express 2016 or higher. For the front end, you need to install Node.js version 8.x or 10.x, Angular 7, and Angular 7 CLI.

If you have .NET Core 2.1 SDK or older version, SQL Server Express 2014 or older versions, and Angular 6 or older version, you can also run most of the sample code with few modifications. Please remember, however, that this book is intended for .NET Core 2.2, SQL Server Express 2016, and Angular 7 and that all of the example programs were created and tested on this platform, so it is best to run the sample code on the same platform.

How the Book Is Organized

This book is organized into eleven chapters, each of which covers a different topic about quantitative finance applications using .NET Core and Angular. The following summaries of each chapter should give you an overview of the book’s content:

Chapter 1, Overview of ASP.NET Core and Angular
This chapter provides an overview of ASP.NET Core and Angular, which explains how to set up the tools, packages, and development environment required for building a single-page application using ASP.NET Core and Angular with the Visual Studio IDE.

Chapter 2, Angular Basics
This chapter provides a quick review of various features available in the Angular framework, including one- and two-way data binding, components, templates, routing, dependency injection, directives, and Inputs/Output decorators.

Chapter 3, Database and Web Services
This chapter introduces the SQL Server and Entity Framework Core, which are built-in features and shipped as part of the core product of Visual Studio 2017. It shows you how to create simple database and how to interact with the data in Angular applications via ASP.NET API web service.

Chapter 4, Market Data
This chapter explains how to interact with market data providers’ API and retrieve the free market data from online data source. These market data includes the end of the day (EOD) stock data, intraday data, real-time stock price quotes, and interest rate data.

Chapter 5, Data Visualization
Data visualization plays a critical role in quantitative finance and trading. Quant analysts and traders need to monitor the real-time changes in market and trading signals visually on their screen. In this chapter, I will show you how to use a client chart library called ECharts to create various charts and display the market data in an Angular singe-page application.

Chapter 6, Linear Analysis
This chapter presents the most fundamental analysis approach in quantitative finance based on linear analysis. I will discuss how to develop different business applications using the linear regression, principal component analysis (PCA), and correlation.

Chapter 7, Technical Indicators
This chapter discusses various technical indicators, which are often used in quantitative analysis. A technical indicator is just a mathematical calculation based on historic market data, which is used to predict market direction. I will show you how to convert various indicators provided in TA-Lib library into web services and how to apply them to your Angular applications.

Chapter 8, Machine Learning
This chapter discusses the advanced quantitative analysis techniques: machine learning. Machine-learning technique has become one of the most promising fields in quantitative finance. It is widely used in quantitative finance for predicting the future stock prices. This chapter will concentrate on the supervised learning and covers several commonly used machine-learning algorithms in finance, including the K-nearest neighbors, support vector machines, and neural networks.

Chapter 9, Options Pricing
This chapter covers the Black-Scholes formula used for options pricing. It shows how to use an open source library called QuantLib to calculate the price and Greeks of the European and American options. It also discusses how to use this library to price the other options, including barrier options, Bermudan options, and other exotic options.

Chapter 10, Pricing Fixed-Income Instruments
This chapter demonstrates how to price the fixed-income instruments, including interest rates, bonds, and credit default swaps. It also discusses various related topics, such as cash flows, term structures, yield curves, discount factors, and zero-coupon bonds. I will provide the detailed procedures on how to use the open-source QuantLib library to price these complex financial instruments.

Chapter 11, Trading Strategies and Backtesting
This chapter presents several trading strategies using the simple quantitative analysis techniques, including crossovers and z-score based on commonly used technical indicators. I will also present a long-short based backtesting framework, which allows you to examine the historical performance of your strategies in stock trading.

Using Code Examples

You may use the code in this book in your own applications and documentation. You do not need to contact the author or the publisher for permission unless you are 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 the example code listings does require permission. Incorporating a significant amount of example code from this book into your applications and documentation also requires permission. Integrating the example code from this book into commercial products is not allowed without written permission of the author.

Customer Support

I am always interested in hearing from readers, and enjoy learning of your thoughts on this book. You can send me comments by e-mail to: jxu at I also provide updates, bug fixes, and ongoing support via my website:

You can also obtain the complete source code for all of examples in this book from the foregoing website. At the same time, I created a code demonstration website at that shows a live demo for all examples included in this book.