100% found this document useful (11 votes)
3K views

Build a Robo Advisor with Python From Scratch Automate your financial and investment decisions MEAP Rob Reider 2024 scribd download

Robo

Uploaded by

marckmincy0e
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
100% found this document useful (11 votes)
3K views

Build a Robo Advisor with Python From Scratch Automate your financial and investment decisions MEAP Rob Reider 2024 scribd download

Robo

Uploaded by

marckmincy0e
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 50

Download the full version of the ebook at ebookname.

com

Build a Robo Advisor with Python From Scratch


Automate your financial and investment decisions
MEAP Rob Reider

https://ebookname.com/product/build-a-robo-advisor-with-
python-from-scratch-automate-your-financial-and-investment-
decisions-meap-rob-reider/

OR CLICK BUTTON

DOWNLOAD EBOOK

Download more ebook instantly today at https://ebookname.com


Instant digital products (PDF, ePub, MOBI) available
Download now and explore formats that suit you...

Data Science from Scratch First Principles with Python 1st


Edition Joel Grus

https://ebookname.com/product/data-science-from-scratch-first-
principles-with-python-1st-edition-joel-grus/

ebookname.com

Writing a C Compiler Build a Real Programming Language


From Scratch 1st Edition Nora Sandler

https://ebookname.com/product/writing-a-c-compiler-build-a-real-
programming-language-from-scratch-1st-edition-nora-sandler/

ebookname.com

Automate the Boring Stuff with Python Practical


Programming for Total Beginners 2nd Edition Al Sweigart

https://ebookname.com/product/automate-the-boring-stuff-with-python-
practical-programming-for-total-beginners-2nd-edition-al-sweigart/

ebookname.com

Growth employment and poverty in Latin America 1st Edition


Cruces

https://ebookname.com/product/growth-employment-and-poverty-in-latin-
america-1st-edition-cruces/

ebookname.com
The Historical Imagination in Nineteenth Century Britain
and the Low Countries Hugh Dunthorne

https://ebookname.com/product/the-historical-imagination-in-
nineteenth-century-britain-and-the-low-countries-hugh-dunthorne/

ebookname.com

Effective Project Management Traditional Agile Extreme 5th


Edition Robert K. Wysocki Ph.D.

https://ebookname.com/product/effective-project-management-
traditional-agile-extreme-5th-edition-robert-k-wysocki-ph-d/

ebookname.com

MCSE 70 293 Exam Prep Planning and Maintaining a Microsoft


Windows Server 2003 Network Infrastructure 2nd Edition
Exam Prep Will Schmied
https://ebookname.com/product/mcse-70-293-exam-prep-planning-and-
maintaining-a-microsoft-windows-server-2003-network-
infrastructure-2nd-edition-exam-prep-will-schmied/
ebookname.com

Relativity Gravitation and Cosmology A Basic Introduction


2005 en 356s Ta-Pei Cheng

https://ebookname.com/product/relativity-gravitation-and-cosmology-a-
basic-introduction-2005-en-356s-ta-pei-cheng/

ebookname.com

Afghanistan The Soviet Invasion and the Afghan Response


1979 1982 M. Hassan Kakar

https://ebookname.com/product/afghanistan-the-soviet-invasion-and-the-
afghan-response-1979-1982-m-hassan-kakar/

ebookname.com
Introduction to Multiple Antenna Communications and
Reconfigurable Surfaces 1st Edition Emil Björnson

https://ebookname.com/product/introduction-to-multiple-antenna-
communications-and-reconfigurable-surfaces-1st-edition-emil-bjornson/

ebookname.com
Build a Robo-Advisor with Python (From Scratch)
1. welcome
2. 1_The_Rise_of_Robo_Advisors
3. 2_An_Introduction_to_Portfolio_Construction
4. 3_Estimating_Expected_Returns_and_Covariances
5. 4_ETFs:_The_Building_Blocks_of_Robo_Portfolios
6. 5_Monte_Carlo_Simulations
7. 6_Financial_Planning_Using_Reinforcement_Learning
8. 7_Measuring_and_Evaluating_Returns
9. 8_Asset_Location
10. 9_Tax-Efficient_Withdrawal_Strategies
11. 10_Optimization_and_Portfolio_Construction
12. 11_Asset_Allocation_by_Risk:_Introduction_to_Risk_Parity
13. 12_The_Black-Litterman_Model
14. 13_Rebalancing:_Tracking_a_Target_Portfolio
15. 14_Tax-Loss_Harvesting:_Improving_after-tax_returns
welcome
Thank you for purchasing the MEAP version of our book, Build a Robo-
Advisor with Python (From Scratch). We’ve enjoyed writing it, and we hope
you’ll enjoy - and benefit from - reading it. We look forward to hearing your
feedback and suggestions for making it even better.

We hope that readers will learn about both finance and Python by reading the
book. It isn’t intended to teach either of those topics from the ground up - we
expect that readers will have a basic understanding of both financial concepts
and Python programming - but accessibility is important to us. If there are
places where you feel we are assuming too much knowledge of either, please
let us know. We also hope you’ll let us know if you feel like any chapters are
too basic. We recognize that not all readers will benefit from every chapter,
but we hope that every chapter is useful to someone.

The balance of theory and implementation varies by chapter. Some chapters


are very financially-focused, and the Python content is limited to showing
how a few functions from existing libraries can be used to perform certain
calculations or accomplish desired tasks. In other chapters, there aren’t any
existing Python libraries that we can use. These chapters are much more
code-heavy, and essentially build new Python libraries implementing the
concepts they cover. We know reading code isn’t always easy, so we try to
show example usages of new code whenever possible to aid understanding.

Because your feedback is essential to creating the best book possible, we


invite you to leave comments in the LiveBook Discussion forum. We
appreciate your interest and produce the best book possible for you.

Thank you again for your interest and feedback.

—Rob and Alex

In this book
welcome 1 The Rise of Robo Advisors 2 An Introduction to Portfolio
Construction 3 Estimating Expected Returns and Covariances 4 ETFs: The
Building Blocks of Robo Portfolios 5 Monte Carlo Simulations 6 Financial
Planning Using Reinforcement Learning 7 Measuring and Evaluating Returns
8 Asset Location 9 Tax-Efficient Withdrawal Strategies 10 Optimization and
Portfolio Construction 11 Asset Allocation by Risk: Introduction to Risk
Parity 12 The Black-Litterman Model 13 Rebalancing: Tracking a Target
Portfolio 14 Tax-Loss Harvesting: Improving after-tax returns
1 The Rise of Robo Advisors
This chapter covers
The increasing popularity of robo advisors
Key features and a comparison of popular robo advisors
Python in the context of robo advising

1.1 What are Robo Advisors?


Robo advisors have become a popular alternative to human financial
advisors. Historically, financial advisors would meet with clients, discuss
their goals, create a financial plan, and then manage their clients’ money over
time. In exchange for this personal attention, they would charge clients fees,
often in excess of 1% per year of their assets under management. Numerous
companies have been trying to disrupt this business through online platforms
that provide automated, algorithmic investment services similar to those of a
financial advisor. Some of these automated systems “advise” clients through
algorithmic implementations of modern portfolio theory, based on the Nobel
Prize-winning work of Harry Markowitz in the 1950s, while others use
optimization techniques borrowed from other disciplines. These companies
have collectively become known as “robo advisors.”

In this book, we show how anyone with a basic understanding of Python can
build their own robo advisor. We hope this will be useful for anyone who
wants to work in this area or wants to apply these algorithms for their own
portfolio or advise others.

1.1.1 Key Features of Robo Advisors


The most basic feature provided by robo advisors is a personalized asset
allocation - a portfolio of investments designed to match the level of riskiness
suitable for the client. The core asset allocations offered by different robo
advisors vary in their choice of asset classes but usually contain a diversified
mix of stocks and bonds. Some advisors may choose to include more non-US
assets in their allocations or an allocation that’s more heavily weighted to
growth or value stocks, but in essentially all cases, the instruments that robo
advisors invest in are liquid and traded on exchanges and not things like
venture capital, private equity, or real estate.

