I'm Miko Pawlikowski and this is HockeyStick.
Today we're talking about robo advisors, a topic in between tech and finance.
To do that I'm bringing in some heavy hitters, the authors of "Build a Robo
Advisor with Python from Scratch", Rob Reider and Aleksander Michalka.
Rob has been a quantitative hedge fund portfolio manager for over 15 years.
He holds a PhD in finance from the Wharton School and is an adjunct professor at
NYU, where he teaches a graduate course in the math finance department called Time
Series Analysis and Statistical Arbitrage.
Alex leads the investment research group at Wealthfront.
He holds a BA in Applied Mathematics from UC Berkeley and a PhD in Operations
Research from Columbia University.
Welcome to this episode, and thank you for flying HockeyStick.
All right, Rob, we're going to start with you.
when I read your resume, I felt very small,
not only to mention your extensive experience, but also
all the right names on it.
The Wharton, a PhD in finance, NYU, adjunct professor.
Can you tell us a little bit about what you're teaching and what you're doing?
after my PhD, I, worked at a bank.
I worked on, derivative securities, then I moved to their proprietary trading group.
then, I moved to, an actual hedge fund, Millennium Partners, big hedge fund.
went to another hedge fund, which blew up.
it's a very sad story.
It was started by a medical doctor and, wanted to, But then somebody
on the medical side, the health care side, committed insider trading.
It was a front page of Wall Street Journal.
and the hedge fund basically, blew up.
but then after that I had a very interesting, experience.
I worked at a wonderful company called Quantopian.
a backtesting platform in Python.
So you can go into their platform, backtest different trading strategies.
They supply data.
They had a lot of built in code.
and then their basic business model was they were going to try to be
the first crowdsourced hedge fund.
So if you thought you had a good strategy, you could just hit a button
and be considered for actual money.
And they actually got an investor to see their hedge funds.
and it was interesting for me because I started my life as an
engineer and did a lot of coding.
And then I moved away from coding for years.
Like when I worked at millennium, I had people work for me and
they would do all the coding.
So my coding skills atrophied, but when I, went back into Quantopia and I had
to learn Python, like I'm so old that I learned Fortran as my first language.
I picked up a Python book and I just loved Python.
so that sparked my interest, in doing Python.
and then I actually had A stint at a robo advisor as well, which
was a startup robo advisor.
I think it's very hard to be a startup anything, especially when you're
competing against large incumbents like, Vanguard and Schwab and things like that.
and then I teach at NYU, so I've been teaching for, over 15 years.
I teach a course on quantitative trading for a master's program,
it's a one and a half year master's in mathematical finance.
then you also have that online course time series analysis in Python.
So I guess you, taught yourself Python.
now you're teaching everybody else.
yeah, so when I was at Quantopian, there's this company called Datacamp.
Quantopian was in Boston.
Datacamp used to be in Boston, now they're in New York.
I guess their offices were near Quantopians, and they
were just starting out.
And they said: we need somebody to teach a course in time series analysis in Python.
So Quantopian suggested that I do it.
And that's actually related to our, origin story, because once I did that
online course, which became fairly popular, a few publishers reached out
to me and said, do you want to do a book on time series analysis in Python?
And at the time I was busy, I was bored of the subject, so I turned it down.
the publisher Manning said, Do you, we pick somebody else to do it.
Do you want to edit what they're doing?
and then, I started like editing somebody else's work.
And so like, why am I spending all this time, editing somebody else's work?
Maybe I should just write my own book.
And the next kind of offer that came along was this book on robo advising and
Python, which I know something about.
And then I knew I know stuff takes me a long time to do.
I'm a perfectionist.
Things take me three times longer than it would take somebody else.
So I knew it would take me forever to write a book.
So I knew I had to find a co author.
And I basically just cold called Alex.
I didn't know who he was.
I just saw that he was head of research at a Wealthfront.
He had the perfect background, a PhD, worked at a robo advisor.
So I just reached out to him and said, would you be interested?
And we hit it off and that's how we started collaborating.
I
So you were roped in Alex.
Is that right?
One day you just wake up, you get a call.
It's Oh, fine.
I'll write a book with you.
yeah, I had kind of always wanted to write a book.
never was sure what the topic would be, had a few candidates in mind.
But then, when I met Rob, I thought it was the perfect fit, like you
mentioned, I've been working at Wealthfront, as the head of research
for about two years at that point.
And, Rob had basically already written the book.
He had a full outline of all the chapters and the sub chapters and all this stuff.
So it made it really easy for me to say yes.
I also saw that you worked at weather bill to do weather derivative pricing models.
that sounds very interesting to me.
can you talk a little bit about what that actually means in practice?
Yeah.
So the company was started, in 2006.
It was a friend that I knew from college.
and he roped me into it.
To use that term, I was going to go straight through to grad school, but right
before I was graduating, he convinced me to come on and work for him for a year.
And the weather derivative thing isn't the most important part.
really what we were trying to do is build a, basically an insurance solution for
businesses that were affected by weather.
So you can think of things like golf courses or events, if you're having a
big outdoor concert or sports event and expecting to sell a lot of tickets, sell
a lot of merchandise and it gets rained out, you could lose a lot of money.
Or if there's a, really warm winter and you're a power utility,
you might not sell as much gas.
so you could use a weather derivative contract to, hedge against whatever
weather peril you're facing.
the market had been mostly in that kind of utility sector that I mentioned.
for the longest time, but it was a very manual process.
If you wanted to hedge weather risk, you had to get your team of lawyers and
go to a bank and talk to their team of lawyers and get the details hammered out.
what we did was use technology to make the process a lot simpler, cheaper, faster.
And, let's see, it was all online.
So you never actually had to talk to anybody could go online and
configure a contract and just buy it right there on the spot.
So how much of that was actual weather modeling?
There was a good amount.
So there are multiple ways to price a weather contract.
you can buy historical weather data, which is what we did.
And, the simplest way is just model the payouts that would have happened.
historically and figure out a fair value for the contract based on that.
Another way that you can do it is actually simulate the underlying weather processes,
like the daily temperature values and the daily precipitation values, and then run
lots and lots of simulations and, take the average compute payouts for the contract
based on those weather simulations, and then, come up with a price based on that.
So we started with the easier method, that was my first task on the job,
and then later we started moving into the more complex methods where you're
actually modeling the underlying, weather processes, which is a lot of work,
especially when you have thousands of, locations, which are usually airports, but
not always, thousands of locations across the US, across Europe, Canada, pretty
large scale, pretty difficult problem.
So for anybody listening to this, you'll probably notice that it's
not our typical technical, episode.
We're going to expand our horizons a little bit and try to understand an entire
new environment, the finance environment.
But before we jump into the robot advisors, I want to use this opportunity
because I don't usually get people with, 15 years, experience in a hedge
funds portfolio manager role to a lot of people listening to this, they're going
to be coming from software engineering background and probably their exposure
of how hedge funds actually work is shaped primarily by things like billions.
how does it compare to real life?
from your experience, are there elements of billions that you would say are
representative, or is it all Hollywood?
only watched a handful of episodes of Billions, so I can't speak to that.
But of the few episodes I watched, I thought it was actually pretty realistic.
And I think the writers, know Wall Street.
this like sort of two types of hedge funds.
There's, Traders that use fundamental information.
So they'll, analyze companies, products and their financial statements, and
they'll listen to earnings calls and they'll talk to sell side analysts.
And those are like the fundamental traders.
And then you have the quantitative traders that don't know, anything
about what the company does.
They just, use statistics and computers to come up with trading strategies
and in billions, they had both.
and that's millennium was like that too.
Millennium, had something like, 150 different little tiny groups
or silos and each group might be two, three, four people.
and some of them traded based on fundamentals and usually focused on
a single sector, because you can only really be an expert on one little area.
And then they also had a large number of quantitative traders as well.
and I should say that.
Millennium is considered a multi strategy hedge fund, but there's lots of other
types of hedge funds, there's some hedge funds that have large groups,
like there's a known hedge fund, Two Sigma, that has instead of small
silos of two, three, four people, they have large groups of a hundred people
and they work in a different way.
They also do quantitative stuff, but in a large collaborative environment.
Millennium was very secretive, groups didn't talk to each other, give away
their secret sauce, which solves some problems and creates other problems.
on one hand, when you work in small silos, you have to reinvent the wheel.
You have to come up with your own trading algorithms.
So there's no common algorithms that everyone could use, but
also it aligns incentives.
You don't have to worry about people like stealing your stuff
and going to another hedge fund.
And, Also, at Millennium, every little group pays for their own data.
So when I worked at, J.
P.
Morgan, we subscribe to all these different data sources.
And we don't even know why we subscribe.
somebody at some point may have said, Oh, I need this, data.
And 10 years later, we're still subscribing to it.
Whereas at Millennium, it comes out of our own P&L.
So we have the incentive to try to, just, get the data that we need so
it solves a lot of incentive issues.
So there's a lot of them and there's going to be a lot of variation.
And then is it true to say that in the recent decades, we've seen this
rise of this new breed of, investment, funds that we call robo advisors,
like an umbrella term for all of them, or is it older of an invention?
the hedge fund world is very different from the robo advisor world.
The hedge fund world tries to figure out ways to beat the market.
Whereas I would say the robo advisor world is investing in kind of
low cost index funds in the way.
They try to beat the market is through, saving money on taxes and
having higher after tax returns.
So robo advisors typically don't try to, figure out like hedge funds
do, like which stocks to buy, which stocks are better, which one's going
to outperform the market, what their hedge funds look for different anomalies
and try to take advantage of that.
Robo advisors take a totally different approach and say we're
just going to invest in index funds.
We're going to do in a very tax efficient way
So what was the thing that got you interested in robo advisors coming
from the background of, of hedge funds and beating the markets and doing all
this ambitious things to moving on to, something more for everybody, the
average Joe's, robo advisor thing.
What was the trigger, that got you interested in that?
even working at hedge funds.
I've always been interested in personal taxes ways to save money on taxes.
20 years ago, I was telling people at work about this concept of asset
location, not asset allocation, but something called asset location, which
we could talk about later, but this was something that I was espousing
many years before it was popular.
So I've always been interested in personal finance.
I do my own taxes on TurboTax.
So as a result, I've learned a lot about the tax code by
being a 'do it yourself' person.
And this idea of trying to, save money on taxes, for example, is something
that I've always been interested in.
And what about you, Alex, you work at Wealthfront, which is, one of the
more easily recognizable, at least from where I'm sitting, robo advisors.
What was the journey for you to, get interested in that?
Yeah.
So let's see, like I mentioned before, I started in tech, but
the company that I was working for had a financial slam to it.
We were risk management company, where in particular, the risk that we were
helping people manage against was weather.
And then after grad school, I actually worked at a, hedge fund
also called AQR Capital Management.
It ran a variety of strategies, some were hedge fund strategies where, you're
going along a bunch of stocks and short a bunch of stocks and, trying to, Hedge
out market risk, make a return and somewhere along only strategies where,
we're buying stocks, getting full exposure to the stock market, but we're trying
to beat the market, like Rob mentioned.
And I heard about Wealthfront at some point.
I don't know why my wife and I we were on the websites of Wealthfront.
And I noticed that the chief investment officer was Bert Malkiel, who's a very
famous, name in the world of finance.
He wrote a book called "a random walk down wall street".
he's been a long time proponent of indexing, not trying to
beat the market, low costs.
tax efficiency and their, VP of research at the time, the person who
I ended up replacing, had spent a year at AQR also back in the early 2000s.
So I noticed they had some very talented researchers, very talented personnel.
I started reading, some of the white papers that they'd written
in blog posts, and I was just very impressed by the company.
And I think a phrase that you mentioned earlier before was one other driver for
me, which was the average Joe thing.
I really like the idea of having a, serving a client base that was,
much more directly retail at a QR.
A lot of our clients were big institutions like pension funds, and
endowments, sovereign wealth funds.
And there are individuals that are benefiting from those investments.
but it's just a lot more direct at wealth front.
We're very directly serving the end investor.
And what I found after joining was it was even more rewarding.
You'd get these emails from clients telling us how much they love our
product and, love the service.
that always helps,
that helps you sleep at night.
so if we were to try to draw a little bit of a landscape for robo
advisors, where does it start?
What would be considered like the first robo advisor that hit the market?
I think, Betterment actually claims that title.
but Betterment and Wallfront were the two earliest ones back in, I don't
know, 10, 12 years or so ago, I think.
And then over time, more have entered, I think a number have failed.
Like Rob mentioned, it's tough to start as a robo advisor.
You really need to reach scale to make it work.
And then over the years, there've also been a number
of robo advisors launched by.
larger incumbents.
so places like Vanguard, Schwab, like the big advisory and brokerage houses,
have launched their own versions of robo advisors to compliment the human financial
advisors that they've had for decades.
So you mentioned Vanguard and I think at least from my experience, when I
speak to other techies and software engineers, the one thing that they all
know about investing is that they should.
Put some money on S&P 500 and keep it forever.
And that's the smart way to do it.
So from that point of view, if you were to explain to a five year old software
engineer, what's the real difference between using something like a robot
advisor, versus just putting some money on S&P and hoping that the US doesn't
stop being one of the best markets.
I would say, first of all, even if you're going to use Vanguard, you still have
to make a decision about Which Vanguard funds to buy There's S&P 500, but you
might want to hold some bonds too.
and how do you figure out the mix between stocks and bonds?
And that's probably the most important decision an individual investor would
make, more important than trying to beat the market by 1%, there's no right
or wrong answer, but what you choose for your asset allocation is probably
the most consequential decision.
and we do in the book have several chapters on this whole, idea of asset
allocation, but, as we talked about, there's other ways to even do better
than just a straight Vanguard index 500 through various tax savings techniques.
let's talk about this tax savings techniques a little bit.
I think you used the expression free lunch a few times as we spoke about it.
What's the main draw?
What can you offer as a robo advisor that, people might not know about?
there's a few different chapters on these.
I'll talk about two and then I'll let Alex talk about one of them.
let's say you're in the, decumulation phase of your life where you're retired
and you have to draw down on your savings to pay for your expenses.
you're faced with the decision of, which accounts should I draw down
from, Constantly throughout the book.
We thought about how is what we're writing going to be different from what you
would get with something like ChatGPT?
And if you ask ChatGPT, this question, if you said, I'm an individual, I
have $2 million in an IRAI have a million dollars in a brokerage account.
Some of that money has, low cost basis, some of it has high cost basis.
I also have a small Roth account with a half a million dollars.
I'm in this particular tax bracket.
I have to take, required minimum distributions in
a certain number of years.
Oh, I also have an inherited IRA that I have to deplete in 10 years.
how should I start withdrawing money?
It would give you some very generic, general advice.
It's not really designed for giving custom tailored, and that's what I
think is one of the interesting things, why I think the book was a little bit
more interesting because you can't just ask these questions for ChatGPT.
and it does make a huge difference.
Like we showed in the book that depending on which strategy you choose
for withdrawing your assets, it could extend your assets by, a decade or more.
So these are consequential decisions that actually have a big impact.
and it's all based on taxes.
a second area that I mentioned in the book, which is like the sort of free
lunch, is this idea of asset location.
suppose you have, a few different types of accounts, which I just mentioned,
maybe you have a 401k or an IRA, maybe you have a taxable account, maybe you
also have, a Roth account, and then you have different assets, maybe you have,
US stocks, international stocks, you have different, money market, a bond account.
how do you place those different assets into which accounts?
And it's a really interesting optimization problem.
it's not the same for everybody.
It depends on different factors.
And again, it's really a free lunch.
one of the basic concepts is that if you have money in stocks, it
already is somewhat tax advantage.
if you're not constantly trading the stocks, if you are, a buy and hold
investor, then the capital gains on those stocks get deferred anyway, you're
not realizing those capital gains.
So in some ways, it might not make sense to put those stocks in an
IRA, which is also tax deferred.
And even more importantly, if you have the stocks in a regular taxable,
Vanguard account, once you finally do realize those capital gains, you pay the
lower capital gains tax rates, whereas if you had put the money in an IRA,
when you finally take the money out, you pay ordinary income taxes on that.
but it's also not as simple as saying, all right, I'm going to shift bonds into my
IRA and stocks into my taxable account.
It's much more complicated.
we go through in the book, how you would do an optimization like that.
so just a very quick, detour for people who are listening to this,
who are not US-based, you mentioned things like 401k, IRA, and Roth.
Would you mind very quickly explaining what these things mean?
Yes, and in fact, we did recognize when drafts of our book were sent to
different, reviewers that some people were in other countries and saying,
why is it so focused on the US?
So we added a couple of lines in there to say that, even though we're
US-centric, a lot of these same concepts apply in other countries and
we gave, an example or two of that.
so in an IRA and 401k, and they're very similar to each other, So you
don't pay taxes when the money goes into the IRA, but then when you
deplete the IRA, you pay taxes.
for a taxable account, you've already paid taxes on the money.
So you're using after tax money for just a regular brokerage account.
And at a Roth account, you also pay, taxes up front, but then when you take
the money out of the end, unlike an IRA, a rough IRA, you pay no taxes at the end.
And then there's other types of accounts, like there's a health
savings account where you don't pay taxes in the beginning or at the end.
so there's lots of different types of accounts with different tax treatments.
You said it was basically an optimization problem.
So you end up with some kind of choice of parameters of what you
think is more important to you.
And then you basically can write a program that solves that for you.
is that roughly where it is?
Yes, yes.
So everybody should go to manning.com and get the book now and go and write
some code to optimize their money.
Should we end the episode here then?
it's actually a complicated problem.
and a lot of robo advisors, do something called taxless harvesting,
which Alex will talk about next.
but very few actually do asset location because it is a very complicated
thing to do and it is very customized.
So surprisingly, even though this could be a huge tax savings,
it's not really widely done.
and I think that's one of the exciting things about the book is that, I think
there will be a hockey stick, to use that term, pattern where kind of these things,
it might not be like a steep hockey stick, maybe a lower slope hockey stick, but
where these ideas start to take hold and more and more people do them, over time.
What's a glide path?
so there's a whole industry of, something called target date funds.
Vanguard offers many of these.
These are funds that, change your asset allocation over time.
So the kind of theory is that as you get older, you should be
holding, less stocks and more bonds.
And we actually cover this in one part of one chapter about how to
actually do that optimization as well.
and I think we didn't explicitly say it, but between the lines, there are
different restrictions, all these accounts, there are only certain amounts
and you can put in them at different time periods and stuff like that, which
makes it a level more complicated.
Is that right?
Yes.
And there's so many complications with all this stuff.
we cover required minimum distribution, so when you hold an IRA, at some point,
you have to start taking money out of it, and there's certain rules on that,
and it gets even more complicated when you talk about the rules for inherited
IRAs, and then we mostly focused on federal taxes, but there's also state
taxes and every state has different rules.
So like New York, for example, you can take out $20k every year of an IRA without
being subject to New York State taxes.
So that also affects your decision about how to start
withdrawing money from your IRAs.
You might want to go right up to that limit every year, for example.
so Monopoly all of a sudden sounds like it's pretty
straightforward and pretty boring.
They should update the version that has all of this added to it.
I
can definitely see the draw of why somebody would go and pick
up the book to learn about that.
and we're going to get into the technical part of the book in a sec,
but we didn't say it explicitly either.
Who is really your target audience?
I think that was a really tricky thing for Alex and I.
So we had in mind a widely varying audience.
On one hand, for developers that were interested in saving money in finance,
or making money, it reminds me, I was just reading the obituary of Jim
Simons, who was like this quant guru, and he was a Brilliant mathematician.
And at some point in his life, he decided, rather than working on math
theorems, I actually want to make money.
So part of the audience is for people that are, coders that want to turn
their skills into making money.
and they have one set of skills, which is they're really probably great at Python,
but don't know much about the finance.
Then we also had in mind, a segment that maybe our, financial advisors
that maybe, know a lot about the finance part, but a lot of them
actually do stuff in spreadsheets, and they don't know any Python.
and that's making it even more complicated.
The book has a little bit of math in it.
if you were to draw a Venn diagram where one circle is people who know Python and
other circles, people who know finance and other circles, people who know math,
like the intersection of that is small.
so we try to make it so that if you don't know any Python and don't care to learn
it, you could just skip the Python parts.
If you don't know, any math, we try to emphasize that, we include
the math for completeness for those people that are interested in it,
but we could just skip that part.
We put some of that stuff in the appendix.
so it does have a wide audience and in fact, I know that you
wrote a book for Manning.
so you're aware of this, when we had a draft of the book, the Manning
sends out the draft to something like 15 reviewers and Manning's staple of
reviewers are people that are software developers, not financial advisors,
because that's just not their world.
So we got, reviews from mostly software developers.
And in general, the reviews were great, but obviously it's human nature to
focus on what are some of the critiques.
so like we had a throwaway line in the first chapter about why we
chose, Python over other languages.
And they were all over that.
we got a million comments about that.
And then we would also get comments like, what is a T bill or what
does it mean to short sale?
Alex and I had a lot of discussions about do we want to explain these concepts?
and usually where we landed was that you could easily Google
some of the financial terms.
we didn't intend for this book to be teaching the basics of everything.
So we assume that people.
have a minimum understanding of Python.
We're not trying to teach people Python from scratch or have a minimum
understanding of finance and know some of the terms and if you don't
you just have to look those up.
So did your target audience drift a little bit from where you initially started
as you were writing the book or are you roughly where you were at the beginning?
I think we thought a lot about drifting, but in the end I think we ended up,
either out of laziness, or because this was, our philosophy, we did not
change it that much in terms of trying to cater to every single segment of
the population we definitely did make changes to try to accommodate what some
of the reviewers were complaining about.
I tried to make the math a little bit simpler, but I didn't eliminate the math,
so yeah, we definitely did a few things to try to accommodate, some of the critiques.
I definitely see because this really is different to your typical manning book.
There is just more of a completely different domain coming in.
So they must have been a little bit confused at least okay, so let's move a
little bit towards the technical bit then.
And maybe let's talk about some of this maths.
I think one of the things that a lot of software engineers have heard here and
there, but never actually fully understood what it's for and why it's useful, is
things like Monte Carlo simulations.
Can you give us like a quick, you know, again, five year old software
engineer listening to this wondering what should I do with my life?
Should I be an astronaut or should I be a software engineer?
Tell them about Monte Carlo.
Monte Carlo is a hugely useful technique for solving all sorts of problems.
In fact, when I worked as an engineer before I got my PhD in
finance, I actually did Monte Carlo simulations on radar systems.
And then my dissertation was related to Monte Carlo simulations.
that was actually the title, was, had the word Monte Carlo simulation
in the title of the dissertation.
so it's used in many different fields.
and I could get into this a little bit more later, but I think one of our
hopes when we wrote this book is that a lot of the techniques that we use
are just general techniques that could be used in a lot of different realms.
So hopefully, the AI chapter that I have also can be used and
it's not specific to finance.
it's much more general.
so Monte Carlo is very general technique, but it's particularly useful for solving
certain financial planning problems, and I show in the book that, for a
few reasons, you might be tempted to say, all right, stocks have an average
return of, let's say, 10%, bonds maybe have an average return of 4%.
if you take a 50/50 mix of 10 percent stocks, 4 percent bonds, that's,
on average, 7 percent returns.
if I'm trying to do financial planning, can I just assume that, I, on average,
earn 7 percent a year and just skip the whole Monte Carlo simulation part.
But the reasons why You can't really do that is, first of all, you might
want to answer questions like what's the probability of running out of money
in retirement, for example, and it's not just a yes or no, it's actually
a probability distribution of what your final assets are going to be.
Some of them you will run out.
if you don't do a simulation, you won't be able to answer probability questions.
Also, it turns out that the order of returns makes a difference
when you have withdrawals.
So if you have a good year and then a bad year, that might
actually be different than having a bad year and then a good year.
And you actually need to do Monte Carlo simulation to
pick up subtleties like that.
and then, there might be certain complications that you just can't
figure out analytically, like with tax rates and, things like that.
there's no analytic closed form solutions to figure out how much money you're going
to have in a certain amount of time.
it's just too complicated.
you have to resort to Monte Carlo simulations where you simulate, a
whole bunch of random paths, random stock returns, random bond returns.
You could do anything random.
You could have, The inflation rate be, a random variable.
you can even make tax brackets.
you could randomize that and say, there's a certain probability
that tax brackets could change.
So you can incorporate all those things in a Monte Carlo simulation, generate,
10.000 different paths, and then see what happens, at the end of those 10.000 paths.
So what does it actually tell you?
if you design this and generate 10.000 different paths, and then
you look at them in aggregate and this is happening, most of them.
So maybe I should worry about this.
what output information does it give you?
you could get a whole probability distribution.
You can answer questions like, I have.
$2.000.000, what's the probability that I'm going to
run out of money in retirement?
so it could give you, a probability.
you could try different policies and run them through Monte Carlo simulation.
And it could tell you: on average, policy X does better than policy Y.
And outside of finance, what would be some, famous
applications that you can tell us?
as the name implies, gambling is always one.
so Monte Carlo.
but it's used all over, in multiple fields.
When I worked on radar systems, there's a lot of, randomness, involved and
there were no closed form solutions.
the only way to, figure out, how many targets can you track with a certain
radar was through Monte Carlo simulation.
we used it when I worked in weather risk management too.
there were underlying processes say daily temperature and it's daily
temperature at all these thousands of locations across the US and the
quantities that we were interested in were derivations of daily temperature.
They might be like.
the average temperature in Chicago over the winter, but we were also cared
about the number of days where the temperature dropped below zero degrees.
some places in the Midwest where people are farming and
they're worried about frost.
And those things are all related to each other through the temperature values.
but deriving closed form or analytic solutions for those joint
distributions, number of frost days in location X and average temperature
in location Y, is extremely difficult.
and so running lots and lots of simulations is a kind of a brute
force way of doing things that are too hard to do analytically.
I think that makes sense.
And that's probably going to resonate with a lot of people.
too much math.
Let's just simulate some of the things and look at it in the aggregate.
That makes perfect sense.
You mentioned AI.
and I know that your book is talking a little bit about
the reinforcement learning.
Can you give us a sneak peek of what we're going to find in the book on that?
I know this may disappoint people because everyone just wants to talk about AI now.
And that's the only thing people want to talk about.
I was just watching, Berkshire Hathaway's annual meeting, recently,
and people were asking the 93 year old Warren Buffett, who doesn't even
own a computer, what he thinks of AI.
this is the topic that everyone wants to talk about.
And in fact, in the book, it was one chapter and we didn't cover,
generative AI in the book at all.
And it certainly there's uses for generative AI and financial planning.
Like I've seen use cases where, Generative AI can summarize meetings.
so financial advisors love meetings with clients and it can take the
transcript and summarize it for people.
it's interesting.
I actually was listening to a webinar, last week where, they used, a survey,
a financial literacy survey of 38 questions that financial advisors
sometimes give to, their clients just to gage how financially literate they are.
And these authors decided, let me see how ChatGPT does with
these set of 38 questions.
And, ChatGPT has been famous for, acing the bar exam and getting a
four out of five and AP chemistry and doing well in the MCATs.
And it actually only got a 45% correct on this financial literacy, which was
about the same as how, high net worth individuals were doing on the test that
were not financial experts themselves.
we didn't cover generative AI, and I mentioned this earlier, like
for customized non generic advice, whether it's the best tool for that.
there's a lot of uses for generative AI in the, financial planning process
and for financial advisors, but I'm not sure it's great at certain things.
So what I focused on was, another branch of AI, which is, reinforcement learning.
and one of the things I like about the chapter is that first of all, for
anyone who just wants to know about what reinforcement learning is, I
think it's a pretty good introduction to it and a good tutorial, and I give
several examples so you can get your hands dirty with some really easy to
understand examples in the finance world of how reinforcement learning works.
The other thing that I think is interesting about the chapter is that
this type of stuff is not being used at all right now by financial advisors,
to the extent that financial advisors want to, it's a very competitive
area, to the extent they want to, differentiate themselves, I think
it's an interesting area to do that.
I basically go through how reinforcement learning works.
a lot of the chapters start with simple examples and then they
go to more complicated examples.
So I start with a really simple example of suppose that you have a million dollars
And you have a goal that you want to have two million dollars in ten years from now.
What's the best way to allocate assets between stocks and bonds to maximize
the probability of achieving that goal?
So the first thing I did was actually, this type of problem
has been solved for decades in the economics realm using dynamic
programming with backward recursion.
So you would start at the terminal state 10 years from now, and then work
backwards and go through every node.
you create this, state space grid where your state might be what's
your wealth, in any given year.
And what year are we talking about between years zero and 10?
and then you have choice variables, which is how much money do I
allocate between stocks and bonds?
this kind of problem was solved using dynamic programming, and I go
through the actual dynamic programming solution for comparison, and then I
solve it using reinforcement learning.
But then I point out that the nice thing about reinforcement learning
and why it's such a powerful tool is that There's several deficiencies
of using dynamic programming.
one of the biggest ones is the so called curse of dimensionality, that if you
have a lot more state variables and a lot more decision variables, then dynamic
programming would just be impossible to run, it would just take too long.
whereas you can solve those kinds of problems using reinforcement learning.
you may have more state variables instead of just what your wealth is.
You might have state variables of.
What's your taxable wealth, and your wealth in IRAs, you can have your
income as a state variable, you can have whether you've chosen, to start
collecting Social Security yet, so you can have all sorts of different state
variables, and then you're forced to do reinforcement learning if you want
to solve that more complicated problem.
And then in the chapter I go through more and more complicated examples.
And just one example that I, highlight.
one decision that people have to make is when to claim Social Security.
you can tell the government anytime between 62 and 70, when you want to start
getting your Social Security payout.
And the longer you wait, the higher the payout is.
And you can Google this, over a dozen calculators.
In the book I give an example of Schwab's calculator.
And they all pretty much do the exact same thing.
They do this kind of break even analysis.
You could do this analysis in a, two column spreadsheet.
you basically say that, if you're going to live to a ripe old age, and they compute
what that cutoff is, let's say it's 84 years old, then you're better off waiting
till you're 70 to take Social Security.
If you're not in great health and you think you are not going
to live as long, either through genetics or your own health, then
you should try to claim at 62.
And it's a simple calculation, but it's a risk neutral calculation.
It doesn't take risk into account.
It doesn't take longevity risk into account.
So the techniques that I cover in that chapter actually uses utility functions
and takes risk into account and it can be applied to all sorts of problems.
some people have a defined benefit pension plan and when you leave the
company or retire, you're given a choice.
Do you want it in a lump sum or in an annuity where you get
money for the rest of your life?
You could solve a problem like that, which is better using the same
techniques in that in this chapter.
And all of that, all the code is in Python, right?
Yes.
and surprisingly the Python code for this is ridiculously simple.
even like neural networks, the code is not that complicated, sometimes it's
a little more complicated to model the environment, but the actual reinforcement
learning code is just a handful of lines.
And there's a few helper functions that are also just a handful of lines.
So I think it's actually fairly accessible to people to actually do this in Python.
what's your take on why Python seems to have completely dominated
anything to do with finance or stats or anything like that, it seems to
be just obvious choice Python you touched on it when you just threw one
line to explain why you chose Python and you got grief from the reviewers.
but why do you think is that?
it's very easy to get started with.
the Hello World program is literally just one line, print Hello World.
It's popular and lots of very useful packages have been written for it.
So for example, in the book, we use a convex optimization package called CVXPy.
We use NumPy and SciPy, which are used by so many people.
So there's lots of support, lots of very useful, well supported packages.
it's not the most high performance language in the world, but it
can also be made pretty fast.
if you care about that, if you're careful with things and use some,
again, some packages that have been written to speed things up one other
nice thing about Python is that it plays pretty well with other languages.
I've also used R a lot throughout my career, and there's a lot of
useful packages for R as well.
but using R like within a system with other programming languages
is a lot harder than with Python.
Okay, so I buy some of that, but to go back to what you just said, print hello
world is one line, so is in Fortran.
You have to add program and end program, but you could argue the
same thing, and making Python fast is typically not using Python under the
hood, just using a C++ library that was implemented in something else.
So is it really just that it looks more approachable and
that's why everybody runs with it?
Because I have this theory that it's really all about brackets You
don't use curly brackets and that's what people typically don't see.
And you use white space.
So it just looks easier.
But when you look into that, is it that much easier to
handle programming languages?
We use pandas a lot in the book, and there's a lot of things that
are made easier when you use pandas.
it just seems like a lot of the tasks are just much easier done
I know the ecosystem is fantastic, but I suspect that the ecosystem is fantastic
because, it got popular and because everybody just started using that.
So I always wonder, is it just because of the curly brackets, but Anyway,
so going back to your book, I was also going to ask you why measuring
returns is so difficult to begin with.
Because like you said all those things and I never really truly understood It's
typically just some percentages, right?
That you estimate it doesn't sound that difficult, but then the moment
you open a chapter about that, it's all like variances, covariances and
all kinds of things that either a simple programmer like myself is
getting a little bit intimidated by.
So to a five year old software engineer, can you just tell us briefly
why it's not as simple as it looks?
Yeah, so it's actually a rather complicated thing, surprisingly.
And I have, one full chapter on it, and I cover some other issues in
another chapter, but just returns.
so first of all, One complication with measuring returns in any kind
of brokerage account, let's say you have inflows and outflows.
Maybe you deposit money, maybe you withdraw money, maybe you have dividends.
if you didn't have inflows and outflows, it would be much
simpler to compute returns.
You could just look at the final value of your assets, the beginning value,
and that's all you need to know.
but it turns out that, with inflows and outflows, there's
two methods to computing returns.
There's, time weighted returns and money or dollar weighted returns.
So imagine as a simple example that you, started out with some amount
of money, let's say a million dollars and had great returns.
you earn 20 percent that year.
And then let's say you add it to your account.
Let's say you deposited another million dollars and then you have a bad year.
Maybe you were down...
15% what would you say your return is?
on one hand you had a 20 percent return and then a 15 percent return.
So your returns seem to be positive.
On the other hand, your ending value is lower than your starting value.
It could be, than the amount of money you put in because when
you had the bad returns, it was on a larger amount of money.
So that basically is the difference between, In the first case,
it's time weighted returns.
In the second case, it's dollar weighted returns.
people might not notice this, but when you look at your Vanguard statement,
it will tell you your returns, and there's, a little footnote.
And if you go into the footnote, it will say, in Vanguard's case,
they use Dollar weighted returns.
In other cases, they use time weighted returns.
and people probably don't even look at the footnotes.
You don't even understand what it is, but it actually makes a difference.
The second issue is if you're evaluating investments, and that's a huge thing
in my other sort of career of hedge fund strategies, that's a huge issue.
But even if you're looking at robo advisors and some robo
advisors says, we perform better.
you have to evaluate performance and you can't simply look at returns.
You have to look at risk adjusted returns.
it may be the case that, one advisor has, on average, 10 percent
returns, but wildly volatile.
And another advisor maybe only has 6 percent returns, but they're basically
like a bond, and bonds are only paying 5%.
So they're outperforming bonds with actually no extra risk.
So you have to factor risk into account when you're evaluating returns.
And there's several methods for doing that.
in a chapter, I cover, sharp ratio, which is one of the more common measures of
risk adjusted returns, and alpha, which is, made it to the popular press as well.
And alpha is also another way of evaluating risk adjusted returns.
In fact, when Google announced that they changed their name from Google to
Alphabet, in their press release, they said, part of the reason is because
we're trying to catalog the entire, alphabet of the world, but also we think
of, of our company taking Alpha bets.
so that's another reason why they call their company Alphabet.
So all the chasing alpha that all comes from that theory.
yes.
And I give an example in the book where I actually apply this principle.
one very popular, area of investing now is ESG investing,
environmental, social, and governance.
So people who feel like they want to not just invest in the S&P 500, but they
want to invest in companies that do good, either in terms of the environment, in
terms of how they pay their workers, etc.
And there's several funds that cater to those investors.
So I actually go through a case study of trying to evaluate the returns of an
ESG fund that's been around for a while.
One good way to intimidate your reader is to name a chapter after a model or a
theorem that has two names, hyphenated.
In your case, it's the Black-Litterman model.
a challenge for you to explain that in 30 seconds or less,
Okay.
and then send people to the actual chapter.
So the goal of the Black-Litterman model was to accomplish two things.
One is to overcome the sensitivity that's inherent to portfolio optimization.
if you're using portfolio optimization and you tweak the inputs just
slightly, you can end up with two completely different portfolios.
And the other goal was to be able to allow.
Investors to specify their views about how they think certain assets will perform,
either in an absolute sense or relative to one another, the model supports both.
the way the model works is by starting with kind of a reference portfolio
from which the investors derive equilibrium returns, and then they
add in and blend in their views about returns to those equilibrium returns.
The equilibrium returns keep the investors optimized portfolio anchored
to the reference portfolio, but then the views, the second part of the
model, allowing the investor to specify, their views on the, future returns
of the assets that they're investing in, allow them, some deviation from
just The standard reference portfolio,
Okay, I'm not gonna lie, you did lose me a little bit there.
Is there a way to explain it in even simpler terms?
let's see a way to allow investors to build portfolios that incorporate
their views about the expected returns of the assets they're
investing in while combating some of the Input sensitivity that's just
inherent to portfolio optimization.
Got it.
Another thing I was gonna ask you about is, tax loss harvesting, because it makes
sense to me, it sounds fruit harvesting, and that's a good thing, but at the
same time, why would you harvest loss?
Why is it a good idea?
What does it give you?
So the phrase that you always hear in finances is buy low, sell high.
And that's typically what you want to do, but with tax loss
harvesting, what you're actually doing is selling low intentionally.
but that can actually be a good thing.
I think maybe the best way to explain it is through an example.
Oh, you mentioned the S&P 500 before that's, an index of large cap US stocks.
And there's another index out there called the Russell 1000.
it's 1000, stocks instead of 500, but those two things are
super, super highly correlated.
If the S&P is down 2 percent one day, you can bet that the Russell 1000
is going to be down also, around 2%.
So the idea of tax loss harvesting is opportunistically selling assets at
a loss to reduce your current taxes.
And the way that most robo advisors do it is by using pairs of funds or
pairs of ETFs that follow different indices, but indices that are very
highly correlated so that when you sell one and buy the other, your economic
exposure really doesn't change very much.
So going back to our example, if you bought S&P 500 at a hundred dollars,
and then a few months later, it was down to 90, you sell $90 of that
fund, you've realized $10 in losses.
Then you buy $90 worth of their Russell 1000 fund.
Your economic exposure is basically unchanged.
You're still invested in $90 worth of, US large cap stocks.
Oh, but you've realized $10 in losses.
So you can multiply that by your tax rate that applies to that loss, which
might be like 40 percent because it's a short term loss, that means that if
you have capital gains elsewhere in your portfolio, you can use those losses to
offset those gains and then decrease your tax bill in the current year.
So you save money on your current taxes.
And that's the very short, simple goal of tax loss harvesting.
and that sounds like a, a free lunch, but it actually isn't because, if
you fast forward 10 years, what happens, let's say the price of
., either of those index funds has gone up to $200.
If you had just stuck with your original investment, you would have had a gain
of $100 right over that, that 10 years, because you've harvested the loss.
You bought the second ETF for $90.
So now 10 years later, you have a gain of $110 instead.
So you've decreased your current
taxes, but that comes at the cost of increasing your
taxes way off in the future.
but that's still a good thing because the other phrase that you
hear in finances, A dollar today is worth, more than a dollar tomorrow.
It's just kinda the opposite with taxes.
Paying $110 in taxes 10 years in the future it's worth paying the extra
taxes 10 years later to save money on taxes now because you can reinvest
that money now and then in the future, you'll have more money than you would
have if you had not done the tax loss harvesting followed by the reinvestment.
Creating kind of almost artificial loss that, lets you defer some of the
taxes that you, we would have to pay otherwise, and you can invest them in
the meantime and, be more efficient.
That sounds pretty creative.
and that's another thing that you can learn from the book.
The book is called "build a robo advisor with Python.
From scratch" and it's available at manning.com a quick question.
I've been wondering about it for probably at least last 45 minutes.
Is it true that like that tech people, I'm going to just bundle everybody,
software engineers, all the programmers.
There's definitely this trend where this people like optimizing things
in their lives, whether it's diet, maybe working out and stuff like that.
But from where you sit, are they any better at optimizing their savings and
their personal finance than the average Joe who doesn't happen to be a programmer?
to optimize this stuff is very hard to do on your own, which is why it's good
to have, this done in an automated way.
We didn't cover this, but in the first chapter of the book, we talk
about how, individual investors suffer from various behavioral biases.
and I think tech investors probably suffer from the same
behavioral biases as any investors.
And some of those examples, and there's been studies on this.
First of all, Individual investors tend to overtrade.
it's generally not a great idea to trade too much.
You pay taxes, you pay transaction costs.
Even if there's no commissions, there's bid ask spreads and things like that.
so overtrading is typically a bad thing and individual investors
typically do too much of it.
there's also another, behavioral bias that individual investors
suffer from is herding.
So it's typical that when things keep going up and up, people want
to buy it and when things go down, people panic and want to sell.
And that's not necessarily, empirically the best strategy to follow.
So again, a robo advisor can, eliminate some of these behavioral biases.
if some things.
gone down, they might buy a little bit of it.
They're not going to sell it as a panic sell, and they might actually buy a little
bit, to rebalance, which empirically works out, better than, this herding mentality.
and there's other behavioral biases, individual investors, and again, I don't
think tech investors are any different.
They don't like to, realize losses.
if they've had a stock that's gone down, they, it's like admitting
defeat by selling it at a loss.
They just don't like doing it.
There's a lot of studies on this.
and, but for Robo Advisor, they actually say, Oh, we actually
do want to sell it at a loss.
We're going to buy something back similar.
but we don't have any problem realizing this loss.
so I think that I'm not sure that tech investors are any better
doing this than anyone else.
And we know that general investors are not very good at this.
I think tech people might be more willing to embrace tools that
help them avoid those sorts of biases than other people might.
So there might be overly represented in the client base of
robo advisors at the very least.
that's what we see.
All right, great.
where do you see all of this going?
So to me, it sounds like there are certain things that can be automated and you
can be more efficient with your taxes.
You can harvest some of those losses.
You can do all kinds of things to, to optimize the way, the timing and
the things that we just discussed.
what's the next step for robo advisors?
Is that the final destination?
Is that what they're going to stay, doing or is there like the next step
where they can provide even more value for like the next generation of it?
I have one small comment and then I'll let Alex do the rest.
so when I had a brief, stint at a robo advisor, we would do these focus
groups where we would, have people come in, we pay them a hundred dollars
for a few hours and we would show them our website and have them comment.
And it was fascinating for me to actually hear what like individual
investors, what they care about.
And a lot of them actually care about.
beating the market.
And we would try to say no, that's not our thing,
Rightly or wrongly, I think that's what people want.
they already go maybe into what's called smart beta ETFs.
These are ETFs that, claim that they, based on historical anomalies,
try to outperform the market.
So I think that could be an area.
I think, besides just investments, perhaps expansion into more financial
products that can benefit from technology, either to lower the cost or the
efficiency or the headache for people.
would be one way that I could see robo advisors expanding.
probably another thing to consider that we've touched on during this
call is that there's some things that robo advisors just will never do.
There are certain situations that really need hands on, advice, like
a state planning, things like that, where it's very specific to the person.
It can be lots of rules, regulations, very specific in
that you're hard for a program.
To consider all of the possible variations and, specific situations of people.
so I think there's always going to be a place for human, very
hands-on, tailored advice.
but, hopefully robo advisors gain a wider share in what can
be automated, a lot more easily.
So would you say that In, the famous 80/20 rule, you get 80 percent of the
benefits that you can get from, just being a bit more aware of what you do with your
money with 20 percent of effort or is it maybe even better in 90/10, just by
using something like that to begin with.
Yeah, I don't know about the exact split, but I'd say that
rule definitely applies, right?
Most of my life I'm going to be saving and investing, and then there's
only going to be one point in my life where I have to, plan for what
happens after I die, for example.
No robo advisor can help me with the whole thing up until the
point where I have to decide
Rob, a question to you, probably more given, you're educating people in finance.
Would you say that the trend of people getting more aware of what happens to
their money and being, more financially savvy, and invest in different
things is the financial literacy.
I guess it's the word really to use here, getting more widespread or
is it still staying something that the biggest chunk of the population
will probably never bother with.
I've been teaching at NYU for, 16 years or so, and I've definitely
noticed differences over the years I don't know if I could speak to like
whether the general population is getting more financially savvy or not.
my guess would be no, but there's definitely been changes in what students
bring to the table over the years.
When I started out in finance, it was really hard to like,
know the institutional details of how markets worked.
It was like almost there were like a few people that kind of understood how like
the specialist system in the New York Stock Exchange worked and, the professors
that knew that you would look up to them, like, how did they figure all this out,
like how they know both the academics and like the institutional knowledge.
And now I think the institutional knowledge is just much more
widely known, through, the internet and things like that.
So is the right word to say commoditizing that kind of knowledge, or is it
just the internet doing its thing?
People talk and secrets spread out,
that's also true.
when I started, it was much harder to even know, like what some hedge funds do now
there's still a lot of secrecy in hedge funds, like nobody knows how Jim Simons,
earns 66 percent returns every year, like he doesn't go out and, tell people like
exactly the secret sauce of what he does, but I think there's a lot more knowledge
about what hedge funds do and how they make money, for a variety of reasons.
yeah, there was, something called the quant crash in 2007 and
all the hedge funds got killed, over this three day period.
And then people reverse engineered it and figured out, Oh, all these hedge funds
are doing the, very similar strategies.
I think thas che other thing with in the hedge fund world is
it's getting much harder to find, great opportunities to make money.
I guess this is always the case.
Like when I started out, in the hedge fund world, I traded many different
strategies, but one strategy I traded was an index rebalancing strategy.
So all the indices like the S&P 500 would periodically rebalance and
you could predict what the S&P 500 would have to do, in one week's time.
And there's a whole cottage industry of hedge funds that would try to They'd say,
Oh, the hedge funds need to buy the stock.
We're going to buy this in advance of them.
that was like some knowledge that a lot of people know
about now it's just widespread.
they talk about it on CNBC, it's everywhere.
So a lot of these types of things just become much more well known.
got it.
Your book.
I see that the publication is estimated for June, 2024.
So I'm guessing it's all finished.
You're doing the final touches.
Do you know when it's supposed to hit Amazon?
I think the end of June, 24th or 25th is the date.
we had the copy editor go through the whole book, which she did a
very good job, and now we have the typesetter going through the book.
awesome.
So sometime in July if you're on LinkedIn, you're going to see plenty
of selfies with the book I was like, oh, it's real Looks like this
Congratulations.
So
to write good reviews on it and do all that stuff.
Yeah.
you can have a lot of explaining of how to write a review on Amazon.
So I'm hoping you ready for that
What's next after that?
Do you have an eye for the next adventure?
Are you teaming up for another book?
Or taking a breather?
I would consider another book.
I haven't figured out the topic yet.
It's like that Steven Wright joke.
It's an old joke, but I've written the page numbers now.
I just have to fill in the rest.
but I'm also, I got the domain name pynancial.com and I hope
to do some kind of blog where I periodically post, Interesting.
articles on the intersection of finance and Python.
I'm excited about, posting to there, too.
Pynantial.
Yeah, I like financial, but PYNANCIAL.
PYNANCE was PYNANCIAL was the next best thing.
we'll be on the lookout for that.
What about you, Alex?
let's see, this book was way more work than I thought it was going to be.
maybe I'll do another one, but it'll probably be a while.
one thing I am interested in though, is, teaching along the
lines of what Rob is doing.
So that might be my next adventure.
Yeah, I had the same thing.
So I was writing my first book with manning over the pandemic period.
And, I would just wake up at five and I have a few hours before I
started working and working from home.
So I basically use my commute time to write the bulk of it, really.
And then, one day it was finished, and I didn't have to wake up at 5,
and I felt a little weird about it.
And I'm missing that, so I'm guessing that's gonna kick in
soon enough for the two of you.
We'll see when it kicks in.
All right, guys.
It's been an absolute pleasure to talk to you.
I think, you've achieved in educating, at least at the very minimum, myself
about a lot of these things and hopefully some of our listeners as well.
once again, the book's available at manning.com at the moment, it's still
in the early access, program, but all the chapters are available right now.
You can go and have a browse.
And, from what it sounds like in a couple of months, you too will be able
to take a selfie with it and go on LinkedIn and look absolutely fabulous.
Build a robo advisor with Python from scratch.
Thank you guys.