Aside from the core asset allocation, there are a handful of features that robo
advisors provide. We will cover most of these in more detail later in the
book; here we only provide a high-level description of each one.

Rebalancing: A client’s portfolio will start with weights close to the


target allocation at the time of the initial investment, but differences in
returns will cause the portfolio to drift away from the target over time.
Rebalancing may be drift-based, meaning the portfolio is rebalanced
whenever it deviates from the targets by a pre-specified amount, or time-
based, meaning that rebalancing occurs on a fixed schedule.
Additionally, rebalancing may or may not be tax-aware. In tax-aware
rebalancing, some appreciated positions may not be sold if doing so
would involve a high expected tax cost. In some cases, the robo advisor
may be able to keep the portfolio “on track” simply by intelligently
directing dividends and deposits towards assets that have drifted below
their target weights.
Financial Projections: A key question for most individual investors is
“When can I retire?”. Robo advisors may offer tools that show
projections of the client’s net worth through time based on assumptions
for income, spending, inflation, and investment returns. By varying
these assumptions, clients can assess the feasibility of retirement at
different ages.
Tax-Loss Harvesting: The basic idea of tax-loss harvesting is to reduce
the investor’s current tax burden by opportunistically realizing losses in
assets that have declined in value. The realized losses can be used to
offset realized gains or some income. Tax-loss harvesting is a common
feature offered by robo advisors, but one that is tricky to understand
properly. We will discuss the true economic benefit and the
implementation of tax-loss harvesting strategies later.
Glide Paths: As clients age and approach retirement, the amount of risk
that they should take in their investments decreases. A glide path is a
series of portfolios or asset allocations that gradually decrease in
riskiness over time. By the time a client reaches retirement and gives up
their employment income, the glide path will assign a low-risk portfolio.
While some robo advisors use glide paths in their investment process,
others let the client control how much risk they are willing to take
throughout the lifetime of their investments.

Aside from these important features, robo advisors vary in two additional
dimensions - their management fee and the minimum account size. While
there is some dispersion in these values, both are usually quite low compared
to traditional investment advisors, making most robo advisors accessible to
clients in the earliest stages of their careers.

1.1.2 Comparison of Robo Advisors


As of 2020, there were over 200 robo advisors based in the US alone. Table
1.1 compares the feature sets of some of the largest and most well-known.
Many of the advisors in this sample include varying levels of service - for
example, access to a human advisor for an additional fee. For simplicity, we
show pricing for the most basic levels of service.

Table 1.1 Features of various robo advisors

Name Advisory Fee Minimum Tax-Aware Tax-Loss


Account Rebalancing Harvesting
Size
SoFi None $0 Yes Yes
M1 None $500 Yes Yes
Acorns $3 to $9 $100,000 Yes Yes
annually
Ellevest 0.25% $0 No No
E*Trade 0.30% $0 No No
Vanguard 0.20% to $2,000 No Yes
0.25%
Betterment 0.25% $0 Yes Yes
Ally Invest 0.30% $100 No No
Wealthfront 0.25% $50,000 No No
Charles Free $5,000 No Available for
Schwab accounts
above
$50,000
Fidelity 0.35% (Free $5,000 No No
below
$25,000)

1.1.3 Things Robo Advisors Don’t Do


Software is useful for performing simple, repeatable tasks very quickly. Even
the most complex-looking algorithms are just sequences of simple conditions
and steps. The examples given above are ones that are naturally suited to be
accomplished using software. However, there are some services performed
by traditional advisors that software can’t replicate. These are generally
infrequent or one-time events that may require detailed personal information.
Examples of services that are (for now) best accomplished by human advisors
include estate planning, management of non-traditional assets like art or real
estate, and specialized tax advice for things like stock options.

This is not to say that robo advisors can't expand into areas that have
traditionally been the domain of human advisors. For example, financial
advisors are often called upon to help retirees with defined-benefit pension
plans on whether to take a lump sum or monthly payments for life. The same
Python programs used to analyze Social Security can be adapted to analyze
pensions. Of course, there are some things that robo advisors will never be
able to do - software will never get you basketball tickets (no matter how
large your account gets) or treat you to dinner.
1.2 Advantages of Using a Robo Advisor
There are several advantages of using a robo advisor over either using a
human advisor or do-it-yourself investing. We highlight three of those
advantages here.

1.2.1 Low Fees

Surveys show that about 30% of Americans use a financial advisor of some
kind. Fee-based financial advisors charge fees based on a percentage of assets
under management (AUM), an annual retainer, or an hourly charge, and
sometimes a combination of these. In addition to fee-based financial advisors,
some advisors instead follow a commission-based model, where they are
compensated by charging commissions on financial transactions and products
like life insurance or annuities. For those that charge an AUM fee, which is
the largest category, the average fee is about 1% per year. Robo advisor fees
are a fraction of that (see table above). In addition, robo advisors usually have
much lower minimum account sizes than financial advisors.

Even small savings, when accumulated over decades, can make a big
difference. A 1% annual fee charged by a traditional human advisor may not
seem like much, but the cost compounds over time. Imagine starting out with
a $100,000 investment which earns a 7% return each year, before fees. The
1% fee charged by a traditional advisor reduces the return to 6% annually.
This means that after 30 years, the $100,000 investment would grow to about
$570,000. Not bad, but let’s compare this to a typical robo advisor charging
0.25% per year. With the robo advisor, the investment would grow to about
$710,000 - almost 25% more!

1.2.2 Tax Savings

In several chapters, we describe various tax-saving strategies that could be


automated by a robo advisor. How much money can people save through tax
strategies with robo advisors? It’s very difficult to give an exact number
because it’s different for each individual, depending on their circumstances.
Someone who has only taxable accounts and no retirement accounts like an
IRA or 401(k) would not benefit from several of the automated robo advisor
functions that we talk about. Indeed, with the tools covered in this book, you
will be able to estimate, through Monte Carlo simulations, the amount of
savings for a specific set of circumstances. But the savings can be significant.

To give one example, consider a topic we will cover in detail in Chapter 9:


the optimal sequencing of withdrawals. As a brief introduction - and we will
cover this in excruciating detail later in the book - during the retirement stage
of life when people are “decumulating” assets instead of accumulating,
numerous options are available for withdrawing assets. For example, you can
take money out of your taxable accounts first, and when that is depleted, start
taking money out of retirement assets (“Taxable first”). You can also switch
the order and take money out of retirement accounts first (“IRA first”). A
third strategy is to take money out of retirement accounts each year up to the
top of the nearest tax bracket so that future IRA withdrawals don’t push you
into a higher tax bracket (“IRA fill bracket”). Finally, the fourth strategy is
similar to the third, but you convert your IRA distribution into a Roth IRA
(“Roth conversion”).

To illustrate how consequential those decisions can be and how much you
can save by employing the best strategy for a given set of circumstances, the
figure below shows how long your money will last for those four strategies.
The specific set of assumptions and the details of the strategy will be covered
later, but the point is that it makes a big difference. The optimal strategy can
extend your assets by many years.

Figure 1.1 Decumulating tax-efficiently can make your money last longer
1.2.3 Avoid Behavioral Biases
It is well-documented that investors are subject to numerous behavioral
biases, many of which can be avoided by algorithm-based automated trading.

Disposition effect Studies have shown that investors tend to hold onto
losing stocks, hoping to get back to break even. However, robo advisors
realize it’s often useful to sell losing stocks to harvest tax losses.
Herd behavior Investors tend to be influenced by others, which
explains why they dive into stocks during bubbles and panic during
crashes. Herding might have conferred benefits when fleeing predators
in prehistoric times, but it is not a great investment strategy. Robo
advisors, on the other hand, unemotionally rebalance gradually toward
stocks during crashes and away from stocks during bubbles.
Overtrading Several studies on overtrading have all reached the same
conclusion: the more active a retail investor tends to be, the less money
they make. Individual investors may incorrectly assume that if they are
not paying brokerage commissions, there is no cost to frequent trading.
However, commissions are only one cost. The bid/ask spread, the
difference between the price you can buy a stock and sell a stock on an
exchange, is a significant component of trading costs. Also, frequent
trading leads to short-term capital gains, which is not tax efficient. Robo
advisors methodically factor these costs into account when they make
trades.

1.2.4 Saving Time


By automating simple tasks associated with investing, a robo advisor can
save investors huge amounts of time compared to a “do it yourself” approach.
Monitoring the portfolio for drift away from its targets or for tax-loss
harvesting opportunities, and placing trades to rebalance, harvest losses, or
invest deposits aren’t especially difficult, but they aren’t especially fun either.
Robo advisors automate these tasks, leaving investors time for more
enjoyable pursuits.

1.3 Example Application: Social Security Benefits


One thing that gets us excited about this topic is that robo advising is still in
its infancy. Consider one example: the important decision on when to claim
Social Security benefits. For many Americans, their Social Security check
can be considered one of their most valuable assets, in many cases worth
more than half a million dollars on a present value basis. People must elect
when they want to start receiving, or claiming, their Social Security
payments, which is anytime between 62 and 70, and the longer you wait, the
larger your payment will be. It is one of many important retirement decisions
that are consequential and mostly irreversible. So what kind of advice is out
there on when to claim Social Security? If you do a Google search on when
to claim Social Security, you’ll find numerous calculators that mostly all do
the same thing. They usually have a simple break-even analysis like the one
we created below. To see a similar one, see, for example, the one offered by
Charles Schwab (schwab.com/resource-center/insights/content/7-questions-
about-social-security).

Figure 1.2 Break-even analysis on the age to start claiming Social Security
In this break-even analysis, the x-axis represents the age you expect to die,
and the y-axis represents the present value of your Social Security payments
until death. As you can see from the graph, in this simple analysis that
compares claiming at 62 vs. 70, if you expect to live past 82, you are better
off waiting until 70 to claim Social Security, and if you expect to die before
82, you are better off claiming at 62. As the chart shows, if you live to 90 and
claim at 70, the present value of all payments is about $500k.

What is this analysis missing, and how can Python be used to improve the
analysis? First of all, the analysis gets exponentially more complicated when
spouses are considered, and the Social Security rules can get very
complicated. Although the break-even analysis above can be done in a
spreadsheet, taking into account couples and all the Social Security rules
would overwhelm a spreadsheet and must be coded in a computer language
like Python.

In order to accurately predict Social Security benefits, an estimate must be


made for the trajectory of future income up to retirement. Python has several
libraries for forecasting a time series like income. An accurate forecast
requires an earnings history for the investor, which can be downloaded from
the Social Security website, and Python can be used to scrape the file.
The break-even analysis above is not customized in any way, and Python can
help here too. Since Social Security benefits are similar to an asset like a
bond, it should be incorporated into an investor’s asset allocation - larger
Social Security payments would mean that even a conservative investor could
hold fewer bonds. The break-even analysis also ignores taxes on Social
Security income. And it ignores the Social Security benefits that may be
withheld when someone’s income exceeds a threshold while they are
collecting benefits. The Social Security analysis can therefore be extended to
include an investor’s particular tax situation.

One of the most important and overlooked shortcomings of the break-even


approach is that it doesn’t take risk into account. In this case, the risk is
longevity risk - the chance that you survive beyond your life expectancy and
outlive your money. Social Security benefits, as well as defined benefit
pension plans and annuities, reduce that risk by guaranteeing lifetime
benefits. In Chapter 6 on AI, we show how to take risk into account with
examples in Python.

Throughout the book, we aim to not only explain what robo advisors
currently do but also introduce various tools that few, if any, advisors
currently use. We already mentioned the chapter on using AI to solve
financial planning problems. We also have a chapter on “asset location,”
which involves strategically distributing different types of assets among
existing taxable, tax-deferred, and tax-exempt accounts to minimize taxes.
Whereas asset allocation involves tradeoffs between risk and reward, asset
location is close to a free lunch. However, the strategy can get quite complex,
which perhaps explains why it has not been widely adopted.

1.4 Python and Robo Advising


The designers of Python programming intended the language to be fast,
powerful, and fun. We think that they have succeeded. Python is easy to get
started with - the classic “Hello World” program is not much harder than just
typing the words “Hello World” - and easy to learn. Python’s documentation
is extensive, and its wide adoption means it’s usually quite easy to find
solutions to tricky problems - chances are, someone has run into them
already. Finally, Python is flexible - while it supports some more
sophisticated features of lower-level languages like Java, Python doesn’t
require them. If you want to use Python in an object-oriented way, you can -
but you don’t have to. Likewise, you can add “hints” for data types in Python
functions, but they aren’t required. Python lets you choose.

All of these qualities make Python easy to learn and work with for any
programmer. But what makes Python a good language for robo advising? As
Python’s popularity has grown, the number of mathematical and statistical
packages has grown as well. Applications in this book will lean heavily on
pre-existing packages, including:

numpy: A general-purpose package for numerical computing, numpy


provides tools ranging from the basics (basic vector and matrix
operations or least-squares solutions to linear systems) to the complex
(such as random number generation or matrix factorizations). The numpy
package achieves high speed by implementing many numerical
subroutines in C.
scipy: scipy provides algorithms for numerical problems, including
optimization, integration, and root-finding. It also includes a large
library of statistical functions. Like {\tt numpy}, {\tt scipy} uses
subroutines written in low-level languages like Fortran and C to improve
speed.
pandas: pandas was developed at AQR Capital Management starting in
2008, and was made open-source in 2009. It adds a level of abstraction
on top of arrays and matrices to make data manipulation effortless.
cvxpy: cvxpy is a mathematical modeling language allowing users to
formulate and solve convex optimization problems using a natural and
easy-to-read syntax.
statsmodels: statsmodels is one of several libraries in Python that can
perform a linear regression with just a few lines of code.

We should also talk about what Python isn’t. Python’s interpreted nature
means it will never be as fast as low-level compiled languages like C or
Fortran. If your application requires top speed, a compiled language may be a
better choice. This also means that bugs only show up when code is run and
won’t be found during compilation. Overall, we still think that despite these
limitations, Python is a great choice for this book. Robo advising doesn’t
require lightning speed, and we think that the ease of use and extensive
libraries and documentation outweigh any disadvantages in execution speed.

This book won’t assume that readers are Python experts but will assume a
basic familiarity. For an introduction to programming in Python, we
recommend “The Quick Python Book” by Naomi Ceder as a great place to
start.

All chapters contain examples in Python, and many include function and
class definitions. These can be found at the GitHub page for this book:
https://github.com/robreider/robo-advisor-with-python. On the GitHub page,
file names correspond to chapter numbers. Within each chapter, later code
builds on earlier code. For example, a code section in the middle of a chapter
might rely on a function defined earlier or on a package imported earlier.
Additionally, class definitions with many methods may be broken into
multiple code sections. We recommend copying or importing code from
GitHub rather than straight from the text if you are working in Python while
reading an electronic version of the book.

In some chapters, we have moved the longer, complicated code to GitHub,


and the shorter code that relies on simplifying assumptions is placed in the
body of the chapter. Also, we have a section on GitHub for “extras” that
don’t fit easily into any chapter. For example, in the "extras" section, you will
find the code for scraping the earnings history from a Social Security
statement using the Python library BeautifulSoup. This code can be
expanded into a full Social Security calculator in Python and incorporated
into several other chapters on wealth planning.

1.5 Who Might be Interested in Learning About


Robo Advising?
There are several groups of people who might be interested in the topics
covered in this book.

You want to better understand personal finance to help you with your
own finances. There is no shortage of books on personal finance for do-
it-yourself investors, but this book focuses on topics that can clearly
save you money and goes into them in depth. You won’t see chapters
found in other personal finance books like “Live within your means” or
“Don’t buy complex financial products”. Even if you have no interest in
applying these techniques in Python, the book is written so that you can
skip the Python examples and still understand the principles behind what
the algorithms do.
You are interested in working for a financial advisor or wealth
manager. As we mentioned, the number of robo advisors is growing,
and the incumbents are also getting into robo advising. Traditional
wealth managers are also using the same techniques for their clients. A
quick search on indeed.com for jobs as a “financial advisor” currently
lists over 20,000 jobs. This book provides relevant skills that are used in
the industry.
You are a Financial Advisor and would like to provide your clients with
a larger set of tools. According to the Bureau of Labor Statistics, as of
2022, there were 283,000 financial advisors in the United States. The
financial advisory business is obviously very competitive, and providing
sophisticated services gives a firm a competitive advantage. Advisors
can differentiate themselves in this crowded field and create a
competitive advantage by offering more advanced tools like the ones
described in this book. A financial advisor who can automate guidance
can service many more clients while still providing customized advice.
You are interested in useful, practical applications of Python. There is
no better way to learn Python than by applying it to interesting, practical
problems and observing intuitive results. This book will use numerous
Python libraries to solve wealth management problems. We will use a
convex optimization library and a hierarchical tree clustering library to
perform asset allocation, a statistical and random number library for
Monte Carlo simulations, and a root-finding library for measuring
portfolio performance. If you're interested in learning about AI, Chapter
6 provides several fully worked examples, from start to finish, of how
you can apply AI to solve financial planning problems.

Throughout the book, you may find that certain rules, regulations, investment
vehicles, or account types are specific to investors in the US. In most cases,
however, the concepts discussed should apply to investors outside of the US,
even if the specifics of some rules or assumptions need to be modified.
1.6 Summary
Robo advisors use algorithms to automate some of the functions of
human financial advisors.
Robo advisors have several advantages over human advisors: they have
lower fees, they can save a considerable amount of money using tax
strategies, and they can help investors avoid some well-documented
behavioral biases that detract from their performance.
Python, with its extensive libraries, can be used to implement many of
the functions of a robo advisor, from asset allocation to tax loss
optimization to Monte Carlo simulations for financial planning.
2 An Introduction to Portfolio
Construction
This chapter covers
Creating risk-reward plots
Using matrix operations to compute portfolio returns and volatilities
Calculating, plotting, and deriving the math behind the efficient frontier
Introducing a risk-free asset and the idea of the Capital Allocation Line
Gauging an investor’s risk tolerance through questionnaires
Using slider widgets to help an investor visualize the risk-reward
tradeoff

One of the primary functions of a robo advisor is to construct a well-


diversified portfolio of assets. This chapter will provide the theoretical
foundation for portfolio construction and some building blocks we will use
later. We will also start using Python in our examples. Later in the book, we
will delve deeper into the topic of portfolio construction, including some
problems with the traditional methods that are covered in this chapter.

Let's start off with a simple example with only three assets: First Energy
(FE), Walmart (WMT), and Apple (AAPL). The analysis that follows can
always be generalized to include as many assets as you would like. In this
example, the assets are individual stocks, but they could easily be bonds,
ETFs, commodities, cryptocurrencies, or even hedge funds. The problem we
want to address is what are the optimal weights to assign to these three assets.
We will start off by taking the approach of the Nobel Prize-winning work of
Harry Markowitz. The Markowitz approach recognizes that investors have
two conflicting objectives. Of course, they want high returns, but they also
want low risk, and in the last section of this chapter, we discuss how to
balance these competing objectives.

Suppose we knew these three assets' expected returns, variances, and


correlations to each other. Of course, we do not know things like the expected
return of a stock, but for now, let's suspend disbelief for the purposes of this
discussion. Let's say the annual expected returns for FE, WMT, and AAPL
are 4%, 9%, and 12%, respectively. We can represent this as a vector:

Let's say the annual standard deviation of returns, or volatility of returns (we
will use these two terms interchangeably), for FE, WMT, and AAPL are
15%, 20%, and 35%, respectively. We can also represent this as a vector:

We can plot these three stocks in mean-standard deviation space, which some
call a "risk-reward" plot, using the code in Listing 2.1:

Listing 2.1 Plotting points in mean-standard deviation space

import pandas as pd
import numpy as np
import matplotlib.pyplot as plt

stocks = ['FE', 'WMT', 'AAPL']


mu = [0.04, 0.09, 0.12]
sigma = [0.15, 0.20, 0.35]

def plot_points(mu, sigma, stocks):


plt.figure(figsize=(8,6))
plt.scatter(sigma, mu, c='black') #A
plt.xlim(0,.45)
plt.ylim(0,.25)
plt.ylabel('Mean')
plt.xlabel('Standard Deviation')
for i, stock in enumerate(stocks):
plt.annotate(stock, (sigma[i], mu[i]), ha='center', va='bottom', wei

plot_points(mu, sigma, stocks)


plt.show()

Figure 2.1 shows the risk-reward plot when we run the code in Listing 2.1.

Figure 2.1 Example of the risk-reward plot for three stocks

2.1 Computing a Portfolio’s Expected Return and


Standard Deviation
Our goal is to find the most efficient way to weight these assets by
constructing portfolios with the highest expected return for a given standard
deviation. We will see in this section that calculating the mean and standard
deviation of a portfolio of assets involves summations and double
summations. We will introduce matrix multiplication to perform these
operations. For those who are not familiar with the field of “linear algebra,”
don’t worry. You only need to be aware that there are efficient, one-line
commands in Python to perform these matrix operations, which we will
demonstrate in the listings.

Suppose we represent the weights for FE, WMT, and AAPL as 1, 2, and
3, respectively. In that case, we can again write this in vector notation:

The return on this portfolio, rp, is:

and the expected return on the portfolio is just the weighted average of the
expected returns on the three assets that make up the portfolio:

We can write this in vector notation as the dot product of vectors and :

There are several ways to do this calculation using Python and NumPy (see
the box below). In this and the following chapters, we'll use the matrix
multiplication operator @, which has a clear and concise syntax that makes
the code more readable. Listing 2.2 demonstrates how to use the operator @ to
compute the expected returns of a portfolio given the weights and expected
returns of each asset. If you run Listing 2.2, the portfolio's expected return is
9.5%.

Listing 2.2 Computing expected portfolio returns

w = np.array([0.2, 0.3, 0.5])


mu_p = mu @ w.T
print('Expected portfolio return: ', mu_p)

Note: Delving into some finer points of matrix multiplication in Python


The one-line code in Listing 2.2 is all you really need to know about
performing matrix multiplication using the operator @, but in case you're
interested in getting deeper in the weeds, a few additional remarks are in
order:

In Listing 2.2, we transposed the second vector of weights, not the first
vector of means. Whereas in mathematics we assume vectors are column
vectors, in Python when you create a list or a one-dimensional NumPy
array, it is assumed to be a row vector. Also note that in order to take the
transpose of a vector, it has to be a NumPy array and not a list, so you
would have to create the vector of weights using, for example, w =
np.array([0.2, 0.3, 0.5]) rather than using a list w = [0.2, 0.3,
0.5].
When using the @ operator for matrix multiplication, the NumPy library
automatically applies broadcasting rules, which makes it unnecessary in
many cases to transpose one of the arrays. In other words, you can
simplify the dot product in Listing 2.2 by using mu_p = mu @ w instead
of mu_p = mu @ w.T. But if you do that, be careful that the broadcasting
rules are working the way you think they should be working.
The operator '*', when applied to arrays, does an element-by-element
multiplication rather than a matrix multiplication (multiplying entire
rows in the first matrix by entire columns in the second matrix). If we
had used an element-by-element multiplication mu * w instead of the
matrix multiplication w @ mu in Listing 2.2, it would not return the
weighted sum of expected returns for the three stocks, which is a scalar,
but rather a one-dimensional array with three elements.
To make things even more complicated, NumPy has a data structure
called a NumPy matrix, which differs from a NumPy array. If you
convert the NumPy arrays to NumPy matrices, then the '*' operator does
a true matrix multiplication, not an element-by-element multiplication.

The NumPy function np.dot() is equivalent to the matrix multiplication


operator @ for 1-D and 2-D arrays and can be used interchangeably with @.
However, @ is preferred for readability.

Unfortunately, the standard deviation of the portfolio is not simply the


weighted average of the individual stock standard deviations. The pairwise
correlations between the assets play an important role. To illustrate with just
two assets, the standard deviation of the portfolio is

Instead of dealing with the correlations and individual stock volatilities, it is


often more convenient to deal with covariances, which combine correlations
and volatilities. The covariance between assets and is

and if and are the same, it's just the variance of the asset:

Listing 2.3 converts a correlation matrix and a vector of individual volatilities


into a covariance matrix using the above formula. We need to convert the
vector of volatilities into a diagonal matrix to scale the correlations by the
corresponding volatilities.

Listing 2.3 Computing the covariance matrix from volatilities and correlations

Corr = [[ 1. , 0.1 , 0.17],


[ 0.1 , 1. , 0.26],
[ 0.17, 0.26, 1. ]]

Cov = np.diag(sigma) @ Corr @ np.diag(sigma) #A


print('Covariance matrix: \n', Cov)

Covariance matrix:
[[0.0225 0.003 0.008925]
[0.003 0.04 0.0182 ]
[0.008925 0.0182 0.1225 ]]

For assets and writing each term in terms of covariances, we can generalize
the volatility of a portfolio as a double summation:
Random documents with unrelated
content Scribd suggests to you:
composer’s works. For, far from being an imitator of Schumann’s
style, he appeared at once in his own strong personality and as a
stranger, who even in Leipsic was not understood. Yet he found
publishers for three pianoforte sonatas, a scherzo, a trio and several
songs. For years the interest in him was confined to a small circle. He
stayed for a while in Hanover, making from there several concert
tours with Joachim or Stockhausen, the great singer, another
devoted friend, visiting also Schumann in his retreat in the Endenich
hospital. In his variations on a theme from Schumann’s Op. 99, he
gave a touching expression to his sympathy with the master’s
sufferings. After the publication of these and the ballads Op. 10,
Brahms devoted several years to profound study. Schumann’s praise
had not spoiled him, nor was he discouraged by the lack of success.
For a few seasons he was the director of the orchestra and chorus in
Detmold, spending also some time in Hamburg and in travelling.
Meanwhile he finished many songs and choruses, two serenades for
orchestra, and two sextets. In Jan., 1859, he played in Leipsic his first
great pianoforte concerto; most of the criticisms thereon were,
however, such as to now excite our mirth. It was in Switzerland and
Vienna that his genius found a sincere recognition. About thirty
years ago the writer first saw Brahms in his Swiss home; at that time
he was of a rather delicate slim-looking figure, with a beardless face
of ideal expression. Since then he has changed in appearance, until
now he looks the very image of health, being stout and muscular, the
noble, manly face surrounded by a full gray beard. The writer well
remembers singing under his direction, watching him conduct
orchestra rehearsals, hearing him play alone or with orchestra,
listening to an after-dinner speech or private conversation, observing
him when attentively listening to other works, and seeing the modest
smile with which he accepted, or rather declined, expressions of
admiration.
The Alpine summits and glaciers had great attractions for Brahms,
but also the welcome which he was always sure to find in Basel and
Zürich. For his permanent home he selected Vienna, in 1862, where
he was surrounded by the spirits of the classic masters. He was
received most favorably. His interpretation of Bach, Beethoven,
Schubert and Schumann was particularly praised. He was appointed
chorus master of the Sing-Academie for a season, and prepared a
memorable performance of Bach’s Passion Music. Yet his genius
would not allow him to devote much time to such services, and once
only in later years he accepted a similar appointment, directing from
1872–1875 the concerts of the “Society of the Friends of Music.”
Aside from this all his time was devoted to composing, interrupted
only by frequent journeys to performances of his works, and by
giving valuable assistance in the revision of the works of Couperin,
Mozart and Chopin. During the first years of his residence in Vienna
he finished many important chamber works, variations, waltzes and
Hungarian dances for the pianoforte, and vocal compositions of
every kind. The first great success was won by the “German
Requiem,” begun after the death of his mother in 1866, and
completed, for the greater part, in Switzerland, in the two following
years. After the first famous performance in the Bremen Cathedral in
the spring of 1868, it was soon heard in other cities and was greatly
admired, although certain features were severely criticised. Other
works of high importance followed: the “Song of Destiny,” “Rinaldo,”
the “Rhapsody,” Op. 53, the “Song of Triumph” for the celebration of
the happy ending of the Franco-German war, besides many songs,
chamber works, and the charming Love-Song Waltzes. By all these
works Brahms rose gradually higher and higher in the general
estimation both at home and abroad. But he steadfastly avoided the
one field in the reform of which all musical interest seemed to centre,
—the opera. Perhaps the time will come when we may be fully
informed as to his relation to dramatic music and the reasons which
kept him away from the stage. Much might be guessed. But it is
needless to pay attention to mere rumors and suppositions. There
were other fields in which he was called upon to achieve great things.
Nothing shows better the greatness of Brahms’ artistic character
than the fact that, in spite of Schumann’s prophecy and many early
instrumental masterpieces, he waited with his first symphony until
he was a man of over forty years. Four great symphonies have
appeared between 1876 and 1885, preceded by orchestral variations
on a theme of Haydn; also, during the same time, two overtures, a
second pianoforte concerto, one for violin, two smaller choruses with
orchestra, chamber works, piano pieces and songs. Another great
choral composition, “Deutsche Fest-und Gedenksprüche,” a double
concerto for violin and violoncello, Gipsy songs and many other vocal
and chamber works complete the list of his more recent
compositions. And more great things may be expected from him. If
there is anything inspiring in the present aspect of musical art, it is
the fact that Johannes Brahms is still among us, physically and
mentally as strong as if perpetual youth were granted to him. Indeed,
the graces and heroes have not only kept watch at his cradle, but
guided him throughout his long career.

JOHANNES BRAHMS.

In early youth.

Those who have met him will never forget the impression of his
strong personality. Nor will those who saw him conduct or heard him
play ever enter into the superfluous discussion whether he was a
great leader of orchestra and chorus or a master of his instrument.
For in both directions he was not only equal to the most exacting
demands, but always appeared as if inspired, and inspiring
everybody who sang or played under him or listened to the genius of
his music. At the pianoforte and the conductor’s desk he is a king,
but socially he appears unaffected and easy, neither reticent nor
predominating in conversation, jolly and kind among friends and
children. He has never married. Many honors have been conferred
upon him: the degrees of Doctor of Music by the University of
Cambridge, England, in 1877, and of Doctor of Philosophy by the
Breslau University in 1879; also several orders and the membership
of many societies and institutes. Throughout the musical world his
music, especially his instrumental works, is now received with
enthusiasm, although still finding a strong opposition on the part of
many critics of either too conservative or too progressive tendencies.
Yet the time is not far distant when it will be generally granted a high
position in the history of our art.

Fac-simile autograph manuscript of Canon by Brahms. “An Album


Leaf.”
Fac-simile autograph letter from Johannes Brahms to Karl
Klauser.

Three prominent characteristics of Brahms’ works command our


admiration. From the start he appeared as a strong individuality, and
notwithstanding a leaning towards Bach’s polyphonic art and
harmonic wealth, Beethoven’s virile pathos and ideality of purpose,
and Schubert’s melodic charm, he has spoken his own distinct
language. In every field of composition except the opera he has
contributed masterpieces which show that in each he has to-day no
superior, and in but few an equal. Throughout he impresses us by the
fact that to him art has always been something sacred, worthy of
highest effort and noblest purpose. In this respect one may well
compare him to Bach or Beethoven or Schiller, of whom Goethe so
beautifully said, that “far behind him lay that which conquers us all,
—vulgarity.” Whoever honestly strives for the sympathy of his genius
must be filled with a like earnest spirit, willing to be guided by his
subtle art into ideal regions full of higher joys than common musical
amusements afford.
The wealth of his melodic, rhythmic and harmonic invention is
truly astonishing; his combinations are so new and often intricate,
the thematic material so rich or peculiar, its development so
elaborate, that it is a commonly expressed opinion that his music has
to do more with the intellect than with imagination and feeling. The
truth is, that no modern composer has expressed deeper and more
fervent feelings, either jubilant or sad, than Brahms. His great
intellect only guides the wealth of emotion in order to find a well
balanced, wholly original and artistic construction for the creatures
of his rich imagination. And he is an eminently modern composer;
with all his so-called conservative tendencies there is hardly a page in
his works which could have been written at an earlier stage of
musical art. Familiar with all the subtleties of modern expression
and innovations of harmony, rhythm, and instrumentation, he has
himself introduced many new and bold features.
To speak in detail of the one hundred and fifteen published works
of Brahms would require a space far beyond the limits of this sketch.
Thus only a summary classification is possible. Looking first at the
instrumental compositions, one cannot praise Brahms too highly,
that in opposition to prevailing tendencies towards a neglect of cyclic
forms in favor of free, rhapsodic or programmatic fantasias, he has
cultivated the former with supreme devotion, enriching and
modifying them in many ways, but so that they still appear as worthy
representatives of their types.
The three pianoforte sonatas and the Scherzo Op. 4 reveal the
cardinal features of his later chamber and orchestral works: a most
excellent thematic material, consisting often of but a few notes,
awakening highest expectations; a rich, ingenious development,
always coherent and logical; a Beethovenish virility; distinct
contrasts and wonderful climaxes in the lively opening and closing
movements, usually beginning directly with the principal subject, the
working-out section being especially interesting and elaborate, the
coda often of rare charm; the slow movements of delicate or intense,
always noble feeling, in the form of variations or a long cantilena; the
scherzos on a large plan, in three-four or six-eight time, very spirited,
with a quieter trio preceding the finale, except in No. 3, where a short
intermezzo is interpolated. Everywhere we note an ample and
effective use of syncopations, a peculiar style of accompaniments,
bold modulations and rhythmic devices, occasionally even some
programmatic suggestions. Few masters have shown such originality
and maturity in their first works.
Of independent pianoforte variations there are sixteen on a
touching theme of Schumann, eleven on a beautiful original theme,
thirteen on a Hungarian theme (with a combination of three-four
and four-four time), twenty-five splendid variations on a short theme
of Handel ending with a great fugue, some very difficult variations on
a theme of Paganini, and—in a more romantic spirit—nine for four
hands on that peculiar theme which Schumann had received “from
the spirits of Schubert and Mendelssohn.” Some of these important
works have a suggestive and refined sentimental character, others
are virtuoso pieces of the highest order. As regards free conception of
the variation form and variety of construction and mood, Brahms
goes decidedly farther than Beethoven or Schumann. He seems
inexhaustible in this form, which he used later most ingeniously also
in chamber and orchestra works. The four poetic ballads Op. 10, the
capriccios and intermezzos Op. 76 and two Rhapsodies Op. 79 are
fine concert pieces of a freer but always coherent style, often very
difficult. More popular are the famous Hungarian dances
(fascinating settings of melodies, the authorship of which Brahms
has never claimed), which he has orchestrated and arranged for four
hands. His waltzes Op. 39, also for four hands, are short character-
pieces of a bright, graceful or passionate spirit, in certain features
recalling Schubert and Schumann, yet so original that they have been
much imitated by younger composers. Several piano works for
technical study (after Weber, Chopin and Bach), and fine
arrangements of most of his chamber works and orchestra serenades
and of a gavotte of Gluck may at least be mentioned. The difficulties
of his pianoforte style, so rich in polyphonic figuration, harmonic
and rhythmic combinations, syncopations, and wide stretches,
especially abound in the two seldom-played concertos. Yet, without
the highest appreciation and sympathetic devotion, the greatest
virtuosity would never be able to make their inner life clear.
Like a giant appears the early written D minor concerto. Quick
modulations, syncopations, chains of trills and a Beethovenish
importance of themes and development impress us mightily in the
passionate first movement, divine sweetness in the long adagio,
while the finale, with its fantasia-like cadenza, rises from a simple
mood to the acme of enthusiasm. The B flat concerto Op. 83 has even
four movements, the long and romantic opening allegro being
followed by an allegro appassionato of a superior scherzo character,
the delightful andante by a highly effective allegro grazioso as finale.
In spite of the elaborate development and the variety of contrasting
moods, the whole work retains a bright and inspiring character. In
both concertos the important and richly scored symphonic
accompaniment only raises the solo part to greater prominence.
A fugue and a choral prelude with fugue are Brahms’ only but
significant compositions for the organ.
The chamber works secure our master a place of honor beside the
greatest representatives of this high branch of composition; they
comprise three sonatas for violin and two for violoncello and
pianoforte, five pianoforte trios (one with horn and one with
clarinet), three string quartets, three pianoforte quartets, three string
quintets (one with clarinet), one pianoforte quintet and two string
sextets. In the older works one feels often the struggle of a great soul
with strong passions, longings, hopes and anxieties, joys and pains,
yet not lacking in sunshine and humor, while in the more recent
compositions a quieter, more contemplative spirit prevails. The
classic arrangement of four movements forms the rule, most of them
being very elaborate and extensive, rich in themes of importance and
beauty, the working out and coda showing Brahms’ genius in the
finest light, the treatment of the different instruments being
throughout masterly. The complicated development often prevents
an immediate enjoyment, but increases our desire for a closer
acquaintance; for this counterpoint goes always hand in hand with
true feeling. In the opening movements the first part is not always
repeated, and other novel features are introduced; the slow
movements in the form of variations or of a long developed cantilena
often lift us into high and unwonted regions; the scherzos are so full
of genius that one wonders why Brahms has not used this form in his
symphonies. The finales are of the highest order, seldom reached by
other modern composers. In the works with horn and clarinets these
much neglected instruments have received a wonderful treatment in
music of great beauty. Unusual and complicated rhythms appear
frequently, but treated in a surprisingly easy way. The details are
throughout deeply interesting, yet often strange, even the most
peaceful movements requiring closest attention. If one of all these
great works must be distinguished as the greatest, we would name
the pianoforte quintet in F minor, Op. 34. Yet the very latest work,
the clarinet quintet, shows the same freshness and originality of
invention, wonderful thematic net-work, variety of distinctly
expressed moods, and the finale displaying an unsurpassed skill in
variations.
The two orchestra serenades are real gems of spirited, delightful,
well constructed music, one being for complete orchestra, the other
for violas, ’celli, basses, reed instruments and horns. Besides the
lively first and last movements and adagios they contain each a
scherzo and one of them two minuets.
The theme for the nine orchestra variations Op. 56 is taken from
one of Haydn’s divertimenti for wind instruments. They crown
Brahms’ glorious achievements in the writing of variations; for, far
from being “mere algebraic experiments,” they are delightful and
ingenious tone pictures of distinct character and mood, with a nearer
or more remote relation to the principal theme. The composer has
thus initiated a new field of independent orchestral music, already
successfully followed by others. The instrumentation is prominently
interesting. It is generally admitted that Brahms is very conservative
compared with Wagner and Berlioz in the matter of instrumentation.
At least he never allows orchestral colors to divert our attention from
the higher, inner meaning of a work. Yet in this score and in all his
other works for or with orchestra, there are many features either of
wonderful brilliancy or peculiar colors, which as novelties are worth
studying. The finale, built upon a much repeated bass figure,
successively joined by the different groups of the orchestra with
other themes, reaches a beautiful climax in the pompous return of
the original melody.
JOHANNES BRAHMS.

From an engraving by Weger, after a


photograph from life.

The four symphonies in C minor, D, F and E minor are justly


regarded as the most important orchestral works of our generation.
Much is still written against them, and not everybody is willing or
able to share the enthusiasm which their good performance arouses
among the majority of cultivated audiences. Yet nothing can shake
their high position among all symphonic works written since the
great master of the immortal Ninth has left this earth. They have
each a very individual character and, although in the main the old
form is retained, new features are to be found in almost every
movement. The first symphony opens with an impressive sostenuto
introduction, the others begin at once with the principal subject of
the allegro. Usually the first part of the latter is brought to a formal
close and repeated; only in the fourth symphony, so rich in thematic
material, no repetition occurs, but a very elaborate working out
prepares for the climax reached in the concentrated recapitulation.
Everywhere noble themes are finely contrasted, wonderfully
developed, wholly or in fragments, in the working out, so as to hold
the listener in breathless suspense. The allegros of the first and
second symphonies have particularly fine codas. The slow
movements are not very extensive and are easily enjoyed, their
quieter and lofty mood being but little disturbed. However, the
adagio in No. 2 is more complicated, has richer material, more
frequent changes of key and rhythm, a more elaborate figure work
and a peculiarly intimate spirit. A remarkable innovation is the
consequent substitution for a minuet or scherzo of a sort of
intermezzo, full of grace, sunshine and innocent playfulness, hardly
disturbed by more serious episodes. Most extended is this in No. 4, a
rondo with themes of an almost grotesque character, surprising
details in their development and a spirit of true Beethoven-like
humor. Yet those of the first three symphonies are of no less
importance, having two distinct parts, of which the second one
(contrary to the older trio) has a livelier character. Especially that of
No. 2 is one of the most delightful orchestral pieces of modern
literature. That Brahms is indeed a symphonist of the highest rank, is
particularly evident in his finales. That of No. 1 is conceived in the
grandest spirit, opened by a solemn introduction of overwhelming
beauty and impressiveness, the allegro based on themes of rare
inspiration, their wonderful development rising from climax to
climax like a great triumphal procession. Still the finale of No. 2 is
not less inspiring; even more brilliant, with its glorious themes, the
splendid instrumentation and exciting coda. In No. 3 the closing
movement has the unusual minor key, is less dithyrambic, yet not
lacking in life, a choral-like episode forming a fine contrast, and the
whole ending happily in a long, quiet coda in F major with a poetic
reminiscence of the principal subject of the opening movement. One
may justly regard the finale of No. 4 as a musical wonder, a new
experiment gloriously carried out. It has the shape of a passacaglia,
an old dance constructed upon a ground bass. The theme consists of
eight bars, each represented by a chord, and is treated in about thirty
variations of the most ingenious contrapuntal devices, greatly
contrasted, yet so coherently that it sounds like an uninterrupted
logical development, holding our interest keenly alive and increasing
our enjoyment till the splendid end is reached.
We have thus seen how many strong features Brahms has
introduced in the symphonic form, without departing from its classic
foundation; but it is still more important that as a genius of a
superior mind and noble soul he had the right material in himself to
fill this greatest form of instrumental music with an adequate and
original inner life, reflecting the highest spirit of modern German
civilization.
The characteristic feature of the Academic Festival Overture is the
successive introduction of several German student melodies, not in
the form of a potpourri, as it has been unjustly regarded, but as
themes developed with consummate art, expressing the inspiration
of a solemn festival, of loyalty to the fatherland, of merrymaking and
youthful exultation. Every page shows the hand of a superior master.
Still greater is the tragic overture, its spirit reflecting a heroic
struggle, gloom, solemnity, but also hope and comfort; its form being
particularly interesting by an ingenious combination of the working
out and recapitulation into a sort of free, yet coherent, wonderfully
constructed and deeply impressive fantasia.
How much we should like to speak in detail of the two concertos
for violin and for violin and ’cello! It would be a misnomer to call
them symphonies with obligato solo parts, notwithstanding the very
elaborate orchestral score, but more incorrect to compare them with
any virtuoso concertos. Enormous technical difficulties are to be
conquered in the service of high musical purposes. The arrangement
is after the classic model, in three movements. Of these the slow
movements with their melodic breadth are the more enjoyable, while
the extensive outer movements, with their rich development of
peculiarly fine and original themes, require repeated hearings to
reveal all their innate beauty and greatness. And these works, too,
belong to the future and can afford to await their time for a general
appreciation.
Brahms’ earlier chorus works are an Ave Maria for female chorus
and orchestra, a funeral chant with wind instruments, four female
choruses with harp and two horns, seven Marianan songs, a setting
of the 23d Psalm for female chorus and organ, several motets and
part songs for four, five or six voices, sacred songs, and twelve
romances for female chorus, partly with piano accompaniment. Now
and then we are reminded of the style of Palestrina or old German
folk-songs, then again of Bach’s polyphonic art with fugues, simple
and double canons, yet throughout of a new, peculiar mode of
expression, full of poetic sentiment. Among the works of later years
we mention two motets, which are praised as Brahms’ highest
achievements in polyphonic writing, seven songs for mixed voices,
and many arrangements of old German folk-songs.
The German Requiem is of such great importance, that without a
knowledge of it neither a full estimation of Brahms’ individual genius
nor of the significance of the latest epoch of music in general can be
obtained. Taking from the old Latin funeral mass only the name,
Brahms selected certain verses from the Bible, expressing not only
the sadness and terror of death and judgment, but also hope and
consolation,—even thankfulness and praise. His work, independent
of any church service and to be sung in a living language, contains in
each note music which came from the depth of a noble soul and was
written by a master of the highest and most complicated field of
vocal composition. Entirely free from conventionalities or dry
learning, each of the seven numbers gives completely what his genius
was able to accomplish. It is indeed the great funeral chant of
modern music, at least for Germans and Protestants. Choruses I.,
IV., V. and VII. have a quiet character, finely expressing the milder
feelings above mentioned, yet with all their seeming simplicity
showing a consummate art in the details of their construction, No. V.
being mainly given to a difficult soprano solo. No. II. (“Behold all
flesh is as the grass”) is a peculiar funeral march in three-four time,
the chorus singing partly in unison to strange and impressive
orchestral music; after a touching animato (“Be patient unto the
coming of Christ”) the principal melody is repeated, followed by a
long fugue (“The redeemed of the Lord shall return again”). No. III.
opens with a baritone solo, lamenting the frailty of life, soon joined
by the chorus, rising to a climax expressive of hope. Then follows
that famous fugue, in an astonishingly rich polyphonic treatment,
moving over an uninterrupted, much criticised pedal point on D to
emphasize the words, that “the righteous souls are in the hand of
God.” No. VI. is regarded as the culmination of the work. After the
chorus’ lament that “Here on earth we have no continuing place,”
comfort is brought by the baritone voice unfolding the mystery of the
resurrection. The chorus repeat this and burst out in an ecstatic
vivace, “The trumpet shall sound, the dead shall be raised!...” “...
Grave, where is thy victory, death, where is thy sting?” In wonderful
modulations climax after climax is reached; finally in glorious C
major a double fugue is added, a hymn of praise to “the Lord of
honor and might,” whose proportion, art and impressiveness alone
suffice to make Brahms a compeer of the greatest masters of
polyphonic music. Throughout, chorus, orchestra and soloists have
to overcome the greatest difficulties, but seldom are their efforts
directed to more ideal purposes.

JOHANNES BRAHMS.

From a photograph from life by Fr.


Luckhardt, Vienna.

For the “Song of Triumph” Brahms selected some mysterious


verses from the Apocalypse. Of the three large numbers for double
chorus, orchestra and organ, some portions have been called direct
imitations of Handel; yet even there one finds enough of Brahms’
individuality and throughout an intense heartiness and directness of
feeling. In singing this music, one is overwhelmed by its grandeur.
The second number, more purely Brahms’, is of particular beauty,
the chorus “Let us rejoice” being joined by a cantus firmus of the
wood instruments on the choral “Now, thank ye all the Lord!” In No.
III., opened by a baritone solo, an enthusiasm is reached in the
Hallelujah surpassing any jubilant chorus music written since the
Ninth Symphony.
The “Deutsche Fest-und Gedenksprüche” have a uniform patriotic
purpose. There are again three large and most difficult numbers for
double chorus, without solo or accompaniment. No. I. refers to the
battle of Leipsic in 1813 and the regained liberty from the Napoleonic
bondage (“Our fathers hoped in thee, thou helpedst them,” etc.), and
has an imposing character of resolution and vigor. No. II., referring
to the collapse of the French in 1870, illustrates in lively contrasting
colors “a palace guarded by one strongly armed and remaining in
peace” and “an empire that falls in discord and becomes waste.” No.
III. praises the splendor of the new united empire, but warns its
people “to beware and guard thy soul well, that it shall never forget
the story which thine eyes have seen.” A deeply religious spirit also
pervades this great and but little known work.
The Rhapsody for alto solo, male chorus and orchestra treats a
portion of Goethe’s “Journey through the Hartz in Winter.” Once in
1777 the poet left a hunting party to pay an incognito visit to a young
admirer of his genius, who was in a Wertherish despondent
condition of mind. The impression received by this adventure gave
rise to one of his deepest yet somewhat mysterious poems, which
inspired Brahms to one of his greatest works. The opening orchestral
sounds touch our inmost heart; sighs and the anguish of a trembling
soul is their spirit; then the solo voice in tones of intense feeling asks
for comfort for one “who from the fullness of love drank hate of man
and in loneliness devours all that hath worth in him.” A peculiar
combination of three-two and six-four time illustrates finely this
anguish and restlessness. Gradually the music becomes more quiet,
till with a harp-like accompaniment, chorus and soloist sing a hymn
of indescribable beauty and loftiness, imploring “the all-loving
Father to enlighten the heart of the unfortunate, if but one tone from
his psalter can reach His ears.” The solo part requires a truly inspired
musician, whose voice is the instrument of his soul. The short chorus
is also a difficult task. Many times has the writer heard this heavenly
work, but never without its repetition being demanded and given.
Yet how little known it is in this country!
An extensive work for male chorus with tenor solo and orchestra is
the cantata “Rinaldo,” the text being again from Goethe. It deals with
a romantic story from Tasso’s “Jerusalem Delivered,” has partly a
solemn, partly a lively dramatic character and breathes the
refreshing air of the sea. The more or less extensive and elaborate
choruses are very different from the conventional style, the solo part
is unusually difficult and so exacting that an adequate performance is
seldom secured.
In three works Brahms has illustrated the relentlessness of Fate,
selecting poems of almost Greek grandeur and beauty. Hölderlin’s
“Song of Destiny” contrasts the blessed abode of the divine spirits
with the fate of the “restless, grief-laden mortals, who blindly wander
from one sad hour to another.” Schiller’s “Nänie” mourns “that even
the Beautiful fades and the Highest must die,” and “The Song of the
Fates,” from Goethe’s “Iphigenia,” warns the human race “to fear the
gods, doubly those whom they have exalted, for they turn from entire
races the light of their eyes.” The last work is for six, the others for
four chorus voices. Everywhere the orchestra is important, rich in
weird, characteristic effects. Bold modulations and rhythmic
combinations always in keeping with the composer’s high conception
of the poetry affect deeply ear and heart. Who but Brahms could have
found music so worthy of such profound poetical subjects! In the
“Song of Destiny” he even surpasses the poet by repeating at the end
the wonderful orchestral introduction indicating hope for our own
final attainment of the abode of the blessed spirits. The “Nänie” is
dedicated to the mother of the lamented painter Feuerbach, who had
been a true art companion of Brahms. Only a careful, sympathetic
rendering will reveal the beauty of this work. In the “Song of the
Fates” there is a movement of a quiet, melodious character, which
many critics have declared to be entirely contrary to the meaning of
the text. To us it seems more like a well justified, touching expression
of pious submission, wonderfully calming our excitement for the
mysterious ending with its harmonies and orchestral sounds never
heard before.
Brighter is the character of some works belonging to a field which
Schumann had specially cultivated, yet where Brahms shows again
such originality that he has been much imitated. His delightful vocal
quartets with piano accompaniment, graceful and bright or deep and
gloomy, charm greatly by their artistic construction, beauty of
thought, feeling and sound and peculiarity of colors. Still more
famous are the two collections of Love-Song Waltzes for voices and
piano for four hands, resembling the sparkling pianoforte waltzes
Op. 39, most varying in shape and mood, the words being mainly
from Daumer’s “Polydora,” those of the fine, quiet closing movement
in nine-four time being selected from Goethe. The eleven Gipsy
Songs Op. 102 are also meeting with an enthusiastic reception,
Hungarian spirit and rhythm giving them a peculiar color, the moods
being either humorous or passionate, melancholy or exuberant,
quartets alternating with solos, the accompaniment being as
elaborate as it is effective.
Of the twenty highly remarkable duets some have, in spite of many
harmonic and rhythmic finesses, quite a plain character, while others
are very elaborate, the voices either joining or alternating. As
particularly typical we mention “The Seas,” “The Nun and the
Knight,” “The Sisters,” “The Messengers of Love,” “Edward,” and
“Let us wander.”
Finally we have reached the field in which Brahms has been
especially fertile and original, his “Lieder.” To speak of them only in
a general way is difficult indeed. Thirty-one of the published 115
works contain nearly 200 songs. Throughout his whole career
Brahms has been writing songs; there was in his soul a lyric element,
kindled again and again by the beauty of feeling, thought and diction
of the great German poets, and he found a style of song-writing so
independent, that in spite of some more or less striking exceptions
one can hardly trace his relation to Schubert, Schumann and Franz.
He is their equal as regards wealth of invention, noble conception of
the text, finishing of details. Yet in treatment of the voice, relation
between vocal and instrumental part, and construction of the latter
he opens a new path. In the selection of poems he shows eminent
knowledge and taste. Many half-forgotten poems of a superior order
he has awakened to fresh life; others, which on account of their
peculiar metre or meaning have been avoided, have found in him an
unexpectedly effective interpreter. However, it seems to us as if the
poems often suffer transformation. They have inspired the composer
with certain tone-pictures, which in turn impose upon them very
distinctly the spirit of his own strong individuality. This individuality
is by no means always deep and heavy, for smiles and dancing are no
strangers to it. Often the melodies are as plain as folk-songs, but
always of great nobility. With a few notes the composer reaches our
hearts and lifts us at once into a higher region. Other melodies again
are as elaborate as a dramatic scene. The accompaniment,
inexhaustible in forms, yet never conventional, simple or with great
harmonic wealth and peculiar figuration, rivals the singer in
expressing the moods of the poem. Of the so-called folk-songs (old
German, Swiss, Bohemian, Scotch, Italian, etc.) some are treated
most artistically, others with a touching simplicity. Very few poems
composed by other masters are found among his list, and the favorite
poets Heine, Eichendorff, Chamisso are almost avoided. A
remarkable exception is the separately published “Moon-night,” very
different from Schumann’s jewel song, yet not inferior. Goethe,
Hölty, Platen, Tieck, Schenkendorf, Groth and Möricke are fully
represented, often by poems of an antique spirit and form. Keller,
Daumer, Heyse, Schack, Herder and many others inspired Brahms
too, and it is noteworthy that he had no music for meaningless
trivialities. The majority of these songs are devoted to love in all
possible phases and moods, often wonderfully reflected in scenes of
nature. There is perhaps more of twilight and autumn than of
sunshine and spring, but exultant and happy moods are well
represented,—also flowers, birds, woods, oceans and storms and the
stillness of the fields,—but all these more in a symbolic than realistic
conception and with a wonderful coloring of the prevailing mood.
The sweet little “Cradle song,” “Erinnerung,” “Minnelied,” “Wie bist
du, meine Königin?” “Meine Liebe ist grün,” “Von ewiger Liebe,”
“Ruhe, Süssliebchen,” “Mainacht,” “Vergebliches Ständchen” are
only a few familiar jewels among the rich collection; how many more
deserve the same sympathy and study from singers with noble
artistic ambitions! Special mention is due to the two fine songs for
alto with viola obligato Op. 91 and to the fifteen romances from
Tieck’s half-forgotten fairy tale “Die schöne Magelone,” which have a
most elaborate form and an intensely emotional character. Nowhere
indeed can one get a better estimate of Brahms’ high significance as a
song writer than here, where the poet appears like a dwarf in the
light of the composer’s higher genius.
Greatness indeed remains Brahms’ characteristic feature,
wherever we look at him or at his works; greatness in ideas, purposes
and powers; greatness in self-criticism and faithfulness to the dignity
of his art; greatness in the devotion to past masters and
independence of contemporary influences; greatness in the sincerity
and simplicity of his manners and relation to the outer world. Never
appearing as a revolutionary spirit, yet he has himself introduced
many strong innovations in various fields, and for a long time his
works will not only afford profound enjoyment to earnest lovers of
our art, but be a source of the most valuable studies for those to
whom its further development will be entrusted. Long has he been
ignored, patiently has he waited, till the world has come to him to
respect in him the noblest musical genius of our time.

Louis Keeserborn
CARL GOLDMARK

Reproduction of a photograph from life,


made by J. Löwy in Vienna.

You might also like